{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "*This notebook contains course material from [CBE40455](https://jckantor.github.io/CBE40455) by\n", "Jeffrey Kantor (jeff at nd.edu); the content is available [on Github](https://github.com/jckantor/CBE40455.git).\n", "The text is released under the [CC-BY-NC-ND-4.0 license](https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode),\n", "and code is released under the [MIT license](https://opensource.org/licenses/MIT).*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "< [Getting Started with SimPy](http://nbviewer.jupyter.org/github/jckantor/CBE40455/blob/master/notebooks/02.01-Getting-Started-with-SimPy.ipynb) | [Contents](toc.ipynb) | [Emergency Room Simulation](http://nbviewer.jupyter.org/github/jckantor/CBE40455/blob/master/notebooks/02.03-Emergency_Room_Simulation.ipynb) >
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Queuing Systems\n",
"\n",
"Queuing systems are a ubiquitous feature of business and engineering applications. Examples exist whereever you find descrete items passing through a system, such as cars through a toll booth, customers in line at a coffee shop, aircraft on a production line, orders at a contract pharmaceuticals manufacturer, patients in an emergency room, phone calls at a call center, ...., well, you get idea. If you are reading these notes at work or in your college dorm room, chances are that you've already dealt with at least one queueing system today.\n",
"\n",
"The generic pattern is \n",
"\n",
" Arrivals ----> Queuing System: Items in queue for processing ----> Departures\n",
"\n",
"This notebook introduces a few basic elements of queuing theory from an empirical perspective. The main elements include simulation methods, the Poisson and Lognormal distributions commonly used to model the random elements of these systems, and Little's Law. Hopefully these tools provide practical insights to phenomenon everyone experiences in everyday life, and form a foundation for detailed modeling of the batch processes encountered in the process industries."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Poisson Processes and Exponential Distributions\n",
"\n",
"Suppose we told that certain events, for example the arrival of customer orders from a web page, occur at an average rate of $\\lambda$ events per unit time. We assume these events are independent from one another, and the process behaves uniformly over time. How can this be modeled for the purpose of simulation? \n",
"\n",
"This is known as a **Poisson process**, one of the most widely studied and useful constructs in statistics and probability theory. Here are a few key facts about Poisson processes:\n",
"\n",
"1. Given a average rate of events $\\lambda$ per unit time, the probability of $n$ events occuring in a period $\\tau$ is given by the [Poisson distribution](https://en.wikipedia.org/wiki/Poisson_distribution) \\begin{align}\\\\ P(n;\\lambda\\tau) & = \\frac{(\\lambda\\tau)^n e^{-\\lambda\\tau}}{n!}\\\\ & \\end{align} This probability distribution has a mean $\\lambda\\tau$ and a standard deviation $\\sqrt{\\lambda\\tau}$.\n",
"\n",
"2. The time between events is given by the Exponential distribution with probability density function \n",
"\\begin{align}\\\\ f^{Exp}_\\lambda(t) & = \\lambda e^{-\\lambda t}\\\\ & \\end{align} This distribution has a mean $\\frac{1}{\\lambda}$ and a standard deviation $\\frac{1}{\\lambda}$.\n",
"\n",
"Knowing the statistical distribution of time between events provides a convenient way to simulate the behavior of Poisson process. Given a average rate $\\lambda$ of events per unit time, the technique is to draw random variables from an exponential distribution, then to wait that period of time before issuing another event."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example: Simulate Customers Arriving at a Known Rate"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}