# Description

DELAY.MOD represents a single-server queue that keeps track of how many customers have waited for more than L time units. This model can be used to estimate the probability that a customer waits less than a specified time (see comments), and to infer Little's Law using event counts.

# State Variables

State Variables in DELAY.MOD
Variable Name Abbreviation Variable Description Size Type
QUEUE Q Number of jobs in queue 1 Integer
RESOURCES R Number of idle resources in model 1 Integer
S S Count of START Events 1 Integer
D D Count of DELAY Events 1 Integer
W W Proportion of jobs waiting longer than L 1 Real
L L Waiting time limit - to estimate Prob{Wait<L} 1 Real
PROB PROB Estimate of Prob{Wait<L} 1 Real

# Vertices

Vertices in DELAY.MOD
Vertex Name Vertex Description State Changes
RUN The simulation is started None
ARRIVE Customers arrive in the queue Q=Q+1
START Jobs start service Q=Q-1, R=R-1, S=S+1
FINISH Jobs finish processing R=R+1
DELAY Counts delay events and number of customers who wait longer than L time units D=D+1, W=W+(S>=D), PROB=W/D

# Initialization Conditions

Initialization Conditions in DELAY.MOD
Variable Description
RESOURCES Initial number of resources
L Waiting time limit

# English Translation

An English translation is a verbal description of a model, automatically generated by SIGMA.

```The SIGMA Model, DELAY.MOD, is a discrete event simulation.
It models estimates the probability that the Wait<L.
```
```I. STATE VARIABLE DEFINITIONS.
```
```For this simulation, the following state variables are defined:
```
```R: Number of idle resources in model   (integer valued)
Q: Number of jobs in queue   (integer valued)
S: Count of Start Events   (integer valued)
D: Count of Delay Events   (integer valued)
W: Proportion of jobs waiting longer than L  (real valued)
L: Waiting time limit - to estimate Prob{Wait<L}  (real valued)
PROB: Estimate of Prob{Wait<L}  (real valued)
```
```II. EVENT DEFINITIONS.
The SIGMA Model, DELAY.MOD, is a discrete event simulation. It models estimates the probability
```
```Simulation state changes are represented by event vertices (nodes or balls) in a SIGMA graph.
Event vertex parameters, if any, are given in parentheses.
Logical and dynamic relationships between pairs of events are represented in a SIGMA graph
by edges (arrows) between event vertices.
Unless otherwise stated, vertex execution priorities, to break time ties, are equal to 5.
```
```1. The Run(R,L) event occurs when the run is started.
Initial values for, R,L, are needed for each run.
After every occurrence of the Run event:
Unconditionally, schedule the first job arrival;
that is, schedule the Arrive() event to occur without delay.
```
```2. The Arrive() event occurs when customers arrive in the queue.
This event causes the following state change(s):
Q=Q+1
After every occurrence of the Arrive event:
Unconditionally, schedule the next job arrival;
that is, schedule the Arrive() event to occur in (1/.9)*ERL{1} time units.
If R>0, then there is an idle resource;
that is, schedule the Start() event to occur without delay.
Unconditionally, a job arrived L time units ago;
that is, schedule the Delay() event to occur in L time units.
(Time ties are broken by an execution priority of 6.)
```
```3. The Start() event occurs when jobs start service.
This event causes the following state change(s):
Q=Q-1
R=R-1
S=S+1
After every occurrence of the Start event:
Unconditionally, the job will finish after its processing time;
that is, schedule the Finish() event to occur in 1*ERL{1} time units.
```
```4. The Finish() event occurs when jobs finish processing.
This event causes the following state change(s):
R=R+1
After every occurrence of the Finish event:
If Q>0, then there are jobs waiting, start on the next job;
that is, schedule the Start() event to occur without delay.
```
```5. The Delay() event:
This event causes the following state change(s):
D=D+1
W=W+(S>=D)
PROB=W/D
No additional events are scheduled here.
```

Estimating the probability that a customer waits less than a specific time using DELAY.MOD:

Suppose that we wish to compute the following probability distribution:

W is the average time a job waits in the queue. We can easily do this without storing any information for first-come-first-served (FIFO) queues. This is done by adding the DELAY event (see the Event Relationship Graph) that is scheduled to occur τ time units after each ARRIVAL event. The DELAY event simply tells us that a job arrived τ minutes ago. If service has not started by that time, then the customer has waited in queue longer than τ. We keep a count of the DELAY events that occur by time t, D(t). Whenever a START event occurs and D(t)≥S(t), then that job has waited in line at least τ. Let W be the total number of START events where D(t)<S(t). Our estimator of FW(τ) is simply W/S(t) which as t gets large will converge to the correct probability.

To understand how this works, draw a hypothetical D(t) plot, like that in the figure below. D(t) will always be below A(t) - a job obviously cannot experience a delay in the queue until after it has arrived. D(t) will cross S(t) horizontally when a service starts before τ and vertically when a job is delayed longer than τ.