| Quintiq file version 2.0 | 
| #parent: #root | 
| Method GetWeightedModelKPI () declarative as Real | 
| { | 
|   Description: | 
|   [* | 
|     Returns the sum of weighted KPIs, over KPIs that are assigned to current level. | 
|     Can be different from ProgramGoalValue if CPLEX includes goal terms of earlier fixed levels. | 
|   *] | 
|   TextBody: | 
|   [* | 
|     curlevel := this.Level(); | 
|     algorithmrun := this.AlgorithmRun(); | 
|      | 
|     //nonfinancial part of KPI, filtering by level done below | 
|     nonfinancialresult := this.OptimizerNonFinancialKPIResult(); | 
|     // for each weightedn value in the non financialresult, it is determined if it should be accounted for | 
|     // first Blending, Campaign, Fullfillment, InventoryMixBalancing, LotSize, MaximumInventoryLevel, MaximumSupply, MinimumInventoryLevel, MinimumUnitCapacity and MinimumSecondaryCapacity | 
|     // are added | 
|     nonfinancialkpi :=   ( nonfinancialresult.KPICampaign() + nonfinancialresult.KPICampaignTransitionTotalQuantity() ) * ( ifexpr( curlevel = algorithmrun.CampaignLevel(), algorithmrun.CampaignWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIFulfillment() * ( ifexpr( curlevel = algorithmrun.FulfillmentLevel(), algorithmrun.FulfillmentWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIInventoryMixBalancing() * ( ifexpr( curlevel = algorithmrun.InventoryMixBalancingLevel(), algorithmrun.InventoryMixBalancingWeight() , 0 ) ) | 
|                        + nonfinancialresult.KPILotSize() * ( ifexpr( curlevel = algorithmrun.LotSizeLevel(), algorithmrun.LotSizeWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIMaximumInventoryLevel() * ( ifexpr( curlevel = algorithmrun.MaximumInventoryLevel(), algorithmrun.MaximumInventoryLevelWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIMaximumSupply() * ( ifexpr( curlevel = algorithmrun.MaximumSupplyLevel(), algorithmrun.MaximumSupplyWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIMinimumInventoryLevel() * ( ifexpr( curlevel = algorithmrun.MinimumInventoryLevel(), algorithmrun.MinimumInventoryLevelWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIMinimumUnitCapacity() * ( ifexpr( curlevel = algorithmrun.MinimumUnitCapacityLevel(), algorithmrun.MinimumUnitCapacityWeight(), 0 ) ) | 
|                        // after which we continue with MinimumSupply, PostponentPenalty, ProcessMinimum and -MaximumQuantity, SalesDemandPriority, FulfillmentTarget, ServiceLevel, Slack | 
|                        // StockingPointCapacity, SupplyTarget, TargetInventoryLevel, UnitCapacity and UnitSecondaryCapacity | 
|                        + nonfinancialresult.KPIMinimumSupply() * ( ifexpr( curlevel = algorithmrun.MinimumSupplyLevel(), algorithmrun.MinimumSupplyWeight(), 0 ) )  | 
|                        + nonfinancialresult.KPIPostponementPenalty() * ( ifexpr( curlevel = algorithmrun.PostponementPenaltyLevel(), algorithmrun.PostponementPenaltyWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIProcessMaximumQuantity() * ( ifexpr( curlevel = algorithmrun.ProcessMaximumQuantityLevel(), algorithmrun.ProcessMaximumQuantityWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIProcessMinimumQuantity() * ( ifexpr( curlevel = algorithmrun.ProcessMinimumQuantityLevel(), algorithmrun.ProcessMinimumQuantityWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPISalesDemandPriority() * ( ifexpr( curlevel = algorithmrun.SalesDemandPriorityLevel(), algorithmrun.SalesDemandPriorityWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIShiftPatternChangesPenalty() * ( ifexpr( curlevel = algorithmrun.ShiftPatternChangesPenaltyLevel(), algorithmrun.ShiftPatternChangesPenaltyWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIFulfillmentTargetAbsolute() * ( ifexpr( curlevel = algorithmrun.FulfillmentTargetLevel(), algorithmrun.FulfillmentTargetWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIServiceLevel() * ( ifexpr( curlevel = algorithmrun.ServiceLevelLevel(), algorithmrun.ServiceLevelWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIStockingPointCapacity() * ( ifexpr( curlevel = algorithmrun.StockingPointCapacityLevel(), algorithmrun.StockingPointCapacityWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPISupplyTarget() * ( ifexpr( curlevel = algorithmrun.SupplyTargetLevel(), algorithmrun.SupplyTargetWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPITargetInventoryLevel() * ( ifexpr( curlevel = algorithmrun.TargetInventoryLevel(), algorithmrun.TargetInventoryLevelWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPIUnitCapacity() * ( ifexpr( curlevel = algorithmrun.UnitCapacityLevel(), algorithmrun.UnitCapacityWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPITotalExpiredQty() * ( ifexpr( curlevel = algorithmrun.ExpiredQtyLevel(), algorithmrun.ExpiredQtyWeight(), 0 ) ) | 
|                        + nonfinancialresult.KPICO2Emission() * ( ifexpr( curlevel = algorithmrun.CO2EmissionLevel(), algorithmrun.CO2EmissionWeight(), 0 ) ) | 
|      | 
|     //accounts - filtering by levels is very convenient here | 
|     accountkpi := sum( this, OptimizerAccountKPIResult, accountkpiresult, | 
|                        accountkpiresult.Level() = this.Level(), | 
|                        accountkpiresult.AccountValueWithinKPIHorizon() * accountkpiresult.Weight() * ifexpr(  accountkpiresult.IsMaximize(), 1, -1 ) ); | 
|      | 
|     return nonfinancialkpi + accountkpi; | 
|   *] | 
|   InterfaceProperties { Accessibility: 'Module' } | 
| } |