Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method DelayedInitialization ( 
 | 
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program, 
 | 
  LibOpt_Task task, 
 | 
  const RunContextForCapacityPlanning runcontext, 
 | 
  Boolean isfeasible 
 | 
) 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    if ( isfeasible ) // we omit not needed processing in the handle infeasible for performance 
 | 
    { 
 | 
      this.RestoreSetCPLEXBoundFlags( program, runcontext ); // need flags on objects (for const-ness written to program) 
 | 
      this.StorePITVarProperties( program, task.Scope() ); 
 | 
      this.StoreSalesVarProperties( program, task.Scope() ); 
 | 
       
 | 
      this.ResetManualQuanties(  this.GetRunContext(), task.Scope() ); // resetting manual plan if user has selected override manual quantities 
 | 
    } 
 | 
     
 | 
    // logged values for snapshots  
 | 
    this.LoggedNrPTQtyCampaignSlackVar( [Number] guard( program.RetrieveReal( CapacityPlanningSuboptimizer::LoggedNrPTQtyCampaignSlackVarName() ), 0 ) );  
 | 
     
 | 
    this.MacroPlan().GetLastAlgorithmRun().NumberOfThreads( program.Threads() ); // record what is used 
 | 
     
 | 
    // workaround. Was stored on program because init needs to be const 
 | 
    nextlevel := this.CurrentSubOptimizerLevel().LevelNumber();  
 | 
    algorithmrunlevel := this.MacroPlan().GetLastAlgorithmRun().GetAlgorithmRunLevel( nextlevel );  
 | 
    if ( not isnull( algorithmrunlevel ) )  
 | 
    { 
 | 
      actualtime := DateTime::ConstructMinutes( this.BaseForActualTime(), program.RetrieveReal( 'ActivateGoals_actualtime' ) );  
 | 
      algorithmrunlevel.Update( actualtime, algorithmrunlevel.End(), false, 0.0, 0.0, 0.0, program.Optimal() ); 
 | 
    } 
 | 
    if ( this.IsAutoScalingEnabled() ) // need to do init in the handle feasible or handle infeasible because init is const. We do it at the very first return to a handle method 
 | 
    { 
 | 
      this.InitForScaling( program );  
 | 
    } 
 | 
     
 | 
    if ( not this.InOneTransaction() )  
 | 
    { 
 | 
      task.Log( 'Duration init var+goal = ' + [String] program.RetrieveReal( 'duration_init_vargoals' ) );  
 | 
      start_init_reactive := program.RetrieveReal( 'start_init_reactive' );  
 | 
      end_init_reactive := program.RetrieveReal( 'end_init_reactive' );  
 | 
      duration_init_reactive := (end_init_reactive - start_init_reactive )/OS::PrecisionCounterFrequency();  
 | 
       
 | 
      timetoclonemsg := program.RetrieveString(  'timetoclone_msg' ); 
 | 
      task.Log( timetoclonemsg );  
 | 
      timeforA := program.RetrieveReal( 'type_A_constraints' );  
 | 
      timeforB := program.RetrieveReal( 'type_B_constraints' );  
 | 
      timeforC := program.RetrieveReal( 'type_C_constraints' );  
 | 
      this.InitTimeThreadA( timeforA ); // written to snapshot later 
 | 
      this.InitTimeThreadB( timeforB );  
 | 
      this.InitTimeThreadC( timeforC );  
 | 
       
 | 
      cumultimeA := timeforA;  
 | 
      cumultimeB := timeforB;  
 | 
      cumultimeC := timeforC;  
 | 
      snapshot := task.Run().LastSnapshot();  
 | 
      collected := 0;  
 | 
      snapshots := construct(  SnapshotMacroPlannerOptimizers );  
 | 
      while ( not isnull( snapshot ) and collected < 5 )  
 | 
      { 
 | 
        if ( snapshot.istype( SnapshotMacroPlannerOptimizer ) )  
 | 
        { 
 | 
          snapshots.Add( snapshot.astype( SnapshotMacroPlannerOptimizer ) );  
 | 
          collected++;  
 | 
        }   
 | 
        snapshot := snapshot.PreviousOnRun();  
 | 
      } 
 | 
     
 | 
      cumultimeA := cumultimeA + sum ( snapshots, Elements, s, true, s.InitTimeThreadA() );  
 | 
      cumultimeB := cumultimeB + sum ( snapshots, Elements, s, true, s.InitTimeThreadB() );  
 | 
      cumultimeC := cumultimeC + sum ( snapshots, Elements, s, true, s.InitTimeThreadC() );  
 | 
      
 | 
      task.Log( 'Duration type A init constraints = ' + [String] timeforA + ' = cumul -> ' + [String] cumultimeA );  
 | 
      task.Log( 'Duration type B init constraints = ' + [String] timeforB + ' = cumul -> ' + [String] cumultimeB );  
 | 
      task.Log( 'Duration type C init constraints = ' + [String] timeforC + ' = cumul -> ' + [String] cumultimeC );  
 | 
      task.Log( program.RetrieveString( 'MergeDuration' ) );  
 | 
      task.Log( 'Duration init reactive = ' + [String] duration_init_reactive );  
 | 
      this.AdjustWorkLoad( task, cumultimeA, cumultimeB, cumultimeC );  
 | 
      msg := 'Adjusting thread parameters to'  
 | 
              + [String] this.ThreadAParameter()  
 | 
              + ', '  
 | 
              + [String] this.ThreadBParameter()  
 | 
              + 'ratios:'  
 | 
              + [String] (this.ThreadAParameter() / 1000)  
 | 
              + ', '  
 | 
              + [String] ((this.ThreadBParameter() - this.ThreadAParameter()) / 1000 ) 
 | 
              + ', ' 
 | 
              + [String] ((1000 - this.ThreadBParameter()) / 1000);  
 | 
      task.Log( msg );  
 | 
     
 | 
    } 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |