| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitConstraintsForOperationDependentDemandInputSet_Add ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   const RunContextForCapacityPlanning runcontext, | 
|   const LibOpt_Scope scope, | 
|   const OperationInputSet set, | 
|   const Period_MP period, | 
|   const PeriodTaskOperation pto, | 
|   Real scalefactor_periodtaskqty_maxconst, | 
|   Real scalefactor_operationinputsetover_maxconst, | 
|   Real scalefactor_periodtaskqty_minconst, | 
|   Real scalefactor_operationinputsetunder_minconst, | 
|   Real scalefactor_partialoperationdemandqty_maxconst, | 
|   Real scalefactor_partialoperationdemandqty_minconst, | 
|   Real scalefactor_operationdemandqty_maxconst, | 
|   Real scalefactor_operationdemandqty_minconst, | 
|   Real scalefactor_rhs_maxconst, | 
|   Real scalefactor_rhs_minconst, | 
|   Real maxfactor, | 
|   Real minfactor | 
| ) const | 
| { | 
|   Description: 'Initialize constraints for dependent demands which is part of an input group and belongs to an input set.' | 
|   TextBody: | 
|   [* | 
|     operation := set.Operation(); | 
|      | 
|     // maxconst Constraint UoM: Input Set | 
|     maxconst := program.OperationInputSetUpperBoundConstraints().New( set, period ); | 
|     maxconst.Sense( "<=" ); | 
|     maxconst.RHSValue( 0.0 * scalefactor_rhs_maxconst ); | 
|     // Term: - maxfactor       * PTQty variable | 
|     // UoM: [Input Set/ Unit]  *    [Unit] | 
|     maxconst.NewTerm( -maxfactor * scalefactor_periodtaskqty_maxconst, program.PTQtyVariables().Get( operation, period ) ); | 
|     // Term UoM: Input Set | 
|     maxconst.NewTerm( -1.0 * scalefactor_operationinputsetover_maxconst, | 
|                       program.OperationInputSetOverVariables().Get( set, period ) ); | 
|      | 
|     //minconst Constraint UoM: Input Set | 
|     minconst := program.OperationInputSetLowerBoundConstraints().New( set, period ); | 
|     minconst.Sense( ">=" ); | 
|     minconst.RHSValue( 0.0 * scalefactor_rhs_minconst ); | 
|     // Term: - minfactor       * PTQty variable | 
|     // UoM: [Input Set/ Unit]  *    [Unit] | 
|     minconst.NewTerm( -minfactor * scalefactor_periodtaskqty_minconst, program.PTQtyVariables().Get( operation, period ) ); | 
|     // Term UoM: Input Set | 
|     minconst.NewTerm( scalefactor_operationinputsetunder_minconst, program.OperationInputSetUnderVariables().Get( set, period ) ); | 
|      | 
|     // Only select the input where the product is included. | 
|     traverse( set, OperationInput, oi, oi.HasRegularProductforOptimizer() or oi.GetIsProductInOptimizerRun( runcontext.IsPostProcessing() ) ) | 
|     { | 
|       uomconversion := oi.OperationInputSetConversionFactor(); | 
|      | 
|       if( operation.HasLeadTime() ) | 
|       { | 
|          | 
|         pispipperiods := construct( Period_MPs, constcontent ); | 
|         if ( this.GetPeriodsFromPeriodTaskOperation() )  | 
|         { | 
|           traverse( pto, DependentDemand.ProductInStockingPointInPeriodPlanningLeaf.Period_MP, ddperiod )  | 
|           { | 
|             pispipperiods.Add( ddperiod );  | 
|           } | 
|           pispipperiods := pispipperiods.Unique();  | 
|         } | 
|         else | 
|         { | 
|           CapacityPlanningSuboptimizer::GetOperationDependentDemandPeriods( period, operation, &pispipperiods, this.GetPeriodsFromPeriodTaskOperation() ); | 
|         } | 
|      | 
|         traverse( pispipperiods, Elements, pispipperiod ) | 
|         { | 
|           // Term:   uomconversion        * PartialOperationDemandQty variable | 
|           // UoM: [Input PISP to Input Set] *        [Input PISP] | 
|           varpodqty := program.PartialOperationDemandQtyVariables().Get( oi, pispipperiod, period );  | 
|           maxconst.NewTerm( uomconversion * scalefactor_partialoperationdemandqty_maxconst, varpodqty ); | 
|           minconst.NewTerm( uomconversion * scalefactor_partialoperationdemandqty_minconst, varpodqty ); | 
|         } | 
|       } | 
|       else | 
|       { | 
|         // Term:   uomconversion        * OperationDemandQty variable | 
|         // UoM: [Input PISP to Input Set] *        [Input PISP] | 
|         maxconst.NewTerm( uomconversion * scalefactor_operationdemandqty_maxconst, program.OperationDemandQtyVariables().Get( oi, period ) ); | 
|         minconst.NewTerm( uomconversion * scalefactor_operationdemandqty_minconst, program.OperationDemandQtyVariables().Get( oi, period ) ); | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |