yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
MethodOverride CreateIssues
{
  Description: 'Create `LibOpt_Issues` to highlight potential issues about values collected by this `LibOpt_StatisticTimeSuboptimizer`.'
  TextBody:
  [*
    // lle13 Oct-1-2020 (created)
    
    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();
      algorithmsnapshots := selectsortedset( this, Suboptimizer.SnapshotComponent.Children.astype( LibOpt_SnapshotAlgorithm ), algorithmsnapshot,
                                             // FILTER
                                             true,
                                             // VALUE
                                             algorithmsnapshot.SequenceNr()
                                           );
      
      if( haslowerthresholdviolations )
      {
        severityscaleentries_lowerthresholdviolation := LibOpt_Statistic::GetSeverityScaleEntriesSortedByThreshold( this.GetSeverityScaleForLowerThresholdViolation() );
        
        traverse( indexvector_lowerthresholdviolation.AsValues(), Elements, index )
        {
          value := valuesvector.Get( index );
          
          // Create an Issue and link it to the relevant Snapshot.
          algorithmsnapshot := algorithmsnapshots.Element( index );
          LibOpt_Issue::Create( this,
                                algorithmsnapshot,
                                this.GetIssueType(),
                                this.Focus()
                                  + ', ' + Translations::LibOpt_Suboptimizer_ExecutionNr( algorithmsnapshot.ExecutionNr() )
                                  + ', ' + Translations::LibOpt_IterationNr( algorithmsnapshot.GetIteration().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 );
          
          // Create an Issue and link it to the relevant Snapshot.
          algorithmsnapshot := algorithmsnapshots.Element( index );
          LibOpt_Issue::Create( this,
                                algorithmsnapshot,
                                issuetype,
                                this.Focus()
                                  + ', ' + Translations::LibOpt_Suboptimizer_ExecutionNr( algorithmsnapshot.ExecutionNr() )
                                  + ', ' + Translations::LibOpt_IterationNr( algorithmsnapshot.GetIteration().IterationNr(), this.Run().TotalNrOfIterations() ),
                                this.GetSeverity( value, true /*is upper threshold violation*/, severityscaleentries_upperthresholdviolation ),
                                this.GetIssueDetails( value )
                              );
        }
      }
    }
  *]
}