陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
Quintiq file version 2.0
#parent: #root
Method InitVariablesForKPITotalValue (
  CapacityPlanningSuboptimizer_CapacityPlanningAlgorithm program,
  const RunContextForCapacityPlanning runcontext,
  const LibOpt_Scope scope
) const
{
  Description: 'Initialize all KPI variables that used as goal'
  TextBody:
  [*
    // Non financial kpis 
    // TotalBlending variable UoM: Unit
    program.TotalBlendingVariables().New();
    // TotalCampaign variable UoM: Unit
    
    totalcampvar := program.TotalCampaignVariables().New();
    if ( not runcontext.UseCampaignSequenceOptimizer() ) 
    {
      totalcampvar.LowerBound( Real::MinReal() ); // due to transition output maximization
      // TotalCampaignTransitionOutput variable UoM: Unit
      program.TotalCampaignTransitionOutputVariables().New();
    } 
    // TotalDifferenceInDemandDays variable UoM: Days
    program.TotalInventoryMixBalancingVariables().New();
    // TotalFulfillment variable UoM: Default
    program.TotalFulfillmentVariables().New();
    // TotalLotSize variable UoM: Unit
    program.TotalLotSizeVariables().New();
    // TotalMaximumInventoryLevel variable UoM: PISP
    program.TotalMaximumInventoryLevelVariables().New();
    // TotalMinimumInventoryLevel variable UoM: PISP
    program.TotalMinimumInventoryLevelVariables().New();
    // TotalMaximumSupply variable UoM: Unit
    program.TotalMaximumSupplyVariables().New();
    // TotalMinimumSupply variable UoM: Unit
    program.TotalMinimumSupplyVariables().New();
    // TotalMinimumUnitCapacity variable UoM: Unit
    program.TotalMinimumUnitCapacityVariables().New();
    // TotalMinimumUnitSecondaryCapacity variable UoM: TransportCapacity
    program.TotalMinimumUnitSecondaryCapacityVariables().New();
    // TotalPostPonementPenalty variable UoM: Monetary
    program.TotalPostponementPenaltyVariables().New();
    // TotalProcessMaximumQuantity variable UoM: Unit
    program.TotalProcessMaximumQuantityVariables().New();
    // TotalSalesDemandPriority variable UoM: Default. Priority can take a negative value, in which case the total SDPriority could also become negative
    var := program.TotalSalesDemandPriorityVariables().New();
    var.LowerBound( Real::MinReal() );
    // TotalFulfillmentTarget variable UoM: Default
    program.TotalFulfillmentTargetVariables().New();
    // TotalServiceLevel variable UoM: Default
    program.TotalServiceLevelVariables().New();
    // TotalSlack variable UoM: Default
    program.TotalSlackVariables().New();
    // TotalSlackUserSupply variable UoM: PISP
    program.TotalSlackUserSupplyVariables().New();
    // TotalStockingPointCapacity variable UoM: SP
    program.TotalStockingPointCapacityVariables().New();
    // TotalSupplyTarget variable UoM: Unit
    program.TotalSupplyTargetVariables().New();
    // TotalTargetInventoryLevel variable UoM: PISP
    program.TotalTargetInvLevelVariables().New();
    // TotalUnitCapacity variable UoM: Unit
    program.TotalUnitCapacityVariables().New();
    // TotalUnitSecondary variable UoM: TransportCapacity
    program.TotalUnitSecondaryCapacityVariables().New();
    // TotalCapacitySmoothing variable 
    program.TotalCapacitySmoothingSlackVariables().New(); 
    // TotalExpiredQty variable
    program.TotalExpiredQtyVariables().New();
    // TotalCO2Emission variable UoM: CO2
    program.TotalCO2EmissionVariables().New();
    // TotalShiftPatternChangesPenalty variable UoM: Default
    program.TotalShiftPatternChangesPenaltyVariables().New();
    // Account kpis
    
    accounts := scope.GetAccountsInOptimizerRunConst(); 
    traverse( accounts, Elements, account )
    {
      traverse( account, AccountAssignment.AccountCostDriver, driver )
      {
        // Account KPI variables UoM: Monetary                    
        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
        {
          program.DriverStaffingVariables().New( account, driver );
        }
        else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverInventoryValue() )   // inventory value
        {
          varval := program.DriverInventoryValueVariables().New( account, driver );
          varval.UpperBound( 0.0 );  // currently unused
          varval.LowerBound( 0.0 ); 
        }
        else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverInventoryHolding() ) // inventory holding
        {
          program.DriverInventoryHoldingVariables().New( account, driver );
        }
        else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverNrOfUnits() )        // nr of units
        {
          program.DriverNrOfUnitsVariables().New( account, driver ); // currently unused
        }
        else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverSales() )            // sales
        {
          program.DriverSalesVariables().New( account, driver );
        }
        else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverTime() )             // time
        {
          program.DriverTimeVariables().New( account, driver );
        }
        else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverVolume() )           // volume
        {
          program.DriverVolumeVariables().New( account, driver );
        }
        else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverLot() )              // Lot
        {
          program.DriverLotVariables().New( account, driver );
        }
        else if( driver.Name() = Translations::MP_AccountAssignmentCostDriverChangeover() )        // Changeover
        {
          program.DriverChangeoverVariables().New( account, driver );
        }
        else if ( driver.Name() = Translations::MP_AccountAssignmentCostDriverOneTime() )         // One-time cost
        {
          program.DriverOneTimeVariables().New( account, driver ); 
        }
        else
        {
          info( '>>> Can not create driver variable for account ', account.Name(), ' and driver name:', driver.Name() );  
        }
      }
    }
    
    if ( runcontext.IsMetaIteration() ) 
    {
      program.TotalStockingPointCapacityMetaVariables().New(); 
    }
      
    // Create goal variables for each level
    this.InitVariablesForLevelGoal( program, runcontext );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}