Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method Execute ( 
 | 
  AlgorithmRun algorithmrun, 
 | 
  Units units, 
 | 
  Period_MPs periods, 
 | 
  OptimizerPuzzle optimizerpuzzle 
 | 
) as stream[JSON] 
 | 
{ 
 | 
  TextBody: 
 | 
  [* 
 | 
    run := LibOpt_Run::Create( this ); 
 | 
     
 | 
    outscope := LibOpt_Scope::Create( run );  
 | 
    traverse( this.DefaultScope(), Elements, se, not se.istype( OptimizerPuzzleInOptimizerRun ) and not se.istype( PeriodInOptimizerRun ) )  
 | 
    { 
 | 
      outscope.Add( se );  
 | 
    } 
 | 
    traverse( periods, Elements, p )  
 | 
    { 
 | 
      outscope.Add( p );  
 | 
    } 
 | 
     
 | 
    outscope.Add( optimizerpuzzle );  
 | 
     
 | 
    run.SetStartScope( outscope );  
 | 
     
 | 
    periodstart := minselect(  periods, Elements, p, true, p.Start() );  
 | 
    periodend := maxselect(  periods, Elements, p, true, p.Start() );  
 | 
     
 | 
    context := RunContextForCapacityPlanning::Create( run, units, periodstart, periodend );  
 | 
    context.Initialize( algorithmrun );  
 | 
     
 | 
    this.CreateComponents( run );  
 | 
     
 | 
    // save used settings to active settings, so we save the last used when the user kicks off a run  
 | 
    mp := periodstart.MacroPlan();  
 | 
    this.ActiveSettings().astype( OptimizerFullRunSettings ).SaveLastUsedSettings( null( RunContextMeta ), optimizerpuzzle.Name(), mp.StrategyMacroPlan().Name(), periodstart.StartDate(), periodend.StartDate() );  
 | 
     
 | 
    return run.Start(); 
 | 
  *] 
 | 
  InterfaceProperties { Accessibility: 'Module' } 
 | 
} 
 |