| Quintiq file version 2.0 | 
| #parent: #root | 
| Method CapacityPlanningAlgorithmInitVariables ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const RunContextForCapacityPlanning runcontext, | 
|   const constcontent PeriodTaskOperations userperiodtasks, | 
|   const constcontent ProductInTrips userproductintrips, | 
|   const constcontent ProductInStockingPointInPeriodPlannings pispipssmartplan, | 
|   const LibOpt_Scope scope, | 
|   const constcontent ProductInStockingPointInPeriodPlannings pispipsinrun, | 
|   constcontent ProductInStockingPointInPeriodPlanningLeafs leafpispipsinrun, | 
|   const constcontent ProductInStockingPoint_MPs pispsinrun, | 
|   const constcontent ProductInTrips pitinrun | 
| ) const | 
| { | 
|   TextBody: | 
|   [* | 
|     runcontext := this.GetRunContextConst();  | 
|     if( not runcontext.IsInventoryOptimizationRun() ) | 
|     { | 
|       progress( 'Init variables', DateTime::ActualTime()); | 
|       info( 'Init variables', DateTime::ActualTime()); | 
|     } | 
|      | 
|     this.RegisterTypes( program ); | 
|      | 
|     computenvar := this.MacroPlan().Optimization().DebugMode();  | 
|     nvars := ifexpr( computenvar, counter( program, Variables, v, true, true ), 0 );  | 
|     oldnvars := nvars;  | 
|     if ( computenvar )  | 
|     { | 
|       debuginfo(  'start vars:', nvars );  | 
|     } | 
|     // Create variables for KPI total value | 
|     this.InitVariablesForKPITotalValue( program, runcontext, scope ); | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' this.InitVariablesForKPITotalValue( program, runcontext, scope );', nvars-oldnvars );   | 
|       oldnvars := nvars;  | 
|     } | 
|     // create variables for supply | 
|     this.InitVariablesForOperationPeriodTask( program, userperiodtasks, scope ); | 
|     if ( computenvar ) | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' periodtask related vars:', nvars-oldnvars );   | 
|       oldnvars := nvars;  | 
|     } | 
|      | 
|     this.InitVariablesForTrip( program, userproductintrips, scope, pitinrun ); | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' trip related vars;', nvars-oldnvars);   | 
|       oldnvars := nvars;  | 
|     } | 
|      | 
|     // create variables for sales demands | 
|     this.InitVariablesForSalesDemands( program, scope ) | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' sales demand vars:', nvars-oldnvars );   | 
|       oldnvars := nvars;  | 
|     } | 
|      | 
|     // create variable for pispip | 
|     this.InitVariablesForPISPIP( program, pispipssmartplan, scope, pispipsinrun, leafpispipsinrun, pispsinrun ); | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' pispips vars:', nvars-oldnvars);   | 
|       oldnvars := nvars;  | 
|     } | 
|      | 
|     // create variable for stocking point inventory | 
|     this.InitVariablesForStockingPointInventory( program, runcontext, scope ); | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' sp vars:', nvars-oldnvars );   | 
|       oldnvars := nvars;  | 
|     } | 
|      | 
|     // create variable for unit period quantity | 
|     this.InitVariablesForUnitPeriods( program, scope ); | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' unit period vars:', nvars-oldnvars );   | 
|       oldnvars := nvars;  | 
|     } | 
|      | 
|     // create variable for supply specification | 
|     this.InitVariablesForSupplySpecification( program, scope ); | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' supply spec:', nvars-oldnvars );   | 
|       oldnvars := nvars;  | 
|     }  | 
|      | 
|     //Generate variables related to campaigns if campaignoptimization is enabled | 
|     this.InitVariablesForCampaignCombiSelection( program, runcontext, scope );  | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' campaign related vars:', nvars-oldnvars );   | 
|       oldnvars := nvars;  | 
|     } | 
|      | 
|     // create variables for shift patterns | 
|     this.InitVariablesForShiftPatterns( program, runcontext, scope ); | 
|     if ( computenvar )  | 
|     { | 
|       nvars := counter( program, Variables, v, true, true );  | 
|       debuginfo( ' shift pattern vars:', nvars-oldnvars );   | 
|       oldnvars := nvars;  | 
|     }  | 
|      | 
|     //Also add the total number of vars when in debugmode | 
|     if ( computenvar )  | 
|     { | 
|       debuginfo( 'Total variables:', nvars );  | 
|     } | 
|      | 
|     if ( this.IsPriorLevelsFixed() )   | 
|     { | 
|       this.FixDecisionVariablesToCurrentPlanBasedOnLevel( program, runcontext, scope );  | 
|     } | 
|      | 
|     // In the inventory optimization, we need to obtain the KPIs of each simulation at the end of the simulation | 
|     // Therefore, we rerun the optimizer over the full horizon with the decisions frozen | 
|     if( runcontext.IsFrozenRun() ) | 
|      | 
|     { | 
|       debuginfo(  'Freezing decision variables. CurrentLevel = ', this.CurrentSubOptimizerLevel().LevelNumber() );  | 
|       unfreeze := false;  | 
|       this.Debug_FreezeDecisionVariables( program, runcontext.FirstPeriod_MP(), runcontext.LastPeriod_MP(), scope, unfreeze );  | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |