chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
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
43
44
45
46
47
48
49
50
51
52
53
54
Quintiq file version 2.0
#parent: #root
Method CapacityPlanningAlgorithmHandleFeasibleDelayedSalesDemand (
  BaseSalesDemandInPeriod salesdemandinperiod,
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  const RunContextForCapacityPlanning runcontext,
  LibOpt_Scope scope,
  Number optminpostponementperiod
)
{
  Description: 'Method for obtaining the delayed sales demand variable from the optimizer'
  TextBody:
  [*
    pispip := salesdemandinperiod.AsPlanningBaseSalesDemandInPeriod();
    
    if( salesdemandinperiod.CanBePostponed() and salesdemandinperiod.NeedsToBePlanned() )
    {
      nextpispip := pispip.NextPlanningPISPIP();
      
      for( i := 2;
           i <= optminpostponementperiod
           and not isnull( nextpispip );
           i++
         )
      {
        nextpispip := nextpispip.NextPlanningPISPIP();
      }
      
      for( i := optminpostponementperiod;
           i <= salesdemandinperiod.MaxPostponementPeriod() // within the maximum number of postponement periods
           and not isnull( nextpispip );                     // the next pispip exists
           i++ )
      {
        if( scope.Contains( nextpispip.PISPIPInOptimizerRun() ) )
        {
          var := salesdemandinperiod.GetDelayedSalesDemandQtyVariable( program, nextpispip.Period_MP() );
          
          if( not isnull( var ) )
          {
            postponedqty := this.GetOptimalValue( var );
            
            if( postponedqty > 0.0 )
            {      
              postponedsd := salesdemandinperiod.Postpone( postponedqty, false, nextpispip.astype( ProductInStockingPointInPeriodPlanningLeaf ) ); 
              postponedsd.UpdateOptimizerFulfillment( true, postponedqty );
            }
          }
        }
        nextpispip := nextpispip.NextPlanningPISPIP();
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}