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 ); 
 | 
  *] 
 | 
} 
 |