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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Quintiq file version 2.0
#parent: #root
Method GetSSGForTuning () as SolverSettingGroup
{
  Description: 'Select the SSG that should be tried on this strategylevel in the next tuning run'
  TextBody:
  [*
    // Martijn Apr-11-2016 (created)
    solversettinggroup := this.SolverSettingGroup();
    
    // If there is at least one SolverSettingGroup that has not been tested on this strategy level
    if( exists( this, SSGInStrategyLevel, ssginsl, not ssginsl.IsTested() ) )
    // select the first SolverSettingGroup that is not tested in alphabetical order
    {
      solversettinggroup := guard( minselect( this, SSGInStrategyLevel, ssginsl,           // Select the SSGInStrategyLevel for which
                                              not ssginsl.IsTested(),                      // The solver setting group has not been tested on the strategy level
                                              ssginsl.SolverSettingGroupName()             // select the first in alphabetical order
                                            ).SolverSettingGroup(),                        // Select the SSG of this SSGInStrategyLevel
                                   null( SolverSettingGroup ) );
    }
    // if the combination of the best settings on eahc level have not yet been tested for this strategy
    else if( not this.Strategy().HasTestedBestSSG() )
    {
      // Select the solversettingroup with the shortest last duration on this level
      solversettinggroup := guard( minselect( this, SSGInStrategyLevel, ssginsl, true, ssginsl.LastDuration() ).SolverSettingGroup(),
                                   null( SolverSettingGroup ) );
      // If this is the last strategy level, set the HasTestedBestSSG of the strategy to true
      if( not exists( this, Next.KPIWeight, kpiweight, kpiweight.Weight() > 0 and kpiweight.Level() > 0 ) )
      {
        this.Strategy().HasTestedBestSSG( true );
      }
    }
    else if( this.IsActiveTuningLevel() )
    {
      // Select the solver setting group with the oldest last tuning run on this level. If equal, select the one with the shortest duration.
      solversettinggroup := guard( minselect( this, SSGInStrategyLevel, ssginsl,
                                              true,
                                              ssginsl.DateLastTuningRun(),           // Select the solversettinggroup with the oldest last tuning run
                                              ssginsl.LastDuration()                 // If equal, select the one with the shortest duration
                                            ).SolverSettingGroup(),                  // Select the SSG of this SSGInSL
                                   null( SolverSettingGroup ) );
    }
    // Otherwise select the solversettinggroup that is currently the default
    else
    {
      solversettinggroup := guard( this.SolverSettingGroup(), null( SolverSettingGroup ) );
    }
    
    return solversettinggroup;
  *]
}