| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitConstraintsForOperationDependentDemandInPeriod ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const RunContextForCapacityPlanning runcontext, | 
|   const LibOpt_Scope scope | 
| ) const | 
| { | 
|   Description: | 
|   [* | 
|     A constraint to calculate the dependent demand quantity of an input per bucket. | 
|     Specially for dependent demand belonging to operation with pre-processing duration. | 
|   *] | 
|   TextBody: | 
|   [* | 
|     // dependent demand quantity per bucket = sum of all dependent demands that fall at that bucket | 
|     // Specially for dependent demand belonging to operation with pre-processing duration. | 
|      | 
|     constddperiodname := typeof( MPOperationDependentDemandPeriodQtyConstraint ); | 
|      | 
|     scalefactor_operationdemandqty_constddperiod := this.ScaleConstraintTerm( typeof( MPOperationDemandQtyVariable ), constddperiodname ); | 
|     scalefactor_partialoperationdemandqty_constddperiod := this.ScaleConstraintTerm( typeof( MPPartialOperationDemandQtyVariable ), constddperiodname ); | 
|      | 
|     scalefactor_rhs_constddperiod := this.ScaleConstraintRHS( constddperiodname, 1.0 ); | 
|      | 
|     traverse( scope.GetOperationInOptimizerRunConst(), Elements, operation, operation.HasLeadTime() ) | 
|     { | 
|       // Only select the input where the product is included. | 
|       traverse( operation, OperationInput, input, input.HasRegularProductforOptimizer() or input.GetIsProductInOptimizerRun( runcontext.IsPostProcessing() ) ) | 
|       { | 
|         if ( this.GetPeriodsFromPeriodTaskOperation() )  | 
|         { | 
|           traverse( operation, PeriodTaskOperationInScope, pto ) // these are the period GetPeriodsForOperation( scope, operation ) would supple | 
|           { | 
|             ptperiod := pto.UnitPeriod().Period_MP();  | 
|              | 
|             traverse( pto, DependentDemand.ProductInStockingPointInPeriodPlanningLeaf.Period_MP, ddperiod )  | 
|             { | 
|               this.InitConstraintsForOperationDependentDemandInPeriod_AddConstraint( program, | 
|                                                                                      ptperiod,  | 
|                                                                                      ddperiod,  | 
|                                                                                      input,  | 
|                                                                                      scalefactor_operationdemandqty_constddperiod,  | 
|                                                                                      scalefactor_partialoperationdemandqty_constddperiod,  | 
|                                                                                      scalefactor_rhs_constddperiod );  | 
|             }     | 
|           } | 
|         } | 
|         else | 
|         { | 
|           periods := this.GetPeriodsForOperation( scope, operation ); | 
|        | 
|           // Need to select all relevant periods. These are the periods in which the operation can run and their dependent demand periods | 
|           traverse( periods, Elements, ptperiod ) | 
|           { | 
|             ddperiods := construct( Period_MPs, constcontent ); | 
|             CapacityPlanningSuboptimizer::GetOperationDependentDemandPeriods( ptperiod, operation, &ddperiods, this.GetPeriodsFromPeriodTaskOperation() ); | 
|        | 
|             traverse( ddperiods, Elements, ddperiod ) | 
|             {      | 
|               this.InitConstraintsForOperationDependentDemandInPeriod_AddConstraint( program, | 
|                                                                                    ptperiod,  | 
|                                                                                    ddperiod ,  | 
|                                                                                    input,  | 
|                                                                                    scalefactor_operationdemandqty_constddperiod,  | 
|                                                                                    scalefactor_partialoperationdemandqty_constddperiod,  | 
|                                                                                    scalefactor_rhs_constddperiod );  | 
|             } | 
|           } | 
|         } | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |