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
55
Quintiq file version 2.0
#parent: #root
Method CreateSupportData (
  LibOpt_Task task,
  RunContextForCapacityPlanning runcontext
)
{
  TextBody:
  [*
    starttime := OS::PrecisionCounter(); 
    optimization := this.Optimization().astype( Optimization ); 
    macroplan := optimization.MacroPlan(); 
    
    macroplan.IsOptimizerRunning( true ); // will generate propagation for estimated improvement scores
    
    optimization.StorePreviousPlanningSpecificationValuesForShelfLife(); 
    
    optimization.SetOptimizerPuzzle( task.Scope().GetOptimizerPuzzleInOptimizerRun(), optimization.GetOptimizerPeriods( runcontext.FirstPeriod_MP(), runcontext.LastPeriod_MP() ) ); 
    
    lanelegs_foroptimization := selectset( macroplan.GetUnits(), Elements.AllChildren.AsChildren.LaneLegForOptimization, laneleg, true );
    
    // Clean forbidden disaggregated sdips
    macroplan.SynchronizeDisaggregatedSalesDemandInPeriod( true ); 
    
    if ( runcontext.UseCampaignSequenceOptimizer() ) 
    {
      optimization.GenerateCampaignCombis(); 
    }
    
    this.MetaOptimizerCreateSupportDataShiftOptimizer( macroplan, task.Scope().GetOptimizerPuzzleInOptimizerRun(), runcontext ); 
    
    // Select the instances for optimization
    if ( not runcontext.IsSmartPlan() ) // for smart plan we do not need to create objects ( these are created on the fly searching upstream/downstream, also adding period for shelf life)
    {
      periods := selectset( macroplan, Period_MP, period, true, period.IsInOptimizerPuzzle() ); 
      
      updatedtrips := construct( Trips );
      // Create all possible combi of trips as optimizer input
      optimization.CreateTrips( lanelegs_foroptimization, periods, updatedtrips );
      
      if ( runcontext.IsMetaIteration() ) 
      {
        optimization.CreatePeriodTaskOperations( periods ); 
      }
      optimization.ShelfLifeExtendHistoricalPeriods( false, null(  ProductInStockingPoint_MPs, owning ) ); // temporarily add period to accomodate shelf life if needed
    }
    
    Transaction::Transaction().Propagate(); // need relations for created data. Need it in same transaction because of pit pruning
      
    endtime := OS::PrecisionCounter(); 
    durationsec := ( endtime - starttime ) / OS::PrecisionCounterFrequency(); 
    debuginfo( 'Time for creating support data ( incl. propagation):', durationsec, 'sec' );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}