Quintiq file version 2.0 
 | 
#parent: #root 
 | 
MethodOverride Operation ( 
 | 
  LibOpt_Task task 
 | 
) as stream[JSON] 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    debuginfo(  'Pre processing' );  
 | 
    runcontext := RunContextForCapacityPlanning::GetRunContextCapacityPlanning( task.Run() );  
 | 
     
 | 
    this.ClearSalesDemandBelowThreshold( task );  
 | 
    this.CreateSupportData( task, runcontext ); // trips, product in trips, periodtaskoperation ( in case of meta ). combis in case of campaign optimization 
 | 
     
 | 
    if ( runcontext.IsMetaIteration() )  
 | 
    { 
 | 
      rcm := RunContextMeta::GetRunContextMeta( task.Run() );  
 | 
       
 | 
      mp := this.Optimization().astype( Optimization ).MacroPlan();  
 | 
      eis := mp.OptimizerMetaEIS();  
 | 
      eis.FocusLevelForEIS( -1 ); // triggers EIS in the 1st operation of meta selector, because levels start at 0 
 | 
      eis.BaseForTried( rcm.OptionBaseForTried() );  
 | 
      eis.BaseForTriedAsFriend( rcm.OptionBaseForTriedAsFried() );  
 | 
      eis.BaseForPeriodDecay( rcm.OptionStartBaseForPeriodDecay() ); // slowly move towards 1  
 | 
      eis.BaseForDecayNrTimeInScope( rcm.OptionBaseForDecayNrTimeInScope() );  
 | 
      OptimizerMeta::ResetIsTried( selectset( mp, PlanningPeriod, p, true, true ) );  
 | 
      Transaction::Transaction().Propagate(); // compute estimated improvements scores after above changes 
 | 
         
 | 
      opt := mp.Optimization();  
 | 
      gp := mp.GlobalParameters_MP();  
 | 
      opstart := runcontext.FirstPeriod_MP().StartDate();   
 | 
      optend := runcontext.LastPeriod_MP().EndDate();  
 | 
       
 | 
      if ( not isnull( opt.AlgorithmScaling() ) ) 
 | 
      { 
 | 
        opt.AlgorithmScaling().ScaleFactorsSuggestedForLevel( relflush ); 
 | 
      } 
 | 
         
 | 
      mp.Optimization().PruneProductInTrips( mp, task ); // remove product in trips meta optimizer detects as useless 
 | 
       
 | 
      changed := false;  
 | 
      gp.StartOfKPIHorizonForMetaRollback( gp.StartOfKPIHorizon() );  
 | 
      gp.EndOfKPIHorizonForMetaRollback( gp.EndOfKPIHorizon() );  
 | 
      if ( gp.GetStartOfKPIHorizon() > opstart )  
 | 
      { 
 | 
        gp.StartOfKPIHorizonForMetaRollback( opstart );  
 | 
        changed := true;  
 | 
      } 
 | 
      if ( gp.GetEndOfKPIHorizon() < optend )  
 | 
      { 
 | 
        gp.EndOfKPIHorizonForMetaRollback( optend );  
 | 
        changed := true;  
 | 
      } 
 | 
      if ( changed )  
 | 
      { 
 | 
        Transaction::Transaction().Propagate( attribute( Period_MP, IsWithinKPIHorizon ) ); 
 | 
      } 
 | 
       
 | 
      this.SetFeedBackQuantities( eis.MacroPlan(), runcontext, task.Scope() );  
 | 
      runcontext.SetPeriodTaskOperationUser( runcontext.HasOverwrittenManualPlanning(), task.Scope(), true );      // for meta optimizer we want to set it once 
 | 
      runcontext.SetProductInTripManualQuantity( runcontext.HasOverwrittenManualPlanning(), task.Scope(), true );  // and not each iteration based on scope 
 | 
    } 
 | 
    this.Optimization().astype( Optimization ).MacroPlan().SetServiceLevelBaseIDs(); 
 | 
    this.SetMaxPostponementPeriodForPISPs();  
 | 
     
 | 
    this.StoreInitialInventoryViolations( runcontext );  
 | 
     
 | 
    return this.Continue( task, task.Scope() ); 
 | 
  *] 
 | 
} 
 |