| Quintiq file version 2.0 | 
| #parent: #root | 
| Method SetOptimizerPuzzle ( | 
|   OptimizerPuzzle optpuzzle, | 
|   Period_MPs periods | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     verify( not isnull( optpuzzle ),  Translations::Algorithm_MP_NoOptimizerPuzzleAvailableError() );  | 
|      | 
|     macroplan := this.MacroPlan();  | 
|     traverse( macroplan, Period_MP, period )  | 
|     { | 
|       period.IsInOptimizerPuzzle( false );  | 
|     } | 
|      | 
|     traverse( periods, Elements, period )  | 
|     { | 
|       period.IsInOptimizerPuzzle( true );  | 
|     } | 
|      | 
|     // set is included flags on product. Only used within this method to make selection of PISPs more efficient.  | 
|     traverse(  macroplan, Product_MP, product )  | 
|     { | 
|       product.IsInOptimizerPuzzle( false ); // clear flags on all | 
|     } | 
|     traverse(  optpuzzle.GetIncludedProducts(), Elements, product )  | 
|     { | 
|       product.IsInOptimizerPuzzle( true ); // set according to puzzle | 
|     } | 
|      | 
|     units := optpuzzle.GetIncludedUnits();   | 
|     sps := optpuzzle.GetIncludedStockingPoints( units ); | 
|      | 
|     traverse( macroplan, StockingPoint_MP, sp )  | 
|     { | 
|       sp.isInOptimizerPuzzle( false );  | 
|     } | 
|     traverse(  sps, Elements, sp )  | 
|     { | 
|       sp.isInOptimizerPuzzle( true );  | 
|     } | 
|      | 
|     traverse( macroplan, Unit, unit )  | 
|     { | 
|       unit.IsInOptimizerPuzzle( false );  | 
|     } | 
|      | 
|     traverse( units, Elements, unit ) | 
|     { | 
|       unit.IsInOptimizerPuzzle( true );  | 
|       unit.OptimizerFullRunAddedOperationOrTrip( false );  | 
|     } | 
|      | 
|     if ( this.DebugMode() ) // write back values to check we adhere to the sub puzzle | 
|     { | 
|       traverse( macroplan, Unit.UnitPeriod, up )  | 
|       { | 
|         up.DebugSubPuzzleQuantityToProcessPrior( up.QuantityToProcess() );  | 
|       } | 
|        | 
|       traverse( macroplan, StockingPoint_MP.ProductInStockingPoint_MP.ProductInStockingPointInPeriodPlanning, p )  | 
|       { | 
|         p.DebugSubPuzzleInventoryEndPrior( p.InventoryLevelEnd() );    | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |