Quintiq file version 2.0
|
#parent: #root
|
Function CalcStandardDeviationServiceLevel
|
{
|
TextBody:
|
[*
|
// Calculate the standard deviation of this service level
|
achievedservicelevels := construct( Reals );
|
|
// Traverse all Iterations' Simulations
|
traverse( this, Iteration.Simulation, simulation )
|
{
|
totaldemand := 0.0;
|
totalunfulfilleddemand := 0.0;
|
|
// Traverse all SimulationPISPIP that belongs to the current Simulation
|
traverse( this, IterationPISPIP.SimulationPISPIP, simpispip,
|
simpispip.Simulation() = simulation )
|
{
|
// Add the SalesDemandQty & UnfulfilledDemandQty of the current SimulationPISPIP to the total variable respectively
|
totaldemand := totaldemand + simpispip.SalesDemandQty();
|
totalunfulfilleddemand := totalunfulfilleddemand + simpispip.UnfulfilledDemandQty();
|
}
|
|
// Default simulation service level to 100
|
simservicelevel := 100.0;
|
// Check if the current simulation has total demand larger than zero
|
if( totaldemand > 0.0 )
|
{
|
// Calculate the simulation service level
|
simservicelevel := 100 * ( 1.0 - totalunfulfilleddemand / totaldemand );
|
}
|
|
// Add the simulation service level to the set
|
achievedservicelevels.Add( simservicelevel );
|
}
|
|
// Calculate the standard deviation of this service level with the set of achieved service levels
|
averageservicelevel := average( achievedservicelevels, Elements, sl, sl );
|
nrsimulations := achievedservicelevels.Size();
|
standarddeviation := 0.0;
|
if( nrsimulations > 0 )
|
{
|
standarddeviation := sqrt( sum( achievedservicelevels, Elements, sl,
|
pow( sl - averageservicelevel, 2.0 ) )
|
/ achievedservicelevels.Size() );
|
}
|
|
this.StandardDeviationServiceLevel( standarddeviation );
|
*]
|
}
|