Queue system queue delay

A number of monitors for the Queue system example net illustrate different ways to measure the amount of time that jobs wait in the queue.

Queue delay

This is a generic data collector monitor that is associated with the Start transition on the Server page. The monitor is used to measure the amount of time that jobs wait in the queue.

Queue Delay monitor

Each job is represented by a record, and the record contains a field named AT which represents the arrival time of the job, i.e. the field contains the model time at which the job was added to the queue. When the Start transition occurs, the job at the head of the queue is removed, and the queue delay for the job can be calculated by subtracting the value of the AT field for the job from current model time.

This data collector monitor can be used to calculate several interesting statistics, such as the average and maximum queue delays and how many jobs passed through the queue during a simulation. This monitor calculates untimed statistics.

The data collector monitoring functions for the monitor are described below.

Predicate function

The predicate function for the monitor is invoked each time the transition Start occurs, and it will always return true when the transition occurs.

fun pred (bindelem) = 
let
  fun predBindElem (Server'Start (1, {jobs, job,proctime})) = true
    | predBindElem _ = false
in
  predBindElem bindelem  
end

Observation function

This observation function invoked every time the above predicate function returns true, i.e. it will be invoked every time the Start transition occurs.

fun obs (bindelem) = 
let
  fun obsBindElem (Server'Start (1, {jobs, job,proctime})) = 
          (intTime()-(#AT job))
    | obsBindElem _ = ~1

in
  obsBindElem bindelem  
end

Each time the Start transition occurs the observation function will return the amount of time that the job at the head of the queue spent in the queue. The expression (intTime()-(#AT job)) calculates the queue delay for the job that is bound to the variable job when the Start transition occurs. The function intTime is described above. The # operator is a operator for record color sets, and it is used here to access the value of the AT field for the record that is bound to the variable job. The observation function returns integer values.

Initialization and stop functions

This monitor does not need to collect data either before a simulation starts or when simulation stop criteria are fulfilled. Therefore, both the initialization and stop functions return the value NONE.

fun init () = NONE
fun stop () = NONE

Queue delay real

This monitor is very similar to the Queue Delay monitor. The only difference is that the observation function returns real values rather than integer values.

fun obs (bindelem) = 
let
  fun obsBindElem (Server'Start (1, {jobs, job,proctime})) = 
          Real.fromInt(intTime()-(#AT job))
    | obsBindElem _ = ~1.0

in
  obsBindElem bindelem  
end

Queue delay IntInf

This monitor is also very similar to the Queue Delay monitor. The only difference is that the observation function returns infinite integer (IntInf.int) values rather than integer values.

Long delay times

This generic data collector monitor is used to calculate the proportion of jobs that have to wait in the queue for a long time. The reference variable longdelaytime is used to determine the lower limit for long wait times. The initial value for this variable is 200, as determined by the declaration of the variable, which is described on the page for the Queue System.

The monitor is associated with the Start transition, and it calculates untimed statistics.

Long processing times monitor

The initialization and stop functions return the value NONE.

The predicate function returns true whenever the Start transition occurs.

The observation function accesses the last value that was collected by the “Queue Delay” monitor, using the last function which is one of the data collector functions. If the queue delay for the job that was just removed from the queue is greater or equal to than the value referenced by longdelaytime, then the observation function will return 1, otherwise it will return 0.

fun obs (bindelem) = 
   if IntInf.toInt(Queue_Delay.last()) >= (!longdelaytime)
   then 1
   else 0

The sum for this monitor will indicate how many jobs had long waiting times, while the average for this monitor will indicate the proportion of jobs that had long waiting times.

Each time the Start transition occurs, the “Queue Delay” monitor will extract data from the net before this monitor extracts data from the net. This is due to the facts that both monitors are associated with the Start transition, both predicate functions return true when the transition occurs, and the “Queue Delay” monitor comes before this monitor in the list of monitors in the index. For more information about the order in which monitoring functions are invoked see the help page for Monitoring functions.

Related pages