| Quintiq file version 2.0 | 
| #parent: #root | 
| MethodOverride CreateRun () as LibOpt_Run | 
| { | 
|   TextBody: | 
|   [* | 
|     run := super.CreateRun(); | 
|      | 
|     mp := this.Optimization().astype( Optimization ).MacroPlan();  | 
|      | 
|     settings := this.ActiveSettings().astype( OptimizerFullRunSettings );  | 
|     puzzle := select( mp, OptimizerPuzzle, puzzle, true, puzzle.Name() = settings.PuzzleName() );  | 
|      | 
|     periodstart := minselect( mp, Period_MP, p, not p.IsHistorical(), p.StartDate() );  | 
|     periodend := mp.LastPlanningPeriod();  | 
|      | 
|     this.Optimization().astype( Optimization ).GetPeriodsForOTS( periodstart, periodend, settings );  | 
|      | 
|     issmartplan := false;  | 
|     issmartplanforperiodtask := false;   | 
|     hastotalsupplyuser := false;  | 
|     totalsupplyuser := 0.0;  | 
|     smartplanpispips := null( ProductInStockingPointInPeriodPlanningLeafs );  | 
|     isupstreamsmartplan := false;  | 
|     ismiddleoutsmartplan := false;  | 
|     isonlyplanonestepupstream := false;  | 
|     ispostprocessing := false;  | 
|     isforcenoautoscaling := true;  | 
|     isoverridemanualplanning := settings.OverrideManualPlanning();  | 
|     isinventoryoptimizationrun := false;  | 
|     isusingselectedunits := false;  | 
|     units := null( Units );  | 
|     process := null( Process_MP );  | 
|      | 
|     algrun := mp.InitializeOptimizerRun( issmartplan,  | 
|                                          issmartplanforperiodtask,  | 
|                                          hastotalsupplyuser,  | 
|                                          totalsupplyuser,  | 
|                                          smartplanpispips,  | 
|                                          isupstreamsmartplan,  | 
|                                          ismiddleoutsmartplan,  | 
|                                          isonlyplanonestepupstream,  | 
|                                          ispostprocessing, | 
|                                          isforcenoautoscaling,  | 
|                                          null( Strategy ), // for OTS we have a workaround via method  LibOpt_BT_RunSequenceElement.MyMethodTemp that copies the strategy | 
|                                          isoverridemanualplanning,  | 
|                                          periodstart,  | 
|                                          periodend,  | 
|                                          isinventoryoptimizationrun,  | 
|                                          isusingselectedunits,  | 
|                                          units,  | 
|                                          process,  | 
|                                          puzzle );   | 
|      | 
|      | 
|     context := RunContextForCapacityPlanning::Create( run, units, periodstart, periodend ); // our create component expects a fully initialized runcontext (for which we need an AlgorithmRun first) | 
|     context.Initialize( algrun ); | 
|     return run; | 
|   *] | 
| } |