Queues appear when a flow of vehicles, persons or objects wants to receive a service that implies a restriction. Typically, services have a limited capacity or are offered only with some frequency, which may lead to queues, delays and waits.
The subject that studies queues is referred to Queuing Theory (see also [[03. Variabili Aleatorie#Teoria delle code]], [[05. Teoria del Deflusso#Teoria delle code]]).
Most of the complexities of queuing theory come from the stochastic nature of the processes involved.
Components of a queuing system
Server: the restriction
Storage: where the costumer waits
Arrivals: the ones that feed the queue
Departures: the yield after service
In a queuing system, the server represents the restriction of the system. The server is able to provide the service at a certain rate, .
Server disposition
In any system, there can be more than 1 server. The servers, can be
[[#Servers in parallel]]
[[#Servers in series]]
Servers in parallel
When the servers are localised in parallel, they can work at the same time. These are differentiated based on how the queue works:
[[#Decentralised system]]
[[#Centralised queue]]
One problem that might arise with parallel service, is that the servers are not positioned in space in an efficient way. It may happen that the queue of one server blocks some other server. This could happen, for example, at a petrol station where two pumps are one after the other and there is not enough space for cars to overtake each other.
Decentralised system
In a decentralised system, each server has its own queue.
The centralised queue, if well managed, can maximize the capacity and efficiency of the system. In fact, in this case, no server will ever be idle, while there are other servers working.
It also guarantees the [[#First Come First Serves - FCFS]] functioning.
In these kind of systems, it is important to implement adequate information system that assigns customers to servers at due time. This needs to ensure that there is no idle server at any time.
This can be challenging, especially when it takes a long time for the costumer to get to the server from the end of the queue (think of container ships waiting outside a port).
In this kind of systems costumers need to undertake several steps to receive a complete service.
For example, in an airport, a passenger has first to check-in, thank go through security, and finally queue to board the plane. Seen as a whole, this is a tandem queue.
In this scenario, the departure from the previous server, is the arrival of the subsequent one.
A better explanation of this kind of systems is provided in the section [[#Tandem queueing system]]
Storage
Arrivals
Departures
Queuing disciplines
Queuing discipline is a non-physical component of a queuing system. It refers to the rules which determine in which order the costumers are served.
The most common ones are:
[[#First Come First Serves - FCFS]]
[[#Last Come Last Serves - LCLS]]
[[#Service in Random Order - SIRO]]
[[#Round Robin - RR]]
Sometimes, there can be priorities assigned to some kind of costumers, leading to a new type of discipline:
[[#Early Due Date First - EDDF]]
[[#Shortest Service Time First - SSTF]]
First Come First Serves - FCFS
This is the most common discipline when dealing with human costumers.
first come first serves (fcfs)
In FCFS discipline, service is provided in the same order of arrivals.
This doesn't mean that the first costumer to enter will also be the first one to exit as, with [[#Servers in parallel]], some server may be faster than another allowing for overtakes in the system.
Last Come First Serves - LCFS
last come first serves (lcfs)
In LCLS discipline, costumers are served in the reversed order of arrival.
This happens when the [[#Storage]] is in a closed space and the entrance and exit are the same "door".
For example an airport shuttle bus will unload first the passengers that boarded the bus at last and viceversa.
Service in Random Order - SIRO
service in random order (siro)
In SIRO discipline there is no preset order and the costumer is selected randomly from the queue.
This system is mostly applied to industrial processes where the costumer are different items in a production line.
Round Robin - RR
round robin - rr
In RR discipline, each costumer is assigned the same amount of service time. If the service is not completed in said time, the costumer returns back into the queue.
This discipline applies in the communication networks.
Early Due Date First - EDDF
Shortest Service Time First - SSTF
Cumulative plot
cumulative plot
A cumulative plot - diagram - plots the cumulative number of customers , to cross a specific location as a function of time .
Properties of the cumulative plot:
It's a discrete function
It's always increasing or, at most, constant
The flow of vehicles or passengers can be calculated starting from the cumulative plot as:
where
the period of observation
The plot can be obtained in 2 ways:
Every time a customer enters the system, the time and the cumulative number of customer is recorded
Every a predefined , the cumulative number of customer that entered the system in that time interval is recored
When a large number of customer is recorded, the jumps of the function become meaningfulness. So, the function is usually replaced by a continuous interpolation.
Notice that the horizontal distance between the 2 curves at a given number of cumulative costumers, , is the time spent by that costumer in the system. This time includes:
Potential delays
Free flow service time
Instead, the vertical distance between the 2 curves at a given instant , is the customer accumulation in the system. This includes:
The customer being served at the moment
The customers waiting to be served
observation
The curve can never go above the curve since, in order to exit, a customer has to have enter first.
It the 2 curves match, it means that the system is empty of customers.
In the diagram above, other than the input-output diagram, the amount of customers in service and in queue at any given time is also shown:
In the input-output diagram, the Arrival curve usually takes the shape of a logistic curve.
The arrival rate is always relatively small at the two extremes while it picks in the middle (the arrival rate, , is given by the slope of the arrival curve). This is because, as humans, we tend to want the same service at about the same time. This pick rate is theoretically unbounded.
The departure curve instead, has a fixed maximum rate, , equal to the Capacity of the system. So, this slope is always bounded.
From a normal [[#Input-output diagram]] we can easily read the sum of the service time and delay, and the total accumulation (number of customer being served + customers queuing).
It is useful to be able to read directly the delay and the excess accumulation. This can be done through the [[#Virtual Arrivals Curve]]
3D representation of input-output diagram
If we want to visualize both vehicles trajectories and input-output diagram on the same chart, we can do so in a 3D diagram:
The projection of this diagram on the () plane gives the trajectories, while the projection onto the plane gives the input-output diagram.
We can also look at the two projection one under the other to visualize everything on a single plane:
Virtual Arrivals Curve
virtual arrivals curve (v(t))
The Virtual Arrivals Curve is a curve obtained by moving the arrival curve () forward in time of an amount equal to the free flow travel time.
It can also be defined as the [[#Departures]] curve that would be measured in the absence of delay.
We can calculate Average excess accumulation () in the period :
Take some time to think on the meaning of the average excess accumulation:
The average excess accumulation is always less or equal to the number of costumers that we see in the physical queue. Watch the example below to better understand this concept.
The diagram shows a stretch of road in 2 scenarios:
No queue: cars move freely at the same speed
We count 2 veh in the area of interest (the one in the orange dashed box)
Queue: Some cars are queueing in the area of interest
We count 5 cars
Notice that, of the 5 cars in the boxed area, even without queue, there would be 2. Meaning, the excess accumulation is NOT 5, but just 3.
Delay
delay ($w$)
The Delay () is the extra time a costumer has to spend in the system due to queuing.
Delay can be obtained as the horizontal distance in the diagram between the [[#Virtual Arrivals Curve]] and the [[#Departures]] curve.
You can't use 'macro parameter character #' in math modeas the total delay collectively incurred by customers between $n_{i}$ and $n_{j}$. ```ad-Teo title: Average delay per costumer ($\overline{w}$) We calculate the **Average delay per costumer** ($\overline{w}$) in the group between $n_{i}$ and $n_{j}$: $ \overline{w} = \frac{W_{2}}{n_{j}-n_{i}} $ ``` ## Little's Formula ![Little's Formula diagram - 02 - Fundamentals fo Queuing Theory - OMT 2024-11-03 18.36.38.excalidraw.png](/img/user/Excalidraw-2/Little's%20Formula%20diagram%20-%2002%20-%20Fundamentals%20fo%20Queuing%20Theory%20-%20OMT%202024-11-03%2018.36.38.excalidraw.png) %%🖋 Edit in Excalidraw%% ```ad-Teo title: Little's Formula $ \overline{\lambda} = \frac{\overline{Q}}{\overline{w}} $ **Proof:** According to the definition, we can write for the #Average delay per costumer: $ \overline{w} = \frac{W}{n_{2}-n_{1}} \quad \Longrightarrow \quad W = \overline{w}(n_{2}-n_{1}) $ Meaning that: $ \overline{Q}(t_{2}-t_{1}) = \overline{w}(n_{2}-n_{1}) $ Therefore: $ \frac{\overline{Q}}{\overline{w}} = \frac{n_{2}-n_{1}}{t_{2}-t_{1}} $ where the ratio on the right-hand side is the ratio of arrival of costumer, $\lambda$. $ \frac{\overline{Q}}{\overline{w}} = \lambda $ *q.e.d.* ``` ## Typical scenario In a typical scenario we only have part of the data:
\begin{align}
\text{Knowns: }&
\begin{cases}
V(t): \text{Measured when there are few people} \
\mu : \text{Max service flow (it's a property of the facility)}
\end{cases} \ \
\text{Unknowns: }&
\begin{cases}
\overline{w}\
\overline{Q}
\end{cases} \quad \Longrightarrow\text{We need the }D(t)
\end
You can't use 'macro parameter character #' in math modeWe will describe how we can construct the departure's curve. First, keep in mind these 2 properties: - $\dot{D}(t) = \mu \quad$ if there is queue - $\dot{D}(t) = \min(\dot{V}(t), \mu)\quad$ if there is NO queue Also, the following rules must be followed:
\begin{cases}
D(t) < V(t) \quad \forall t \
\dot{D}(t) < \mu \quad \forall t
\end
You can't use 'macro parameter character #' in math mode ![Constructing a departures curve on N-t diagram - 02 - Fundamentals fo Queuing Theory - OMT 2024-11-03 19.24.26.excalidraw.png](/img/user/Excalidraw-2/Constructing%20a%20departures%20curve%20on%20N-t%20diagram%20-%2002%20-%20Fundamentals%20fo%20Queuing%20Theory%20-%20OMT%202024-11-03%2019.24.26.excalidraw.png) %%🖋 Edit in Excalidraw%% Notice how the $D(t)$ curve follows exactly the $V(t)$ curve until the rate of arrival, $\dot{V}(t)$ is greater than the rate of service, $\mu$. From this instance, the $D(t)$ has a constant slope equal to $\mu$, until it meets back the $V(t)$, at which point it goes back to following it. ❗❗❗❗❗❗❗❗❗❗❗❗ ❗❗❗ COMPLETARE ❗❗❗ How to take average ❗❗❗❗❗❗❗❗❗❗❗❗ ## On-off queueing system ```ad-Definizione title: On-off queueing system **On-off queueing systems** are systems where the service rate has 2 values, depending on wether the system is on or off: $ \text{Service rate} = \begin{cases} \mu \quad \text{when on}\\ 0 \quad \text{when off} \end{cases} $ ``` A typical example of on-off queuing system is the **traffic light**. For simplicity, the following paragraph will assume the system is a traffic light with 2 states: <mark style="background: #BBFABBA6;">Geen</mark> and <mark style="background: #FF5582A6;">Red</mark>. The traffic light alternates between an on state, green, for a time $G$ and an off-state, red, for a time $R$. The green and red phases together make a *cycle*, lasting $C$. The system has a steady demand, $\lambda$, and a maximum constant on-state rate of service equal to $\mu$. A traffic signal defined as such, can work in 3 different conditions: - 🖋 Edit in Excalidraw%% We can get the total cumulated 🖋 Edit in Excalidraw%% Notice how the $D(t)$ curve follows exactly the $V(t)$ curve until the rate of arrival, $\dot{V}(t)$ is greater than the rate of service, $\mu$. From this instance, the $D(t)$ has a constant slope equal to $\mu$, until it meets back the $V(t)$, at which point it goes back to following it. ❗❗❗❗❗❗❗❗❗❗❗❗ ❗❗❗ COMPLETARE ❗❗❗ How to take average ❗❗❗❗❗❗❗❗❗❗❗❗ ## On-off queueing system ```ad-Definizione title: On-off queueing system **On-off queueing systems** are systems where the service rate has 2 values, depending on wether the system is on or off: $ \text{Service rate} = \begin{cases} \mu \quad \text{when on}\\ 0 \quad \text{when off} \end{cases} $ ``` A typical example of on-off queuing system is the **traffic light**. For simplicity, the following paragraph will assume the system is a traffic light with 2 states: <mark style="background: #BBFABBA6;">Geen</mark> and <mark style="background: #FF5582A6;">Red</mark>. The traffic light alternates between an on state, green, for a time $G$ and an off-state, red, for a time $R$. The green and red phases together make a *cycle*, lasting $C$. The system has a steady demand, $\lambda$, and a maximum constant on-state rate of service equal to $\mu$. A traffic signal defined as such, can work in 3 different conditions: - 🖋 Edit in Excalidraw%% We can get the total cumulated [[#Delay]] as the area in purple, $W$. Let $t^{*}$ be the time at which the queue completely dissipates, the total amount of customers that were in a queue and that were completely served in the time $t^{*}$ is equal to:
n = \begin{cases}
\lambda t^{} \
\mu (t^{}-R)
\end
You can't use 'macro parameter character #' in math modeThe [[#Average delay per costumer]] is the total delay dived by the total amount of customers served during 1 cycle, $n'$, where $n' = \lambda(R+G)$.
You can't use 'macro parameter character #' in math modeIn the particular case that $\frac{\lambda}{\mu} = \frac{G}{R+G}$, we have an 🖋 Edit in Excalidraw%% Now the 🖋 Edit in Excalidraw%% Now the [[#Average delay per costumer]] can be obtained as:
\overline{w} = \frac{W}
You can't use 'macro parameter character #' in math mode ### Overly Saturated system In **Overly saturated** systems, *NOT all* the costumers that arrive at the traffic light when it's red are served. Some will have to wait for the next cycle. In this scenario, the queue keeps growing. ![Overly saturated system - 02 - Fundamentals fo Queuing Theory - OMT 2024-11-17 16.09.14.excalidraw.png](/img/user/Universit%C3%A0/Magistrale/1%C2%B0%20Anno/Operation%20&%20Management%20of%20Transport%20Systems/Notes/Allegati/Overly%20saturated%20system%20-%2002%20-%20Fundamentals%20fo%20Queuing%20Theory%20-%20OMT%202024-11-17%2016.09.14.excalidraw.png) %%🖋 Edit in Excalidraw%% In this case it's not possible to define a unique servers before exiting the system. We call $n$ the number of servers. ``` For simplicity, we now consider a system of 3 servers: ![02 - Fundamentals fo Queuing Theory - OMT 2024-11-17 16.20.39.excalidraw.png](/img/user/Universit%C3%A0/Magistrale/1%C2%B0%20Anno/Operation%20&%20Management%20of%20Transport%20Systems/Notes/Allegati/02%20-%20Fundamentals%20fo%20Queuing%20Theory%20-%20OMT%202024-11-17%2016.20.39.excalidraw.png) %%🖋 Edit in Excalidraw%% In the specific case shown in the figure above, the arrival and departure rates are related as follows:
\lambda > \mu_{2} > \mu_
You can't use 'macro parameter character #' in math modeLet's get to a more realistic case, where the arrival curve is actually 🖋 Edit in Excalidraw%% Also in this case, the following condition is true:
\mu_{1} > \mu_{2} > \mu_
Missing open brace for subscriptThe purple area, is the total cumulated delay for service 3. That is, the delay of all passengers between service 2 and service 3. The total delay in the system would be the total area included between $\color{red} V(t)$ and $\color{orange} D(t)$. ```ad-note title: What's the best way to improve the system In general, it's to improve the service rate of the slowest server. In this case, $\mu_{3}$ is the smallest rate. The first course of action should be to improve this one. This can only be improved to the point $\mu_{3} = \mu_{2}$. After that, both need to be improved at the same time, otherwise the faster server doesn't actually allow for less queueing. ___ It is **NOT** recommended to design a system so that $\mu_{1}=\mu_{2} = \cdots = mu_{n}$. Designing like this would mean assuming there will not be queues. If, for whatever reason, one server happened to be slower than the others (or one is faster), the system wouldn't be able to accomodate these people. ``` ### Diverging systems A particular case of a servers. ## Stochastic queuing ❗❗❗❗❗❗❗❗❗❗❗❗ ❗❗❗ COMPLETARE ❗❗❗ ❗❗❗❗❗❗❗❗❗❗❗❗ ### Relaxation time ## Centralisation A queuing system with $n$ 🖋 Edit in Excalidraw%% ```ad-Teo title: Centralisation is better than decentralised A centralised system require less resources to offer the same level of service (or equivalently, with the same resources centralised systems provide better level of service). ___ *Proof* The resources ($R_{C}, R_{D}$) needed to serve the system at a given level of service will be proportional to the fluctuations experienced by the demand. We can characterize these fluctuations with the Standard Deviation of the arrival rates ($\sigma_{A}$). The 2 statement are therefore true: $ R_{C} \propto \sigma_{A}; \qquad R_{D} \propto \sum\limits_{i=1}^{n}\sigma_{a} = n \sigma_{a} $ We can relate the standard deviation of the single decentralized queues ($\sigma_{a}$) to that of the centralized one ($\sigma_{A}$). Remember that, by definition $ \sigma_{i} = \sqrt{\text{Var}{(i)}} $ Remember also that the Variance is a linear operator: $ \text{Var}(nA+B) = n\text{Var}(A) + \text{Var}(B) $ In our case: $ \text{Var}(A) = \text{Var}\left(\sum\limits_{i=1}^{n}a \right) = n \text{Var}(a) $ Applying the square root at both members of the equation: $ \begin{align} \sqrt{\text{Var}(A)} &= \sqrt{n \text{Var}(a)} \\ \sigma_{A} &= \sqrt{n}\sigma_{a} \end{align} $ Therefore, if the resources are proportional to the variances: $ R_{D} \propto n \sigma_{a} = n \frac{\sigma_{A}}{\sqrt{n}} = \sqrt{n}\sigma_{A} \propto \sqrt{n} R_{C} $ The conclusion is: $ R_{D} \propto \sqrt{n}R_{C} $ Given that $\sqrt{n} \ge 1$, this means that the resources for a decentralized system are always greater than those for a centralized one. *q.e.d.* ``` ## Optimisation In a transportation system, there are always at least the two following costs to keep in mind: - $Z_A:$ **Operator or Agency cost:** costs undergone by the operator of the transportation system (investments, operation, ...) - $Z_{u}:$ **User cost:** costs undergone by the users using the system (tickets, time, delays,...) The optimal level of service is obtained when the total cost is minimized. ![Optimization introduction diagram - 02 - Fundamentals fo Queuing Theory - OMT 2024-11-17 19.16.46.excalidraw.png](/img/user/Universit%C3%A0/Magistrale/1%C2%B0%20Anno/Operation%20&%20Management%20of%20Transport%20Systems/Notes/Allegati/Optimization%20introduction%20diagram%20-%2002%20-%20Fundamentals%20fo%20Queuing%20Theory%20-%20OMT%202024-11-17%2019.16.46.excalidraw.png) %%🖋 Edit in Excalidraw%% We have an optimisation problem, where the objective function is:
Z_{tot} = Z_{A} + Z_
\min_\mu Z = \min_\mu (Z_{A}+ Z_{u})
\frac{\partial Z}{\partial \mu} \stackrel{!}{=}0
You can't use 'macro parameter character #' in math modeand solving for $\mu$. ```ad-example Optimization example Imagine we have a bus service that we want to optimize. It means we want to define what is the best headway, $h$. The headway is the *decision variable*. To solve the problem, we need to define the agency and the user costs. **Agency costs:** - $\beta:$ Cost of operating 1 bus for 1 day (includes everything) - $\frac{C}{h}:$ Number of buses in use ($C=$ cycle time) The total agency cost is: $ Z_{A} = \frac{\beta C}{h} $ **User costs:** - $\overline{w}:$ headway, $h$. The headway is the *decision variable*. To solve the problem, we need to define the agency and the user costs. **Agency costs:** - $\beta:$ Cost of operating 1 bus for 1 day (includes everything) - $\frac{C}{h}:$ Number of buses in use ($C=$ cycle time) The total agency cost is: $ Z_{A} = \frac{\beta C}{h} $ **User costs:** - $\overline{w}:$ [[#Average delay per costumer]] - $\alpha:$ Value of time $\left[ \frac{\text{EURO}}{h} \right]$ ($\sim 15$ €/h in Barcelona) - $\lambda:$ Demand rate (daily demand) $ Z_{u} = \lambda \overline{w} \alpha = \lambda \frac{h}{2 }\alpha $ The graphs below show both the shape of the 2 cost function, and why the average delay is equal to $\frac{h}{2}$. ![02 - Fundamentals fo Queuing Theory - OMT 2024-11-17 19.29.05.excalidraw.png](/img/user/Universit%C3%A0/Magistrale/1%C2%B0%20Anno/Operation%20&%20Management%20of%20Transport%20Systems/Notes/Allegati/02%20-%20Fundamentals%20fo%20Queuing%20Theory%20-%20OMT%202024-11-17%2019.29.05.excalidraw.png) The objective function is therefore: $ \min_{h} \left( \beta C\frac{1}{h} + \frac{1}{2}\lambda\alpha h \right) $ We calculate the first derivative: $ \frac{\partial Z}{\partial h} = -\beta C \frac{1}{h^{2}} + \frac{1}{2} \lambda \alpha \stackrel{!}{=}0 $ from which we get: $ \begin{align} -\beta C \frac{1}{h^{2}} + \frac{1}{2} \lambda \alpha &\stackrel{!}{=}0 \\ \frac{1}{2} \lambda \alpha &= \beta C \frac{1}{h^{2}} \\ \frac{1}{2} \lambda \alpha h^{2} &= \beta C \\ h^{2} = \frac{\beta C}{\frac{1}{2}\lambda \alpha} \end{align} $ which ultimately becomes: $ h = \sqrt{\frac{2\beta C}{\lambda \alpha }} $ ``` ## Psychology ❗❗❗❗❗❗❗❗❗❗❗❗ ❗❗❗ COMPLETARE ❗❗❗ ❗❗❗❗❗❗❗❗❗❗❗❗