haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Quintiq file version 2.0
#parent: #root
Method RunBenchmarking (
  LibOBT_RunTask runtask,
  Strategy strategy,
  LibOBT_RunTaskSetting setting
)
{
  TextBody:
  [*
    this.CleanData(); 
    Transaction::Transaction().Propagate(); // removing some operations - need to update all 
    this.Optimization().TempAlgorithmRunStore().AlgorithmRun( relflush ); 
    this.DuplicateStrategySettings( strategy, false /* not re-using strategy macroplan*/ ); 
    this.Optimization().IsForcedNoAutoScaling( true ); // no scaling
    
    // Update the optimizer status to running
    sm := Util::GetScenarioManagerStream(); 
    sm->UpdateScenarioOptimizerStatus( this.MDSID(), Translations::MP_GlobalParameters_GetOptimizerRunningStatus(), "", "" );
    
    
    // Since it is a benchmarking run, it is not a smart plan run
    issmartplan := false; 
    issmartplanforperiodtask := false;
    hastotalsupplyuser := false;
    totalsupplyuser := 0.0;
    isupstreamsmartplan := false;
    ismiddleoutsmartplan := false;
    isonlyplanonestepupstream := false;
    
    // since it is benchmarking, it is not postprocessing 
    ispostprocessing := false;
    isforcednoautoscaling := true;
    
    // Since it is a benchmarking run, the locked planning should be overwritten
    isoverwritelockedplanning := runtask.OverrideManualPlanning();
    
    // Since it is a benchmarking run, it is not an inventory optimization run and we do not limit the selected units
    isinventoryoptimization := false;
    isuseselectedunits  := false;
    
    this.Algorithm_Parameter().Update( issmartplan, issmartplanforperiodtask, 
                                              hastotalsupplyuser, totalsupplyuser, isupstreamsmartplan, ismiddleoutsmartplan, isonlyplanonestepupstream,
                                              ispostprocessing,
                                              isforcednoautoscaling,
                                              isoverwritelockedplanning,
                                              isinventoryoptimization,
                                              isuseselectedunits, 
                                              false ); // run is async
    
    // Updates the parameters of the run
    
    firstperiod := minselect( this, PlanningPeriod, p, not p.IsHistorical() and p.StartDate() >= runtask.StartDate(), p.StartDate() ); 
    lastperiod := maxselect( this, PlanningPeriod, p, p.StartDate() <= runtask.EndDate(), p.StartDate() ); 
    
    algorithmrun := this.UpdateParameters( null( ProductInStockingPointInPeriodPlannings ), // since it is benchmarking, it is not smart plan
                                           this.StrategyMacroPlan(), 
                                           firstperiod, lastperiod,
                                           setting );
    
    algorithmrun.UpdateForBenchmarking( runtask.ID(),
                                        runtask.TestInstanceID(),
                                        runtask.LibOBT_Benchmarker().LibOBT_BenchmarkerParameter().TotalThreadsAllowed(), // upper bound for nr of threads used
                                        setting.Description(),
                                        runtask.LibOBT_Benchmarker().LibOBT_BenchmarkerParameter().IsBenchmarkingRun() );
    
    // Split as different job to release scenario manager dataset.
    s := this->RunCapacityPlanningAlgorithm( algorithmrun, 
                                             null( ProductInStockingPointInPeriodPlannings ), // No Smart plan, so no Smart plan pispips
                                             firstperiod, 
                                             lastperiod, 
                                             null( Units ),
                                             null( Process_MP ), 
                                             this.OptimizerPuzzleWorld() )
    
    s->Exception()->MacroPlan::HandleErrorBenchmarkRun( this, algorithmrun, runtask.ID() );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}