chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Quintiq file version 2.0
#parent: #root
MethodOverride CreateIssues
{
  Description: 'Create `LibOpt_Issues` to highlight potential issues about values collected by this `LibOpt_StatisticTimeTotal`.'
  TextBody:
  [*
    valuesvector := RealVector::Construct( this.ValuesAsRealVector() );
    
    // Check for lower threshold violations.
    booleanvector_lowerthresholdviolation := valuesvector.SmallerThan( this.LowerThreshold() );
    indexvector_lowerthresholdviolation := booleanvector_lowerthresholdviolation.AsIndexVector();
    haslowerthresholdviolations := indexvector_lowerthresholdviolation.Size() > 0;
    
    // Check for upper threshold violations.
    booleanvector_upperthresholdviolation := valuesvector.GreaterThan( this.UpperThreshold() );
    indexvector_upperthresholdviolation := booleanvector_upperthresholdviolation.AsIndexVector();
    hasupperthresholdviolations := indexvector_upperthresholdviolation.Size() > 0;
    
    // Create Issues if there are violations.
    if( haslowerthresholdviolations or hasupperthresholdviolations )
    {
      //>> Variables needed for Issues creation.
      issuetype := this.GetIssueType();
      
      iterations := construct( LibOpt_Iterations );
      if( this.IsType() or this.IsRoot() )
      {
        iterations := selectsortedset( this, Run.Iteration, iteration,
                                       // FILTER
                                       true,
                                       // VALUE
                                       iteration.IterationNr()
                                     );
      }
      
      snapshotcomponents := construct( LibOpt_SnapshotComponents );
      if( this.IsComponent() )
      {
        snapshotcomponents := selectsortedset( this, Component.SnapshotComponent, snapshotcomponent,
                                               // FILTER
                                               true,
                                               // VALUE
                                               snapshotcomponent.SequenceNr()
                                             );
      }
      //<<
      
      if( haslowerthresholdviolations )
      {
        severityscaleentries_lowerthresholdviolation := LibOpt_Statistic::GetSeverityScaleEntriesSortedByThreshold( this.GetSeverityScaleForLowerThresholdViolation() );
        
        traverse( indexvector_lowerthresholdviolation.AsValues(), Elements, index )
        {
          value := valuesvector.Get( index );
          
          iteration := null( LibOpt_Iteration );
          snapshot := null( LibOpt_Snapshot );
          
          if( this.IsComponent() )
          {
            snapshot := snapshotcomponents.Element( index );
            iteration := snapshot.GetIteration();
          }
          else
          {
            iteration := iterations.Element( index );
            snapshot := iteration.SnapshotOwning();
          }
          
          // Create an Issue and link it to the relevant Snapshot.
          LibOpt_Issue::Create( this,
                                snapshot,
                                issuetype,
                                this.Focus() + ', ' + Translations::LibOpt_IterationNr( iteration.IterationNr(), this.Run().TotalNrOfIterations() ),
                                this.GetSeverity( value, false /*is upper threshold violation*/, severityscaleentries_lowerthresholdviolation ),
                                this.GetIssueDetails( value )
                              );
        }
      }
      
      if( hasupperthresholdviolations )
      {
        severityscaleentries_upperthresholdviolation := LibOpt_Statistic::GetSeverityScaleEntriesSortedByThreshold( this.GetSeverityScaleForUpperThresholdViolation() );
        
        traverse( indexvector_upperthresholdviolation.AsValues(), Elements, index )
        {
          value := valuesvector.Get( index );
          
          iteration := null( LibOpt_Iteration );
          snapshot := null( LibOpt_Snapshot );
          
          if( this.IsComponent() )
          {
            snapshot := snapshotcomponents.Element( index );
            iteration := snapshot.GetIteration();
          }
          else
          {
            iteration := iterations.Element( index );
            snapshot := iteration.SnapshotOwning();
          }
          
          // Create an Issue and link it to the relevant Snapshot.
          LibOpt_Issue::Create( this,
                                snapshot,
                                issuetype,
                                this.Focus() + ', ' + Translations::LibOpt_IterationNr( iteration.IterationNr(), this.Run().TotalNrOfIterations() ),
                                this.GetSeverity( value, true /*is upper threshold violation*/, severityscaleentries_upperthresholdviolation ),
                                this.GetIssueDetails( value )
                              );
        }
      }
    }
  *]
}