yypsybs
2023-09-09 3cb5a54def670d97301f07170fcaad213bfc54f2
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
39
40
41
42
Quintiq file version 2.0
#parent: #root
Method InitConstraintsForPostponedSalesDemands (
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  const LibOpt_Scope scope
) const
{
  Description: 'The constraint of fulfillment postponed sales demands to adhere to the original sales demand fulfillment.'
  TextBody:
  [*
    // add postponement constraint for leaf sdips
    traverse( scope.GetLeafSalesDemandInPeriodInRunConst(), Elements, sdip, sdip.NeedsToBePlanned() and sdip.CanBePostponed() )
    {
      // Constraint: LinkedSalesDemand  
      // SalesDemandQty + Sum( DelayedSalesDemandQty )  <= Quantity ∀ LeafSalesDemandInPeriod
      sdip.InitConstraintsForPostponedSalesDemands( this, program, scope, 1 );
    }
    
    traverse( scope.GetAggregatedSalesDemandInPeriodInRunConst(), Elements, asdip, asdip.NeedsToBePlanned() and asdip.CanBePostponed() )
    {
      // Constraint: SumOfDisaggregatedSalesDemand
      // DisaggregatedSalesDemandQty + Sum( DelayedDisaggregatedSalesDemandQty ) + FulfilledQuantity <= Quantity ∀ AggregatedSalesDemandInPeriod
      asdip.InitConstraintsForPostponedSalesDemands( this, program, scope, 1 );
    }
    
    // Handle sales demand before the optimization horizon, including those before the planning horizon.
    traverse( scope.GetSDIPBeforeScopeInRunConst(), Elements.astype( LeafSalesDemandInPeriod ), lsdip )
    {
      // Constraint: LinkedSalesDemand  
      // SalesDemandQty + Sum( DelayedSalesDemandQty )  <= Quantity ∀ LeafSalesDemandInPeriod
      lsdip.InitConstraintsForPostponedSalesDemands( this, program, scope, lsdip.SDIPBeforeScopeInRun().OptMinPostponementPeriod() );
    }
    
    traverse( scope.GetSDIPBeforeScopeInRunConst(), Elements.astype( AggregatedSalesDemandInPeriod ), asdip )
    {
      // Constraint: SumOfDisaggregatedSalesDemand
      // DisaggregatedSalesDemandQty + Sum( DelayedDisaggregatedSalesDemandQty ) + FulfilledQuantity <= Quantity ∀ AggregatedSalesDemandInPeriod
      asdip.InitConstraintsForPostponedSalesDemands( this, program, scope, asdip.SDIPBeforeScopeInRun().OptMinPostponementPeriod() );
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}