| Quintiq file version 2.0 | 
| #parent: #root | 
| Method InitConstraintsForCapacityUsage ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   MPConstraint minconst, | 
|   MPConstraint maxconst, | 
|   const RunContextForCapacityPlanning runcontext, | 
|   const LibOpt_Scope scope, | 
|   const CapacityPlanningSuboptimizer subopt | 
| ) const | 
| { | 
|   Description: 'The constraint to calculate the production of period tasks' | 
|   TextBody: | 
|   [* | 
|     // minconst and maxconst UoM: Unit | 
|      | 
|     bound := 0.0;  // To prevent infeasible when the unit is closed | 
|      | 
|     // periodtaskqtyvarname := AlgorithmNameVariable::PTQty();  | 
|     scalefactor_periodtaskqty_maxconst := subopt.ScaleConstraintTerm( typeof( MPPTQtyVariable ), typeofexpression( maxconst ) ); | 
|     scalefactor_periodtaskqty_minconst := subopt.ScaleConstraintTerm( typeof( MPPTQtyVariable ), typeofexpression( minconst ) ); | 
|     scalefactor_tripnewsupply_maxconst := subopt.ScaleConstraintTerm( typeof( MPTripNewSupplyVariable ), typeofexpression( maxconst ) ); | 
|     scalefactor_tripnewsupply_minconst := subopt.ScaleConstraintTerm( typeof( MPTripNewSupplyVariable ), typeofexpression( minconst ) ); | 
|      | 
|     scalefactor_rhs_minconst := subopt.ScaleConstraintRHS( typeofexpression( minconst ), 1.0 ); | 
|     scalefactor_rhs_maxconst := subopt.ScaleConstraintRHS( typeofexpression( maxconst ), 1.0 ); | 
|      | 
|     this.AddTermsForCapacityUsage( program, | 
|                                    minconst, | 
|                                    maxconst, | 
|                                    scope, | 
|                                    subopt, | 
|                                    this, | 
|                                    scalefactor_periodtaskqty_minconst, | 
|                                    scalefactor_periodtaskqty_maxconst, | 
|                                    scalefactor_tripnewsupply_minconst, | 
|                                    scalefactor_tripnewsupply_maxconst, | 
|                                    bound ); | 
|      | 
|     varoverload := this.GetCapacityOverloadedVariable( program ); | 
|      | 
|     // Term: UnitCapacityOverloaded variable | 
|     // UoM:         [Unit] | 
|     maxconst.NewTerm( -1.0 * subopt.ScaleConstraintTerm( typeof( MPUnitCapacityOverloadedQuantityVariable ), typeofexpression( maxconst ) ), varoverload ); | 
|      | 
|     if( this.NrOfOpen() <= 0 )    // If the unit is closed, it should not be allowed to plan anything, and the overloaded capacity is served as the slack to prevent infeasible | 
|     { | 
|       subopt.FreezeVariableUpperBound( varoverload , bound ); | 
|     } | 
|      | 
|     this.UpdateRHSForPeriodTasksNotInScope( minconst, maxconst, runcontext, scope, subopt, scalefactor_rhs_minconst, scalefactor_rhs_maxconst ); | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |