lazhen
2025-01-07 b3987122cbbc46c5c59d3173f37fca3170b6dc5a
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
Quintiq file version 2.0
#parent: #root
Method SetDefaultValue () id:Method_DialogSelectOptimizer_SetDefaultValue
{
  #keys: '[112884.0.24363403]'
  Body:
  [*
    // Set default value for components
    
    run := MacroPlan.Optimization().GetLastRegularAlgorithmRun();
    
    // Optimizer
    lastUsedOptimizer := MacroPlan.LastUsedOptimizerPuzzle();
    
    if( isnull( lastUsedOptimizer ) )
    {
      lastUsedOptimizer := MacroPlan.OptimizerPuzzleWorld();
    }
    
    Dialog.SetSelectionOptimizer( lastUsedOptimizer );
       
    // Strategy
    strategy := AlgorithmRun::GetLastStrategyUsed( MacroPlan.GlobalParameters_MP(), run, ScenarioManager, true, false );
    SelectionStrategy.BoundValue( guard( strategy.Name(), '' ) );
    
    
    // Set the default planning start and end
    feedback := '';
    if( Period_MP::HasPeriod( feedback, MacroPlan ) )
    {
      Dialog.SetDefaultPlanningStartAndEnd();
      
      // Prevent the usage of last optimizer start if it is historical
      if( not isnull( run )
          and MacroPlan.StartOfPlanningPeriod().Start() <= run.PeriodFirstStart() )
      {
        // Using bound value is not working as expected
        periodstart := select( MacroPlan, PlanningPeriod, p, p.Start() = run.PeriodFirstStart() );
        periodend := select( MacroPlan, PlanningPeriod, p, p.PeriodEnd() = run.PeriodLastEnd() );
        SelectionPeriodFrom.Data( periodstart );
        SelectionPeriodTo.Data( periodend );
      }
    }
    
    CheckBoxOverrideManualPlanning.Checked( guard( run.HasOverwrittenManualPlanning(), false ) );
  *]
}