chenqinghong
2024-05-07 3ec06a830367465068963156dcc1d8e522571c13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Quintiq file version 2.0
#parent: #root
Method Execute (
  AlgorithmRun algorithmrun,
  Period_MPs periods,
  Units units,
  OptimizerPuzzle optimizerpuzzle
) as stream[JSON]
{
  TextBody:
  [*
    mp := this.Optimization().astype( Optimization ).MacroPlan(); 
    
    periodstart := minselect(  periods, Elements, p, true, p.Start() ); 
    periodend := maxselect(  periods, Elements, p, true, p.Start() ); 
    
    run := LibOpt_Run::Create( this ); 
    
    this.CreateRunWithContexts( algorithmrun, run, units, periodstart, periodend ); 
    
    outscope := LibOpt_Scope::Create( run ); 
    this.SubscribeRunToKPIs( 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 ); 
    
    rcm := select( run, RunContext.astype( RunContextMeta ), rc, true, true ); 
    
    // save used settings to active settings, so we save the last used when the user kicks off a run 
    this.ActiveSettings().astype( OptimizerMetaSettings ).SaveLastUsedSettings( rcm, optimizerpuzzle.Name(), mp.StrategyMacroPlan().Name(), periodstart.StartDate(), periodend.StartDate() ); 
    
    this.CreateComponents( run ); 
    strm := run.Start();
    strm->| this->MyFinalize();
    return strm;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}