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
Quintiq file version 2.0
#parent: #root
FunctionOverride CalcEISSourcingCost
{
  TextBody:
  [*
    value := 0.0; 
    eis := this.MacroPlan().OptimizerMetaEIS(); 
    if ( not isnull( eis )
         and eis.InventoryHoldingCostLevel() <= eis.FocusLevelForEIS() 
         and this.InventoryLevelEnd() >= 0.0 )
    {
      usedinventory := minvalue(  maxvalue ( this.InventoryLevelEnd(), 0.0 ), // not considering pispip that have negative inventory 
                                  maxvalue(  this.InventoryLevelEnd() - this.MinInventoryEndMinusTargetFuturePISPIP(), 0.0 ) );  // used = largest inventory drop
      unused := this.InventoryLevelEnd() - usedinventory; 
      overproductioninperiod := minvalue(  unused, this.NewSupplyQuantity() ); 
      weight := eis.InventoryHoldingCostWeight(); 
      sourcingcostperqty := this.TotalBaseInventoryHoldingCostPerQuantity() * weight; // for now - sourcing cost proportional to unused inventory
      value := ( sourcingcostperqty * overproductioninperiod ) / pow( eis.BaseForTried(), this.MetaOptimizerTried() ); 
      value := value / pow(  eis.BaseForTriedAsFriend(), [Real]this.MetaOptimizerTriedAsFriend() ); 
      if ( abs(  value ) < 1 ) // once it get below 1 - just make it 0. So we switch to random anchor at some point. 
      {
        value := 0.0; 
      }
    } 
    this.EISSourcingCost( value );
  *]
}