| 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' } | 
| } |