hongji.li
2023-11-07 1a1ba3ad5ed9e4380185aa1ccad20204a0e5f115
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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' }
}