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
Quintiq file version 2.0
#parent: #root
Method GetDurationForAutoTune (
  LibOpt_Snapshot snapshot,
  output Real avgdurationseconds_o,
  output Real averagenbhsize_o,
  output Number nroksnapshots_o,
  output Boolean anyfriendsadded_o
) as Boolean
{
  TextBody:
  [*
    nrsnapshots := 0;  
    totalduration := 0.0; 
    totalneigborhoodsize := 0; 
    lastiterationhassolution := false;  
    anyfriendsadded_o := false; 
    windowsize := ifexpr(  this.InitialAggressiveSizeAdapt(), 1, SelectorMeta::WindowSizeForAutotune() ); 
    nrofsnapshotmacroplannerchecked := 0; 
    while ( not isnull( snapshot ) and nrsnapshots < windowsize ) 
    {
      if ( snapshot.istype( SnapshotMacroPlannerOptimizer ) 
           and snapshot.astype(  SnapshotMacroPlannerOptimizer ).FocusLevel() = this.FocusLevel() ) 
      {
        nrofsnapshotmacroplannerchecked++; 
        mysnapshot := snapshot.astype( SnapshotMacroPlannerOptimizer );
    
        if ( mysnapshot.Comment() = Translations::LibOpt_SnapshotKPI_CommentPostHandleResult()
             and mysnapshot.DurationSecondsSolveSubOptimizer().IsFinite() ) 
        { 
          if ( nrofsnapshotmacroplannerchecked = 1 ) 
          {
            lastiterationhassolution := true; 
          }
          nrsnapshots++; 
          totalduration := totalduration + mysnapshot.DurationSecondsSolveSubOptimizer(); 
          totalneigborhoodsize := totalneigborhoodsize + mysnapshot.NrPISPIPPlanningOptimizerRun(); 
          anyfriendsadded_o := anyfriendsadded_o or mysnapshot.SelectorAddedFriends(); 
        }
      }
      snapshot := snapshot.PreviousOnRun(); 
    }
    if ( nrsnapshots > 0 ) 
    {
      avgdurationseconds_o := totalduration / nrsnapshots; 
      averagenbhsize_o := totalneigborhoodsize / nrsnapshots; 
    }
    nroksnapshots_o := nrsnapshots; 
    return lastiterationhassolution;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}