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
Quintiq file version 2.0
#parent: #root
StaticMethod GetLastStrategyUsed (
  GlobalParameters_MP gp,
  AlgorithmRun run,
  ScenarioManager scenariomanager,
  Boolean runfinite,
  Boolean issmartplan
) remote as Strategy
{
  Description: 'Return the last strategy used. Otherwise, return the default strategy'
  TextBody:
  [*
    // Strategy name priority
    // 1- Return lastrun strategy name if there is a lastrun.
    // 2- If there is no last run and it is a smartplan, then return the strategy name defined on the global parameter. 
    // 3- If there is no last run and it is a smartplan and global parameter name is not defined then return default name.
    // 4- If there is no last run and it is not a smartplan then return the default name  
    globalparameter := gp; //guard( run.Algorithm_MP().MacroPlan().GlobalParameters_MP(), null( GlobalParameters_MP ) );;
    defaultname := ifexpr( runfinite, Translations::MP_GlobalParameters_DefaultStrategyName(), Translations::MP_GlobalParameters_DefaultStrategyInfiniteName() );
    qpsmartplandefaultname := guard( ifexpr( globalparameter.DefaultSmartPlanStrategy().Length() > 0, globalparameter.DefaultSmartPlanStrategy(), defaultname ), defaultname ); 
    name := ifexpr( issmartplan, qpsmartplandefaultname, defaultname );
    strategyname := guard( run.StrategyName(), name );
    strategy := select( scenariomanager, Strategy, strategy, strategy.Name() = strategyname );
    
    return strategy;
  *]
}