| Quintiq file version 2.0 | 
| #parent: #root | 
| Method RunCapacityPlanningAlgorithm ( | 
|   AlgorithmRun algorithmrun, | 
|   ProductInStockingPointInPeriodPlannings pispipssmartplan, | 
|   Period_MP periodstart, | 
|   Period_MP periodend, | 
|   Units units, | 
|   Process_MP process, | 
|   OptimizerPuzzle optimizerpuzzle | 
| ) as stream[JSON] | 
| { | 
|   Description: 'Executes capacity planning for all demands within the planning horizon of MacroPlanner' | 
|   TextBody: | 
|   [* | 
|     // Select the periods that are in the optimizer horizon | 
|     periods := this.Optimization().GetOptimizerPeriods( periodstart, periodend );   | 
|     verify( periods.Size() > 0, Translations::Algorithm_MP_NoPeriodsAvailableError() );  | 
|     verify( not isnull( optimizerpuzzle ), Translations::Algorithm_MP_NoOptimizerPuzzleAvailableError() );  | 
|      | 
|     // | 
|     // ********************** Calling optimizer ********************** | 
|     //  | 
|     opt := this.Optimization();  | 
|     s := null( stream[JSON] );  | 
|      | 
|     if ( algorithmrun.IsSmartPlan() )  | 
|     { | 
|       osp := opt.GetOptimizerSmartPlan();  | 
|       s := osp.Execute( algorithmrun,  | 
|                         pispipssmartplan,  | 
|                         opt.GetLaneLegsForOptimization(),  | 
|                         periods,  | 
|                         units,  | 
|                         algorithmrun.IsUsingSelectedUnits(),  | 
|                         process,  | 
|                         this.GlobalParameters_MP().NumberOfPeriodsSmartPlan(),  | 
|                         algorithmrun.IsUpstreamSmartPlan(),  | 
|                         algorithmrun.IsMiddleOutSmartPlan(),  | 
|                         optimizerpuzzle );  | 
|     } | 
|     else if ( this.StrategyMacroPlan().UseMetaOptimizer() )  | 
|     { | 
|       opmeta := opt.GetOptimizerMeta();  | 
|       s := opmeta.Execute( algorithmrun, periods, units, optimizerpuzzle );  | 
|     } | 
|     else | 
|     { | 
|       ofrun := opt.GetOptimizerFullRun();  | 
|       s := ofrun.Execute( algorithmrun, units, periods, optimizerpuzzle );  | 
|     } | 
|     return s; | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |