The class Buffer
in DEVSsharp/ModelBase/Buffer.cs
shows how to collect the average queue length. The default
implementation of Get_Statistics_s()
at Atomic
is to
return Get_s()
. However, Buffer
overrides the
Get_Statistics_s()
such that it returns the number of jobs
waiting in a buffer m_Jobs
as follows.
public override string Get_Statistics_s() { // length Only return string.Format("{0}", m_Jobs.Count); }
The class Buffer
inherits Atomic::when_receive_cs()
shown in the previous section. But it overrides
GetPerformance()
function as follows.
public override Dictionary<string, double> GetPerformance() { Dictionary<string, double> statistics = new Dictionary<string,double>(); if(CollectStatisticsFlag()==true) { double E_i=0; // expectation of queueing line length foreach(string key in m_statistics.Keys) { double probability = m_statistics[key]/TimeCurrent;// P(i) if(probability < 0.0 || probability > 1.0) { throw new Exception("Invalid Probability!"); } else{ int i = System.Convert.ToInt32(key); E_i += probability * i;// E(i)=\Sum_{i} i*P(i) } } statistics.Add("Average Q length: ", E_i); } return statistics; }It makes =
i
) using m_statistics[i]
. Then it
makes
by summing over i
*
(i
) for all
i
as defined in Equation (4.7).
The rest other functions defined in Buffer
class will be
examined in the next section.