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
Quintiq file version 2.0
#parent: #root
Function CalcKPIUpperBound
{
  TextBody:
  [*
    value := Real::MaxReal(); 
    if ( not this.KPIIsAccount() ) 
    {
      if ( this.KPIIsMaximize() ) 
      {
        if ( this.KPIName() = Translations::MP_GlobalParameters_KPIFulfillmentTargetName() ) 
        {
          value := sum( this, StrategyMacroPlan.MacroPlan.FulfillmentTarget, ft, ft.IsEnabled(), ft.TargetPercentage() * ft.TotalDemandQuantity() / 100 ); 
        }
        else if ( this.KPIName() = Translations::MP_GlobalParameters_KPIFulfillmentName() ) 
        {
          value := sum( this, StrategyMacroPlan.MacroPlan.SalesDemand, sd, true, sd.QuantityInDefaultUoM() ); 
        }
        else if ( this.KPIName() = Translations::MP_GlobalParameters_KPISalesDemandPriorityName() ) 
        {
          value := sum( this, StrategyMacroPlan.MacroPlan.SalesDemand, sd, sd.QuantityInDefaultUoM() * guard( sd.Priority().Weight(), 1.0 ) ); 
        }
        
        if ( this.KPIName() = Translations::MP_GlobalParameters_KPICampaignName() )
        {
          value := ifexpr(  this.StrategyMacroPlan().UseCampaignSequenceOptimizer(), 0.0, Real::MaxReal() ) // non-sequencing campaign goal includes transition output, so we assume no a prior bound, seq optimizer computes penalties only
        }
      }
      else
      {
        value := 0.0; // penalty KPI, know best score is 0
      }
    }
    this.KPIUpperBound( value );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}