| Quintiq file version 2.0 | 
| #parent: #root | 
| Method AddTermsToInventorySpecificationHighLevelConstraint ( | 
|   CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, | 
|   MPConstraint constr, | 
|   const ProductInStockingPointInPeriod pispip, | 
|   const LibOpt_Scope scope, | 
|   Real scalefactor_invqty_constr, | 
|   Real scalefactor_rhs_constr | 
| ) const | 
| { | 
|   TextBody: | 
|   [* | 
|     // sum of inventory quantity of active pispip | 
|     traverse( pispip.GetLeavesOfProductDimensionConst(), Elements.astype( ProductInStockingPointInPeriodPlanning ), activepispip, | 
|               not activepispip.ProductInStockingPoint_MP().IsNegativeInventoryAllowed() ) | 
|     { | 
|       targetuom := pispip.ProductInStockingPoint_MP().UnitOfMeasure_MP(); | 
|       uomconversionfactor := activepispip.ProductInStockingPoint_MP().GetUOMConversionFactor( targetuom ); | 
|       // if the activepispip is part of the optimizer run, add the invqty variable, otherwise update the RHS | 
|       if( scope.Contains( activepispip.PISPIPInOptimizerRun() ) )  | 
|       { | 
|         // Term:       uomconversion        *  InvQty | 
|         // UoM:  [leaf PISP to Target PISP] * [leaf PISP] | 
|         constr.NewTerm( uomconversionfactor * scalefactor_invqty_constr, program.InvQtyVariables().Get( activepispip ) ); | 
|       } | 
|       else | 
|       { | 
|         // RHS: current RHS   -        uomconversion       * inventory level end  | 
|         // UoM: [Target PISP] - [Leaf PISP to Target PISP] *     [Leaf PISP] | 
|         newrhs := this.GetConstraintRHS( constr, scalefactor_rhs_constr ) - uomconversionfactor * activepispip.InventoryLevelEnd(); | 
|         constr.RHSValue( newrhs * scalefactor_rhs_constr ); | 
|       } | 
|     } | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |