lazhen
2025-01-07 b3987122cbbc46c5c59d3173f37fca3170b6dc5a
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Quintiq file version 2.0
#parent: #root
Method CreateComponentTreeForLevel (
  LibOpt_Run run,
  LibOpt_Component continuecomponent,
  Number focuslevel
) as LibOpt_Component
{
  TextBody:
  [*
    // get probabilities 
    probrandom := 0.001; 
    
    // construct components
    selectorPISPIP := SelectorMetaPISPIP::Create( run, 'SelectorPSIPIPLevel'+ [String]focuslevel, focuslevel);  
    selectorPISPIP_PP := SelectorMetaPISPIPPreProduction::Create( run, 'SelectorPSIPIPPreProdLevel'+ [String]focuslevel, focuslevel);  
    selectorTrip := SelectorMetaTrip::Create( run, 'SelectorTripLevel'+ [String]focuslevel, focuslevel);  
    selectorSPIP := SelectorMetaSPIP::Create( run, 'SelectorSPIPLevel' + [String] focuslevel, focuslevel ); 
    selectorPTO := SelectorMetaPeriodTaskOperation::Create( run, 'SelectorPTOLevel'+ [String]focuslevel, focuslevel);  
    selectorUP := SelectorMetaUnitPeriod::Create( run, 'SelectorUPLevel'+ [String]focuslevel, focuslevel);  
    selectorrandom := SelectorMetaRandomPISPIP::Create( run, 'SelectorRandomPSIPIPLevel'+ [String]focuslevel, focuslevel);  
    switchchooseproblemtypeavailable := this.SwitchProbability( run, 'ChooseProblemType' + [String]focuslevel );
    switchpispip_problem := this.SwitchProbability( run, 'ChoosePISPIPProblem' + [String] focuslevel ); 
    
    probswitchrandom_or_problem := this.SwitchProbability( run, 'probswitchchooserandom' + [String]focuslevel ); 
    
    probability_pispip := LinkProbabilityPISPIP::Create(); 
    probability_pispip_preprod := LinkProbabilityPISPIPPreProduction::Create(); 
    probability_trip := LinkProbabilityTrip::Create( focuslevel ); 
    probability_spip := LinkProbabilityStockingPointInPeriod::Create( focuslevel ); 
    probability_unitperiod := LinkProbabilityUnitPeriod::Create( focuslevel ); 
    probability_pto := LinkProbabilityPeriodTaskOperation::Create( focuslevel );
    probability_fallback := LinkProbabilityFallBackRandom::Create();   
    
    //>> 1st we select whether we will address a problem, or whether we do a random selection 
    startcomp := probswitchrandom_or_problem; 
    probswitchrandom_or_problem.Branch( 1 - probrandom, switchchooseproblemtypeavailable ); 
    probswitchrandom_or_problem.Branch( probrandom, selectorrandom ); 
    //<<
    
    weightbase := 1.0; 
    // >> in case of problem select an available selector. We select from a random available from. 
    switchchooseproblemtypeavailable.Branch( weightbase, switchpispip_problem, &probability_pispip ); // select pispip problem (see below)
    switchchooseproblemtypeavailable.Branch( weightbase, selectorTrip, &probability_trip ); 
    switchchooseproblemtypeavailable.Branch( weightbase, selectorPTO, &probability_pto ); 
    switchchooseproblemtypeavailable.Branch( weightbase, selectorUP, &probability_unitperiod ); 
    switchchooseproblemtypeavailable.Branch( weightbase, selectorSPIP, &probability_spip ); 
    switchchooseproblemtypeavailable.Branch( weightbase, selectorrandom, &probability_fallback ); // last one added will be default in case no others are available
    // add additional problem types here 
    // <<
    
    // >> pispip problem choice: regular or target pre production
    switchpispip_problem.Branch( OptimizerMeta::ProbilityPISPIPRegularProblem(), selectorPISPIP ); 
    switchpispip_problem.Branch( weightbase, selectorPISPIP_PP, &probability_pispip_preprod ); // uses probability 1-OptimizerMeta::ProbilityPISPIPRegularProblem() if available, 0 otherwise
    
    // link to continuation 
    selectorPISPIP.To( continuecomponent ); 
    selectorPISPIP_PP.To( continuecomponent ); 
    selectorTrip.To(  continuecomponent ); 
    selectorPTO.To(  continuecomponent ); 
    selectorUP.To(  continuecomponent ); 
    selectorSPIP.To( continuecomponent ); 
    selectorrandom.To( continuecomponent ); 
    
    // add additional problem types here 
    //<<
    
    return startcomp;
  *]
  InterfaceProperties { Accessibility: 'Module' }
}