yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
38
Quintiq file version 2.0
#parent: #root
MethodOverride InitConstraintsForPostponedSalesDemands (
  const CapacityPlanningSuboptimizer subopt,
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  const LibOpt_Scope scope,
  Number optminpostponementperiod
) const
{
  TextBody:
  [*
    // const constraint UoM: PISP
    const := program.LinkedSalesDemandConstraints().New( this );
    const.Sense( '<=' );
    
    rhs := this.GetQuantityForOptimizer( scope );
    issdipbeforescope := scope.Contains( this.SDIPBeforeScopeInRun() );
    
    // Check if the SDIP is within the optimizer horizon. The SalesDemandQty variable is only created if the SDIP is within the optimizer horizon
    // If the SDIP is within the optimizer horizon, then add the SalesDemandQty variable, otherwise subtract the fulfilled quantity.
    if( not issdipbeforescope )
    {
      // Term UoM: PISP
      scalefactor_SDQty_constr := subopt.ScaleConstraintTerm( typeof( MPSalesDemandQtyVariable ), typeofexpression( const ) );
      const.NewTerm( 1.0 * scalefactor_SDQty_constr, program.SalesDemandQtyVariables().Get( this ) );
    }
    else
    {
      // Adjust RHS value if this LeafSDIP is not in the run.
      rhs := maxvalue( rhs - this.FulfilledQuantity(), 0.0 );
    }
    
    // RHS UoM: PISP
    const.RHSValue( subopt.ScaleConstraintRHS( typeofexpression( const ), rhs ) );
    
    this.AddTermsForDelayedSalesDemandsForward( program, const, 1.0, scope, subopt, optminpostponementperiod );
  *]
}