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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Quintiq file version 2.0
#parent: #root
MethodOverride InitVariablesForPostponedSalesDemands (
  const CapacityPlanningSuboptimizer subopt,
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  const LibOpt_Scope scope,
  Number optminpostponementperiod,
  Boolean shelflifevaronly
) const
{
  TextBody:
  [*
    if( this.AggregatedSalesDemandInPeriod().CanBePostponed() and this.AggregatedSalesDemandInPeriod().NeedsToBePlanned() )    
    {
      pispip := this.AsPlanningBaseSalesDemandInPeriod();
      nextpispip := pispip.NextPlanningPISPIP();
      
      for( i := 2;
           i <= optminpostponementperiod
           and not isnull( nextpispip );
           i++
         )
      {
        nextpispip := nextpispip.NextPlanningPISPIP();
      }
      
      for( i := optminpostponementperiod;
           i <= this.MaxPostponementPeriod()                                           // within the maximum number of postponement periods
           and not isnull( nextpispip );
           i++ )
      {
        if( scope.Contains( nextpispip.PISPIPInOptimizerRun() ) )
        {
          nextperiod := nextpispip.Period_MP(); 
          // DelayedDisaggregatedSalesDemandQty variable UoM: PISP
          // look if variable is already defined, because we also init variable for the extra shelf life pispips prior to horizon
          var := ifexpr( shelflifevaronly, program.DelayedDisaggregatedSalesDemandQtyVariables().Find( this, nextperiod ), null(  MPVariable ) ); 
          if ( isnull( var ) )
          {
            var := program.DelayedDisaggregatedSalesDemandQtyVariables().New( this, nextperiod ); 
            upperbound := maxvalue( 0.0, this.AggregatedSalesDemandInPeriod().GetQuantityForOptimizer( scope ) ); 
            subopt.FreezeVariableUpperBound( var, upperbound );
          }
          
          if ( nextpispip.ProductInStockingPoint_MP().IsOptShelfLife() ) 
          {
            traverse( nextpispip, ProductInStockingPoint_MP.IncomingShelfLifeDay, islday ) 
            {
              // look if variable is already defined, because we also init variable for the extra shelf life pispips prior to horizon
              dvar := program.DelayedDisaggregatedSalesDemandShelfLifeQtyVariables().Find( this, nextperiod, islday ); 
              if ( isnull( dvar ) ) 
              {
                program.DelayedDisaggregatedSalesDemandShelfLifeQtyVariables().New( this, nextperiod, islday ); 
              }
            }
          }
        }
        nextpispip := nextpispip.NextPlanningPISPIP();
      }
    }
  *]
}