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