| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitConstraintsForOperationDependentDemandInputSet ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const RunContextForCapacityPlanning runcontext, | 
|   const LibOpt_Scope scope | 
| ) const | 
| { | 
|   Description: 'Initialize constraints for dependent demands which is part of an input group and belongs to an input set.' | 
|   TextBody: | 
|   [* | 
|     maxconstname := typeof( MPOperationInputSetUpperBoundConstraint );  | 
|     minconstname := typeof( MPOperationInputSetLowerBoundConstraint ); | 
|      | 
|     scalefactor_periodtaskqty_maxconst := this.ScaleConstraintTerm( typeof( MPPTQtyVariable ), maxconstname ); | 
|     scalefactor_operationinputsetover_maxconst := this.ScaleConstraintTerm( typeof( MPOperationInputSetOverVariable ), maxconstname ); | 
|     scalefactor_periodtaskqty_minconst := this.ScaleConstraintTerm( typeof( MPPTQtyVariable ), minconstname ); | 
|     scalefactor_operationinputsetunder_minconst := this.ScaleConstraintTerm( typeof( MPOperationInputSetUnderVariable ), minconstname ); | 
|     scalefactor_partialoperationdemandqty_maxconst := this.ScaleConstraintTerm( typeof( MPPartialOperationDemandQtyVariable ), maxconstname ); | 
|     scalefactor_partialoperationdemandqty_minconst := this.ScaleConstraintTerm( typeof( MPPartialOperationDemandQtyVariable ), minconstname ); | 
|     scalefactor_operationdemandqty_maxconst := this.ScaleConstraintTerm( typeof( MPOperationDemandQtyVariable ), maxconstname ); | 
|     scalefactor_operationdemandqty_minconst := this.ScaleConstraintTerm( typeof( MPOperationDemandQtyVariable ), minconstname ); | 
|           | 
|     scalefactor_rhs_maxconst := this.ScaleConstraintRHS( maxconstname, 1.0 ); | 
|     scalefactor_rhs_minconst := this.ScaleConstraintRHS( minconstname, 1.0 );     | 
|           | 
|     traverse( scope.GetOperationInputSetInOptimizerRunConst(), Elements, set, | 
|               not exists( set, OperationInput, input, | 
|                           not input.GetIsProductInOptimizerRun( runcontext.IsPostProcessing() ) ) ) // Filter the set if one or more inputs is excluded | 
|     { | 
|        | 
|       operation := set.Operation(); | 
|       // If the outputquantity is zero, then the uom is the uom of the unit | 
|       maxfactor := set.MaxQuantity(); | 
|       minfactor := set.MinQuantity(); | 
|       if( operation.OutputQuantity() > 0.0 ) | 
|       { | 
|         maxfactor := set.MaxQuantity() / operation.OutputQuantity(); | 
|         minfactor := set.MinQuantity() / operation.OutputQuantity(); | 
|       } | 
|      | 
|       if ( this.GetPeriodsFromPeriodTaskOperation() )  | 
|       { | 
|         traverse( operation, PeriodTaskOperationInScope, pto )  | 
|         { | 
|           period := pto.UnitPeriod().Period_MP();  | 
|           this.InitConstraintsForOperationDependentDemandInputSet_Add( program,  | 
|                                                                  runcontext,  | 
|                                                                  scope,  | 
|                                                                  set,  | 
|                                                                  period, | 
|                                                                  pto,  | 
|                                                                  scalefactor_periodtaskqty_maxconst, | 
|                                                                  scalefactor_operationinputsetover_maxconst, | 
|                                                                  scalefactor_periodtaskqty_minconst, | 
|                                                                  scalefactor_operationinputsetunder_minconst, | 
|                                                                  scalefactor_partialoperationdemandqty_maxconst, | 
|                                                                  scalefactor_partialoperationdemandqty_minconst, | 
|                                                                  scalefactor_operationdemandqty_maxconst, | 
|                                                                  scalefactor_operationdemandqty_minconst, | 
|                                                                  scalefactor_rhs_maxconst, | 
|                                                                  scalefactor_rhs_minconst,  | 
|                                                                  maxfactor,  | 
|                                                                  minfactor ); | 
|         } | 
|                    | 
|       } | 
|       else | 
|       { | 
|         periods := this.GetPeriodsForOperation( scope, operation ); | 
|        | 
|         traverse( periods, Elements, period ) | 
|         { | 
|           this.InitConstraintsForOperationDependentDemandInputSet_Add( program,  | 
|                                                                        runcontext,  | 
|                                                                        scope,  | 
|                                                                        set,  | 
|                                                                        period, | 
|                                                                        null(  PeriodTaskOperation ),  | 
|                                                                        scalefactor_periodtaskqty_maxconst, | 
|                                                                        scalefactor_operationinputsetover_maxconst, | 
|                                                                        scalefactor_periodtaskqty_minconst, | 
|                                                                        scalefactor_operationinputsetunder_minconst, | 
|                                                                        scalefactor_partialoperationdemandqty_maxconst, | 
|                                                                        scalefactor_partialoperationdemandqty_minconst, | 
|                                                                        scalefactor_operationdemandqty_maxconst, | 
|                                                                        scalefactor_operationdemandqty_minconst, | 
|                                                                        scalefactor_rhs_maxconst, | 
|                                                                        scalefactor_rhs_minconst,  | 
|                                                                        maxfactor,  | 
|                                                                        minfactor ); | 
|         } | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |