Quintiq file version 2.0 
 | 
#parent: #root 
 | 
MethodOverride InitializeReactive ( 
 | 
  const LibOpt_Task task, 
 | 
  MathematicalProgram program 
 | 
) const as stream[Object] 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    debuginfo( 'Asynchronous start = ', DateTime::ActualTime() );  
 | 
    start_init_reactive := OS::PrecisionCounter();  
 | 
    scope := task.Scope();  
 | 
    runcontext := this.GetRunContextConst();   
 | 
    pispipssmartplan := scope.GetSmartPlanPISPIPsInOptimizerRunConst();  
 | 
     
 | 
    userperiodtasks := runcontext.GetUserPeriodTaskOperationsConst();  
 | 
    userproductintrips :=runcontext.GetUserProductInTrips();  
 | 
     
 | 
    start_init_varsgoals := OS::PrecisionCounter();  
 | 
     
 | 
    programcast := program.astype( CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm );  
 | 
     
 | 
    pispipsinrun := scope.GetPISPIPInOptimizerRunConst();  
 | 
    pispsinrun := scope.GetProductInStockingPointInOptimizerRunConst();  
 | 
    leafpispipsinrun := selectset(  pispipsinrun, Elements.astype( ProductInStockingPointInPeriodPlanningLeaf ), pispip, true, true );  
 | 
    pitinrun := scope.GetProductInTripInOptimizerRunConst();  
 | 
     
 | 
    programcast.StoreReal( 'start_init_reactive', start_init_reactive );  
 | 
    this.CapacityPlanningAlgorithmInitInstance( programcast, runcontext, scope );   
 | 
     
 | 
    // initialize variables  
 | 
    start_init_varsgoals := OS::PrecisionCounter();  
 | 
     
 | 
    this.CapacityPlanningAlgorithmInitVariables( programcast, runcontext, userperiodtasks, userproductintrips, pispipssmartplan, scope, pispipsinrun, leafpispipsinrun, pispsinrun, pitinrun );  
 | 
     
 | 
    this.SetStartSolutionForPTLotSizes( programcast, runcontext, scope );  
 | 
     
 | 
    this.SetStartSolutionForCampaignSequencing( programcast, runcontext, scope );  
 | 
     
 | 
    if ( this.UseHierarchicalCPLEXGoals() )  
 | 
    { 
 | 
      this.CapacityPlanningAlgorithmInitGoals( programcast, runcontext, scope  );// workaround we should add the goal after cloning because otherwise the goal term constant become = nr of threads.  
 | 
                                                                             // but for hierarchical goals this currently produces a core bug 
 | 
    } 
 | 
     
 | 
    end_init_varsgoals := OS::PrecisionCounter();  
 | 
    duration_unit_vargoals := ((end_init_varsgoals - start_init_varsgoals) / OS::PrecisionCounterFrequency());  
 | 
    programcast.StoreReal( 'duration_init_vargoals', duration_unit_vargoals );  
 | 
     
 | 
    startclone := OS::PrecisionCounter();  
 | 
    clone1 := program.Clone().astype( CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm );  
 | 
    clone2 := program.Clone().astype( CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm );  
 | 
    endclone := OS::PrecisionCounter();  
 | 
    durationclone := (endclone - startclone )/ OS::PrecisionCounterFrequency();  
 | 
     
 | 
    msgclone := '#time to clone (ms) =' + [String] durationclone +  
 | 
                '#vars clone1=' + [String] clone1.Variables( relsize ); 
 | 
    programcast.StoreString(  'timetoclone_msg', msgclone );  
 | 
     
 | 
    if ( not this.UseHierarchicalCPLEXGoals() )  
 | 
    { 
 | 
      this.CapacityPlanningAlgorithmInitGoals( programcast, runcontext, scope  );// workaround we should add the goal after cloning because otherwise the goal term constant become = nr of threads.  
 | 
    } 
 | 
     
 | 
    stream1 := this->CapacityPlanningAlgorithmInitConstraints_ParallelTypeA( programcast, pispipssmartplan, userperiodtasks, task, pispipsinrun, leafpispipsinrun, pispsinrun, pitinrun );  
 | 
    stream2 := this->CapacityPlanningAlgorithmInitConstraints_ParallelTypeB( clone1, pispipssmartplan, task, pispipsinrun, leafpispipsinrun, pispsinrun, pitinrun );  
 | 
    stream3 := this->CapacityPlanningAlgorithmInitConstraints_ParallelTypeC( clone2, pispipssmartplan, task, pispipsinrun, leafpispipsinrun, pispsinrun, pitinrun );  
 | 
     
 | 
    // note we run this.FilterCPLEXNoiseInitialization( program, runcontext ) in above parallel threads (filters RHS of constraints) 
 | 
    // meaning this filtering is excluded from any constraints added below.  
 | 
     
 | 
    return stream1->Merge( stream2, stream3 ) 
 | 
           ->| programcast->CapacityPlanningSuboptimizer::InitReactiveFinalize( clone1, clone2, runcontext, scope, this, leafpispipsinrun ) 
 | 
           ->| emit( this ) 
 | 
  *] 
 | 
} 
 |