[Date Index]
[Thread Index]
[Author Index]
Re: a queue
*To*: mathgroup at smc.vnet.net
*Subject*: [mg131753] Re: a queue
*From*: "Dr. Wolfgang Hintze" <weh at snafu.de>
*Date*: Fri, 27 Sep 2013 02:31:32 -0400 (EDT)
*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com
*Delivered-to*: l-mathgroup@wolfram.com
*Delivered-to*: mathgroup-outx@smc.vnet.net
*Delivered-to*: mathgroup-newsendx@smc.vnet.net
*References*: <l1oo3e$j7b$1@smc.vnet.net>
Am Montag, 23. September 2013 08:46:06 UTC+2 schrieb Francisco Gutierrez:
> Dear Friends:
>
> I have a simple queue with the following characteristics:
>
>
>
> First, there is a VERY long list of customers waiting before the system started to operate.
>
> Second, the service rate is better (faster) than the arrivals rate
>
>
>
> I want to calculate the times at which the guys who were in the waiting list before the system started will be served
>
> What should I do?
>
>
>
> mathematica 9.0
>
>
>
> Francisco
The following code (in Version 8, but it should also work in Version 9) gives a simple example of the treatment of the queueing problem with one Server and one queue.
Let us suppose that a customer who has arrived at t=ta will exit from the system (after having been served) at time t=te.
Let the duration of service be s.
Now let's adopt the following strategy: as there is only one server available, the service to a customer starts when the server has finished possible earlier tasks. Assuming furthermore that there is only one queue and adopting the principle first come first serve (which is very natural in this case) we have
te = Max[ta,te']+s
where te' is the exit time of the previous customer. Given ta and s, this formula provides recursively the exit times.
We now make the model explicit by a simulation which uses random variables as follows
ta: the influx of customers is assumed to be a Poisson process, i.e. the time differences dta between consecutive arrivals are exponentially distributed
s: the service time is exponentially distributed
The code then calculates the exit times te.
* start of code *)
a := -Log[Random[]] (* time difference between two consecutive customers *)
s := -4/5 Log[Random[]] (* serivce time *)
dta = Array[a &, 10^2]; (* array of differences of arrival times *)
ta = FoldList[Plus, 0, dta]; (* array of arrival times *)
te = Array[0 &, Length[ta]]; (* array of exit times, initiation *)
Table[te[[i]] = Max[ta[[i]], te[[i - 1]]] + s, {i, 2,
Length[ta]}]; (* calculation of the exit times *)
(* graphis output *)
gta = ListPlot[ta, PlotStyle -> RGBColor[1, 0, 0], ImageSize -> 600,
PlotLabel ->
"Simulation of a queueing system (1 queue, 1 server)\nred : arrival time\n\
black: exit time", DisplayFunction -> Identity];
gte = ListPlot[te + 2, DisplayFunction -> Identity];
Show[Graphics[gta, RGBColor[1, 0, 0]], Graphics[gte],
AxesLabel -> {"Customer", "Times"}, DisplayFunction -> $DisplayFunction]
(* end of code *)
**Follow-Ups**:
**Re: a queue**
*From:* "Dr. Wolfgang Hintze" <weh@snafu.de>
**Re: a queue**
*From:* Francisco Gutierrez <fgutiers2002@yahoo.com>
Prev by Date:
**Re: Helping people on the internet -- was: Re: a simple question**
Next by Date:
**Re: Create a Nasty Password with MATHEMATICA**
Previous by thread:
**a queue**
Next by thread:
**Re: a queue**
| |