admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
Method StopForBenchmarking (
  LibOpt_Task task,
  SnapshotMacroPlannerOptimizer lastsnapshot,
  RunContextForCapacityPlanning runcontext,
  Real scoreforlevel
) as Boolean
{
  TextBody:
  [*
    value := false; 
    targetscore := this.BenchmarkingStopScore(); 
    if ( targetscore.IsFinite() ) // not finite means not set 
    {
      ispenalty := targetscore <= 0; 
      lowquality := this.BenchmarkingStopFraction(); 
      
      factor_low := ifexpr( ispenalty, 2.0 - lowquality , lowquality ); 
      
      // 0.98 quality we translate to absolute treshold -0.0002 in case target = 0.   
      cutoff_low := ifexpr(  targetscore = 0 , (lowquality-1) / 100, factor_low * targetscore); 
      scorefraction := ifexpr(  targetscore = 0, scoreforlevel, (scoreforlevel / targetscore).Round( 5 ) );  
      value := scoreforlevel >= cutoff_low;  
      debuginfo(  'Stop score for benchmarking:', cutoff_low, 
                  'Target = ', targetscore, 
                  'current score fraction = ', scorefraction, 
                  '(needed = ', factor_low, ')', 
                  'stop = ', value );  
      lastsnapshot.BenchmarkingScoreFraction( scorefraction ); 
      lastsnapshot.BenchmarkingTargetScore( targetscore ); 
    }
    value := value and runcontext.IsForBenchmarking(); // we still want to log above stats in case we are not benchmarking, but only use this during benchmarking
    return value;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}