| 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' } | 
| } |