Quintiq file version 2.0
|
#parent: #root
|
Method Stockin (
|
ProductInStockingPoint_MP pisp,
|
Number period,
|
Real target
|
) as Real
|
{
|
Description: 'Ask Quintiq for the predicted service level of a PISP, period and specific target.'
|
TextBody:
|
[*
|
// this will calculate the service level
|
|
// on leaf location, simply call stockin_leaf and store the distributions for new supply and starting stock
|
|
stockin_p := -1.0; // reset in both branches
|
pispip := pisp.GetPISPIPFromPeriodNumber( period );
|
|
if ( pisp.MEIO_IsLeaf() )
|
{
|
stockin_p := this.StockinLeaf( pisp, period, target );
|
}
|
else // if location is not leaf, we take weighted average of the child nodes on the periods that are period+leadtimeToChild for each child
|
{
|
weighted := 0.0;
|
totalDemand := 0.0;
|
pispip.MEIO_Target( target );
|
traverse( MEIO_Engine::GetTreePISP( pisp ), Elements, child )
|
{
|
period_scope := period +this.GetLeadTime( child, pisp )
|
if( period_scope <= this.LastPeriodNumber() )
|
{
|
totalDemand := totalDemand + MEIO_Engine::GetDemandExpectedValue( child, period_scope );
|
mytarget := child.GetPISPIPFromPeriodNumber( period_scope ).MEIO_Target();
|
weighted := weighted
|
+ ( MEIO_Engine::GetDemandExpectedValue( child, period_scope )
|
* this.StockinLeaf( child, period_scope, mytarget ) )
|
}
|
}
|
if( totalDemand > 0)
|
{
|
stockin_p := weighted / totalDemand
|
}
|
else
|
{
|
stockin_p := 1
|
}
|
}
|
pispip.MEIO_Stockin( stockin_p);
|
return stockin_p
|
*]
|
}
|