admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
Method InitializeStartOfLevel (
  LibOpt_Task task
)
{
  TextBody:
  [*
    eis := task.Run().Optimization().astype( Optimization ).MacroPlan().OptimizerMetaEIS(); 
    if ( not this.FocusLevel() = eis.FocusLevelForEIS() ) // optimizer pre-processor inits macroplan.FocusLevelForEIS at -1, so we always trigger this the 1st operation, 1st level. 
    {
      debuginfo( 'Triggering EIS computation for focus level', this.FocusLevel(), ' old EIS focus = ', eis.FocusLevelForEIS() ); 
      weightlevels := RunContextForCapacityPlanning::GetRunContextCapacityPlanning( task.Run() ).WeightLevelNonFinancial(); 
      eis.SetWeightLevelsForEIS( weightlevels ); // we could do this only for the first level, but more robustly coded to set it at the start of any level
      eis.FocusLevelForEIS( this.FocusLevel() ); 
    
      Transaction::Transaction().Propagate( attribute( ProductInStockingPointInPeriodPlanning, EstimatedImprovementScore ) ); 
      Transaction::Transaction().Propagate( attribute( Trip, EstimatedImprovementScore ) ); 
      Transaction::Transaction().Propagate( attribute( PeriodTaskOperation, EstimatedImprovementScore ) ); 
      Transaction::Transaction().Propagate( attribute( UnitPeriod, EstimatedImprovementScore ) ); 
        
      opt := task.Run().Optimization().astype( Optimization ); 
      mp := opt.MacroPlan(); 
      strategymacroplan := mp.StrategyMacroPlan(); 
      slm := select(  strategymacroplan, 
                      StrategyLevelMacroPlan, 
                      level, 
                      true, 
                      level.Level() = this.FocusLevel() and level.MetaLastAutoScalingRun().IsFinite() );  // if not set then give null object, and fallback to non level specific factors
      debuginfo(  'Calling to update goal scaling. Current focus  = ', this.FocusLevel() ); 
      opt.UpdateGoalScaling( strategymacroplan, slm ); 
      debuginfo(  'Found level specific scaling factors = ', not isnull( slm ) ); 
      traverse( opt, AlgorithmScaling.ScaleFactor, sf ) 
      {
        debuginfo( 'Using scaling factor ', Optimization::ScaleTypeName( sf.Type() ), 'value = ', sf.Value() );  
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}