next up previous contents index
Next: Average Queue Length in Up: Practice in DEVS# Previous: Transducer   Contents   Index


Utilization in DEVS#

Recall that to get Utilization, we need to accumulate the time intervals of piece-wise constant time-segments associated with a state. Accumulating the time intervals can be done using the criterion of either ``as long as possible'' or ``as short as possible''. ``Longer'' is preferred over ``shorter'' because it requires less computational burden.

If we accumulate the time interval in cases

(1)
when the constant segment might change at discrete event points, or
(2)
when the simulation run stops
the ``as long as'' preference might be achieved. For example, in Figure 4.3, times at $ t=$ 5, 20, 23, 28, 30 for case (1) (discrete state transitions) and also at $ t=$ 40 for case (2) (simulation stop time).

DEVS# calls the following function when_receive_cs for collecting the time interval of a state segment in cases of above (1) and (2).

    public override void when_receive_cs()
    {
        double dT = TimeCurrent - TimeLastcs;// dT: accumulating time span
        if (CollectStatisticsFlag())
        {
            string state_str = Get_Statistics_s();
            if (m_statistics.ContainsKey(state_str)==false)
                m_statistics.Add(state_str, 0.0); // add new entry
            m_statistics[state_str] += dT;
        }
        TimeLastcs = TimeCurrent;
    }
The function description of when_receive_cs() shows that it records and accumulates the time interval dT from the last time we called when_receive_cs() to the current time if the flag of collecting statistics is true.

We are using m_statistics (defined as Dictionary<string, double>) to collect statistics. The key value of piece-wise constant segment will be a string returned from Get_Statistics_s().

If the string of Get_Statistics_s() was not yet registered in m_statistics, the pair(state_str,0.0) will be newly registered in m_statistics where
state_str=Get_Statistics_s(). The value of m_statistics[state_str] is increased by dT. Finally, t_Lcs that is the last time when we calls when_receive_cs() is updated by the current time.

Every time we need to print the current statistics (such as when we use the command print p), DEVS# shows performance indices by calling each model's overriding GetPerformance(). The default implementation of Atomic:: GetPerformance() is as follows.

    public virtual Dictionary<string, double> GetPerformance()
    {
        Dictionary<string, double> statistics = new Dictionary<string,double>();
        if(CollectStatisticsFlag()==true) {
            foreach(string str in m_statistics.Keys)
            {
                double probability = m_statistics[str] / Devs.TimeCurrent;

                if(probability < 0.0 || probability > 1.0)
                    throw new Exception("Invalid Probability!");
                else
                    statistics[str] = probability;
            }
        }
        return statistics;
    }

As we can see, Atomic::GetPerformance() returns a Dictionary<string, double> such that statistics[key] = m_statistics[key]/TimeCurrent.

Thus statistics[key] contains the $ P(C$ =key) of Equation (4.3) over the interval from 0 to the current time.


next up previous contents index
Next: Average Queue Length in Up: Practice in DEVS# Previous: Transducer   Contents   Index
MHHwang 2007-05-08