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' } 
 | 
} 
 |