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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Quintiq file version 2.0
#parent: #root
Method ReRunOptimizerWithShrinkingHorizon (
  Boolean issmartplan,
  ProductInStockingPointInPeriodPlannings smartplanpispips,
  Boolean overridemanualplanning,
  Period_MP periodstart,
  Period_MP periodend,
  Boolean isUsingSelectedUnit,
  Units units,
  Process_MP process
)
{
  Description: 'Method used to call the optimizer with a shrinking horizon approach'
  TextBody:
  [*
    // method to rerun optimizer with changed period
    
    run := this.GetLastAlgorithmRun(); 
    firstperiod := this.StartOfPlanningPeriod();
    lastperiod := this.LastPlanningPeriod();
    
    // If this is not a frozen run, then generate the sales demand and select the next periods in the window
    if( not run.IsFrozenRun() )
    {
      // Move the horizon forward one period
      firstperiod := periodstart.NextPlanningPeriod();
      lastperiod :=  periodend.NextPlanningPeriod();
      
      // If there is no next period, we cannot move to the next period
      if( isnull( firstperiod ) )
      {
        firstperiod := periodstart;
      }
      if( isnull( lastperiod ) )
      {
        lastperiod := periodend;
      }
      
      // Generate sales demand realizations if this is an inventory optimization run
      if( run.IsInventoryOptimizationRun() )
      {
        firstperiod.GenerateSalesDemandRealizations();
      }
    }
    
    // reset all relations to algorithm run:
    /* not stored on run anymore Potentially making (legacy) inventory optimization broken. Note scope is rebuilt in lib opt approach in which case the following is not needed.  
    run.OperationInOptimizerRun( relflush ); 
    run.PeriodInOptimizerRun( relflush );
    run.PISPInOptimizerRun( relflush );
    run.PISPIPInOptimizerRun( relflush );
    run.ProductInTripInOptimizerRun( relflush );
    run.PTOperationInOptimizerRun( relflush );
    run.SPIPInOptimizerRun( relflush );
    run.TripInOptimizerRun( relflush);
    run.UnitInOptimizerRun( relflush );
    run.UnitPeriodInOptimizerRun( relflush );
    run.LeafSalesDemandInPeriod( relflush );
    */
    this.RunCapacityPlanningAlgorithm( run, 
                                       smartplanpispips,
                                       firstperiod,
                                       lastperiod,
                                       units, 
                                       process,
                                       this.LastUsedOptimizerPuzzle()  );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}