yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
Quintiq file version 2.0
#parent: #root
MethodOverride Capture (
  LibOpt_Task task,
  String comment
)
{
  TextBody:
  [*
    if ( isnull( task )  ) 
    {
      this.CaptureForOTS( task ); 
    }
    else
    {
      suboptimizer := guard( task.Component().astype( CapacityPlanningSuboptimizer ), null( CapacityPlanningSuboptimizer ) );
      
      if ( isnull( suboptimizer ) ) 
      {
        r := this.Run(); 
        suboptimizer := maxselect( r, Component.astype( CapacityPlanningSuboptimizer ), opt, true, opt.FocusLevel() ); 
      }
      
      macroplan := this.Run().Optimization().astype( Optimization ).MacroPlan(); 
      runcontext := suboptimizer.GetRunContext(); 
      runcontextmeta := suboptimizer.GetRunContextMeta(); 
        
      if( not isnull( suboptimizer.RollbackKPI() ) )
      {
        financialscore := RealVector::Construct(); 
        financialposscore := RealVector::Construct(); 
        financial_descr := ''; 
        rollbackkpi := suboptimizer.RollbackKPI().astype(  RollbackKPIMeta ).GetKPI( task, financialscore, financialposscore, financial_descr ); 
        
        this.RollbackKPI( rollbackkpi.AsBinaryValue() );
        this.RollBackKPIFinancialTerms( financialscore.AsBinaryValue() ); 
        this.RollBackKPIFinancialTermsPositive( financialposscore.AsBinaryValue() ); 
        this.RollBackKPIFinancialDescription( financial_descr ); 
      }
      // some custome snapshot info 
      
      if ( not isnull( runcontextmeta ) ) // not every run is meta
      {
        this.Capture( runcontextmeta ); 
        pits := sum( macroplan, Unit.Lane.LaneLeg.Trip, trip, trip.GetIsValidNonFrozenTrip(), trip.ProductInTrip( relsize ) ); 
        pto := sum(  macroplan, Unit.Operation, op, true, op.PeriodTaskOperation( relsize ) ); 
        this.NrProductInTripGlobal( pits ); 
        this.NrOperationPeriodTaskInGlobal( pto ); 
        nrcombis := counter(  macroplan, Optimization.CampaignCombiGeneration.OptCampaign.OptCampaignUnit.OptCampaignUnitSubPeriod.OptCampaignCombiActive, c, true, true ); 
        nrcombisall := sum(   macroplan, Optimization.CampaignCombiGeneration.OptCampaign.OptCampaignUnit.OptCampaignUnitSubPeriod, ocusp, true, ocusp.OptCampaignCombi( relsize ) ); 
        nrcombisselected := counter(  macroplan, Optimization.CampaignCombiGeneration.OptCampaign.OptCampaignUnit.OptCampaignUnitSubPeriod.OptCampaignCombiSelected, c, true, true ); 
        this.NrCampaignSequenceCombisActive( nrcombis ); 
        this.NrCampaignSequenceCombisSelected( nrcombisselected ); 
        this.NrCampaignSequenceCombisTotal( nrcombisall ); 
      }
      
      this.Capture (suboptimizer ); 
      
      if ( isnull( suboptimizer.CurrentSubOptimizerLevel() )                  // when we are done the sub optimizer level will point to null
           or this.Run().Optimization().astype( Optimization ).DebugMode()  
           or not runcontext.IsMetaIteration() )
      {
        this.CaptureMacroPlanKPIs( runcontext, suboptimizer, task.Scope() ); 
      }
      
      if ( not isnull( runcontext ) ) 
      {
        this.Capture ( runcontext ); 
      }
      
      this.Capture(  task.Scope() );
      
      traverse( macroplan, Optimization.AlgorithmScaling.ScaleFactor, sf ) 
      {
        if ( sf.Type() = Optimization::ScalingTypeNameInventoryHolding() ) 
        {
          this.ScalingFactorInventoryHolding( sf.Value() ); 
        }
        else if ( sf.Type() = Optimization::ScalingTypeNameMass() ) 
        {
          this.ScalingFactorMass( sf.Value() ); 
        }
        else if ( sf.Type() = Optimization::ScalingTypeNameMonetary() ) 
        {
          this.ScalingFactorMonetary( sf.Value() ); 
        }
        else if ( sf.Type()= Optimization::ScalingTypeNameTime() ) 
        {
          this.ScalingFactorTime( sf.Value() );   
        }
        else if ( sf.Type() = Optimization::ScalingTypeNameTimeAccount() ) 
        {
          this.ScalingFactorTimeAccount( sf.Value() ); 
        }
      } 
      
      if ( runcontext.IsOTS() ) 
      {
        this.CaptureForOTS( task ); // ensure all KPI are recorded (expensive)
      } 
    }
    this.Comment( comment ); // note that is need to be set for OTS just as input argument is given in order to correctly set target values
  *]
}