admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
Quintiq file version 2.0
#parent: #root
Method DebugAssignGoalValue (
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  AlgorithmRunLevel level,
  LibOpt_Scope scope
)
{
  Description: 'Assign goal value to attribute'
  TextBody:
  [*
    // Storing of goal value to instances
    
    level.Update( level.Start(), DateTime::ActualTime(), true, program.AbsoluteGap(), program.RelativeGap(), program.GoalValue(), program.Optimal() );
    level.UpdateStatistics( program, this.IsAutoScalingEnabled() );
    
    // Non-financial kpis
    result := level.OptimizerNonFinancialKPIResult();
    
    if( not isnull( result ) )
    {
      vartotalblending := program.TotalBlendingVariables().Get();
      result.GoalValueBlending( -this.GetOptimalValue( vartotalblending ) );
                
      vartotalcampaign := program.TotalCampaignVariables().Get();
      result.GoalValueCampaign( -this.GetOptimalValue( vartotalcampaign ) );
      
      vartotalfulfillment := program.TotalFulfillmentVariables().Get();
      result.GoalValueFulfillment( this.GetOptimalValue( vartotalfulfillment ) );
    
      varinventorymixbalancing := program.TotalInventoryMixBalancingVariables().Get();
      result.GoalValueInventoryMixBalancing( -this.GetOptimalValue( varinventorymixbalancing ) );
      
      vartotallotsize := program.TotalLotSizeVariables().Get();
      result.GoalValueLotSize( -this.GetOptimalValue( vartotallotsize ) );
    
      vartotalmaxinvlevel := program.TotalMaximumInventoryLevelVariables().Get();
      result.GoalValueMaximumInventoryLevel( -this.GetOptimalValue( vartotalmaxinvlevel ) );
    
      vartotalmininvlevel := program.TotalMinimumInventoryLevelVariables().Get();
      result.GoalValueMinimumInventoryLevel( -this.GetOptimalValue( vartotalmininvlevel ) );
    
      vartotalmaxsupply := program.TotalMaximumSupplyVariables().Get();
      result.GoalValueMaximumSupply( -this.GetOptimalValue( vartotalmaxsupply ) );
    
      var := program.TotalMinimumSupplyVariables().Get();
      result.GoalValueMinimumSupply( -this.GetOptimalValue( var ) );
    
      vartotalminunitcapacity := program.TotalMinimumUnitCapacityVariables().Get();
      result.GoalValueMinimumUnitCapacity( -this.GetOptimalValue( vartotalminunitcapacity ) );
    
      vartotalminunitsecondarycapacity := program.TotalMinimumUnitSecondaryCapacityVariables().Get();
      result.GoalValueMinimumUnitSecondaryCapacity( -this.GetOptimalValue( vartotalminunitsecondarycapacity ) );
    
      vartotalpostponementpenalty := program.TotalPostponementPenaltyVariables().Get();
      result.GoalValuePostponementPenalty( -this.GetOptimalValue( vartotalpostponementpenalty ) );
      
      vartotalprocessmaxqty := program.TotalProcessMaximumQuantityVariables().Get();
      result.GoalValueProcessMaximumQuantity( -this.GetOptimalValue( vartotalprocessmaxqty ) );
      
      vartotalsalesdemandpriority := program.TotalSalesDemandPriorityVariables().Get();
      result.GoalValueSalesDemandPriority( this.GetOptimalValue( vartotalsalesdemandpriority ) );
    
      vartotalfulfillmenttarget := program.TotalFulfillmentTargetVariables().Get();
      result.GoalValueFulfillmentTarget( this.GetOptimalValue( vartotalfulfillmenttarget ) );
    
      vartotalservicelevel := program.TotalServiceLevelVariables().Get();
      result.GoalValueServiceLevel( this.GetOptimalValue( vartotalservicelevel ) );
      
      vartotalstockingcapacity := program.TotalStockingPointCapacityVariables().Get();
      result.GoalValueStockingPointCapacity( -this.GetOptimalValue( vartotalstockingcapacity ) );
    
      vartotalslack := program.TotalSlackVariables().Get();
      result.GoalValueSlack( -this.GetOptimalValue( vartotalslack ) );
      
      vartotalsupplytarget := program.TotalSupplyTargetVariables().Get();
      result.GoalValueSupplyTarget( -this.GetOptimalValue( vartotalsupplytarget ) );
    
      vartotaltargetinvlevel := program.TotalTargetInvLevelVariables().Get();
      result.GoalValueTargetInventoryLevel( -this.GetOptimalValue( vartotaltargetinvlevel ) );
    
      vartotalunitcapacity := program.TotalUnitCapacityVariables().Get();
      result.GoalValueUnitCapacity( -this.GetOptimalValue( vartotalunitcapacity ) );
      
      vartotalunitsecondarycapacity := program.TotalUnitSecondaryCapacityVariables().Get();
      result.GoalValueUnitSecondaryCapacity( - this.GetOptimalValue( vartotalunitsecondarycapacity ) );
      
      vartotalcapacitysmoothingslack := program.TotalCapacitySmoothingSlackVariables().Get(); 
      result.GoalValueCapacitySmoothingSlack( -this.GetOptimalValue( vartotalcapacitysmoothingslack ) ); 
                     
      vartotalexpired := program.TotalExpiredQtyVariables().Get();                 
      result.GoalValueTotalExpiredQty( -this.GetOptimalValue( vartotalexpired ) );
      
      vartotalco2emission := program.TotalCO2EmissionVariables().Get();
      result.GoalValueCO2Emission( -this.GetOptimalValue( vartotalco2emission ) );
      
      vartotalshiftpatternchangespenalty := program.TotalShiftPatternChangesPenaltyVariables().Get();
      result.GoalValueShiftPatternChangesPenalty( -this.GetOptimalValue( vartotalshiftpatternchangespenalty ) );
    }
    
    // Account kpis
    traverse( scope.GetAccountsInOptimizerRun(), Elements, account )
    {
      accountresult := select( level, OptimizerAccountKPIResult, r, r.AccountName() = account.Name() );
    
      if( not isnull( accountresult ) )
      {
        traverse( account, AccountAssignment.AccountCostDriver, driver )
        {
          if( driver.Name() = Translations::MP_AccountAssignmentCostDriverFixed() )                 // fixed
          {
            // we don't need fixed cost in the optimizer. 
          }
          else if ( driver.Name() = Translations::MP_AccountAssignmentCostDriverInventorySupply() ) 
          {
            // cost driver inventory supply not applicable in optimizer                             // inventory supply
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverStaffing() )         // staffing
          {
            var := program.DriverStaffingVariables().Get( account, driver );
            value := this.GetOptimalValue( var );
            accountresult.GoalValueStaffing( -value );
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverInventoryValue() )   // inventory value
          {
            var := program.DriverInventoryValueVariables().Get( account, driver );
            value := this.GetOptimalValue( var );
            accountresult.GoalValueInventoryValue( value );
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverInventoryHolding() ) // inventory holding
          {
            var := program.DriverInventoryHoldingVariables().Get( account, driver );
            value := this.GetOptimalValue( var );
            accountresult.GoalValueInventoryHolding( -value );
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverNrOfUnits() )        // nr of units
          {
            var := program.DriverNrOfUnitsVariables().Get( account, driver ); 
            value := this.GetOptimalValue( var );
            accountresult.GoalValueNrOfUnits( -value );
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverSales() )            // sales
          {
            var := program.DriverSalesVariables().Get( account, driver );
            value := this.GetOptimalValue( var );
            accountresult.GoalValueSales( value );
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverTime() )             // time
          {
            var := program.DriverTimeVariables().Get( account, driver );
            value := this.GetOptimalValue( var );
            accountresult.GoalValueTime( -value );
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverVolume() )           // volume
          {
            var := program.DriverVolumeVariables().Get( account, driver );
            value := this.GetOptimalValue( var );
            accountresult.GoalValueVolume( -value );
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverLot() )              // Lot
          {
            var := program.DriverLotVariables().Get( account, driver );
            value := this.GetOptimalValue( var );
            accountresult.GoalValueLot( -value );
          }
          else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverChangeover() )        // Changeover
          {
            var := program.DriverChangeoverVariables().Get( account, driver );
            value := this.GetOptimalValue( var );
            accountresult.GoalValueChangeOver( -value );
          }
          else if ( driver.Name() = Translations::MP_AccountAssignmentCostDriverOneTime() )         // One-time 
          {
            var := program.DriverOneTimeVariables().Get( account, driver ); 
            value := this.GetOptimalValue( var ); 
            accountresult.GoalValueOneTimeCost( -value ); 
          }
          else
          {
            info( '>>> Missing goal value assignment for account ', account.Name(), ' driver name:', driver.Name() );  
          }
        }
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}