public class ErlangA extends Object implements MMcDelay
There can be different service level formulae when in presence of abandonment. We implemented 2 versions of the service level :
getServiceLevel(int, double)
and
getServiceLevel2(int, double)
respectively.
These service level formulas correspond to the service level performance measures
defined in the ContactCenters library:
PerformanceMeasureType.SERVICELEVEL
and PerformanceMeasureType.SERVICELEVEL2
.
This formula assumes a M/M/c/M queueing model such that the arrival, service and patience rates are exponential : λ, μ and ν respectively. The M/M/c/M assumes one call type and one agent group. This queueing model can be analyzed as a stochastic process X(t)∈{0,..., c + q} representing the number of calls in the system at time t and where c + q is maximum number of calls in the system. The number of servers is c and the capacity of the queue is q.
Because of the formula used to compute the service level, the queue capacity is assumed to be finite. Since the computation can increase significantly with the capacity of the queue, we suggest the user to use a capacity proportional to the square-root of the load. Calls are blocked when the system is at full capacity, X(t) = c + q.
The rates at each state are :
λk = | λ, | k = 1, 2,..., c + q - 1 |
μk = | {. |
The exact formula is not computable for heavy traffic system (because of numerical limitations).
The approximation formulas for the delay probability, service level, abandonment probability
and average waiting time for heavy traffic
systems from the paper of Garnett et al. (2002) have been implemented.
These approximations assume an infinite queue capacity.
The users should use these approximations when the exact formulas cannot return a value.
We suggest the user to use these approximations when the load (arrival rate over service rate) is above 500.
For the approximation formulas, the number of servers can take a double
value, as opposed
to the exact formulas.
The queue capacity parameter is not needed for these approximations because they assume infinity queue capacity.
The approximation errors decrease as the load (arrival rate / service rate) increases.
When the load is small, the approximation errors can be significantly large.
Most methods require a non-zero positive patience rate (that is, a finite average patience time).
If the patience rate is 0, we suggest the user to use ErlangC
instead.
Note: all parameters (rate or time) must be given with the same time unit.
Constructor and Description |
---|
ErlangA(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity)
Creates a new instance of ErlangA.
|
Modifier and Type | Method and Description |
---|---|
static double |
getAbandonProb(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
int server)
Returns the probability of abandonment, which also corresponds to the ratio of abandonments.
|
double |
getAbandonProb(int server)
Returns the probability of abandonment, which also corresponds to the ratio of abandonments.
|
static double |
getAbandonProbApprox(double arrivalRate,
double serviceRate,
double patienceRate,
double server)
Returns the approximated abandonment probability.
|
double |
getAbandonProbApprox(int server)
Returns the approximated abandonment probability.
|
static double |
getAverageQueueLength(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
int server)
Returns the average queue length, that is the expected number of customers
waiting in queue.
|
double |
getAverageQueueLength(int server)
Returns the average queue length, that is the expected number of customers
waiting in queue.
|
static double |
getAverageQueueLengthApprox(double arrivalRate,
double serviceRate,
double patienceRate,
double server)
Approximates the average queue length, that is the expected number of customers
in queue.
|
double |
getAverageQueueLengthApprox(int server)
Approximates the average queue length, that is the expected number
of customers in queue.
|
static double |
getAverageWaitTime(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
int server)
Returns the average waiting time.
|
double |
getAverageWaitTime(int server)
Returns the average waiting time.
|
static double |
getAverageWaitTimeApprox(double arrivalRate,
double serviceRate,
double patienceRate,
double server)
Approximates the average waiting time
The formula used is taken from Garnett et al.
|
double |
getAverageWaitTimeApprox(int server)
Approximates the average waiting time of a customer.
|
static double |
getProbDelay(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
int server)
Returns the delay probability that the call will have to wait (or the ratio of
calls that must wait).
|
double |
getProbDelay(int server)
Returns the delay probability that the call will have to wait (or the ratio of
calls that must wait).
|
double |
getProbDelayApprox(double server)
Returns the approximated delay probability that a call will have to wait.
|
static double |
getProbDelayApprox(double arrivalRate,
double serviceRate,
double patienceRate,
double server)
Returns the approximated delay probability that a call will have to wait.
|
static double |
getServiceLevel(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
int server,
double awt)
Returns the service level :
Pr{W <= awt}.
|
double |
getServiceLevel(int server,
double awt)
Returns the service level.
|
static double |
getServiceLevel2(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
int server,
double awt)
Returns the service level :
Pr{W <= awt}, where W is the waiting time of a call.
|
double |
getServiceLevel2(int server,
double awt)
Returns the service level.
|
static double |
getServiceLevelApprox(double arrivalRate,
double serviceRate,
double patienceRate,
double server,
double awt)
Returns the approximated service level :
Pr{W <= awt}.
|
double |
getServiceLevelApprox(int server,
double awt)
Returns the approximated service level :
Pr{W <= awt}, where W is the waiting time
of a call.
|
static double[][] |
getStateProbDist(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
int server)
Returns the mass probability distribution of the states (number of calls) in the queueing system.
|
static void |
main(String[] args)
Evaluates the performance measures using Erlang A.
|
int |
minServer(double awt,
double slTarget)
Returns the minimum number c of servers needed to have a service level of at least slTarget,
using the service level formula SL1 (see the class description).
|
static int |
minServer(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
double awt,
double slTarget)
Returns the minimum number c of servers needed to have a service level of at least slTarget,
using the service level formula SL1 (see the class description).
|
int |
minServer2(double awt,
double slTarget)
Returns the minimum number c of servers needed to have a service level of at least slTarget,
using the service level formula SL2 (see the class description).
|
static int |
minServer2(double arrivalRate,
double serviceRate,
double patienceRate,
int capacity,
double awt,
double slTarget)
Returns the minimum number c of servers needed to have a service level of at least slTarget,
using the service level formula SL2 (see the class description).
|
int |
minServerApprox(double awt,
double slTarget)
Returns the minimum number c of servers needed to have a service level of at least slTarget,
using the approximated service level.
|
static int |
minServerApprox(double arrivalRate,
double serviceRate,
double patienceRate,
double awt,
double slTarget)
Returns the minimum number c of servers needed to have a service level of at least slTarget,
using the approximated service level.
|
static double |
minServerApproxDouble(double arrivalRate,
double serviceRate,
double patienceRate,
double awt,
double slTarget)
Returns the minimum number c of servers, as a continuous variable,
needed to have a service level of at least slTarget.
|
public ErlangA(double arrivalRate, double serviceRate, double patienceRate, int capacity)
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonment (or 1 divided by the average patience time).
This parameter should be greater than 0.capacity
- the queue capacitypublic double getProbDelay(int server)
getProbDelay
in interface MMcDelay
server
- the number of serverspublic static double getProbDelay(double arrivalRate, double serviceRate, double patienceRate, int capacity, int server)
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandons due to impatience (or 1 over the average patience time)capacity
- the capacity of the queue (cannot be negative)server
- the number of serverspublic static double[][] getStateProbDist(double arrivalRate, double serviceRate, double patienceRate, int capacity, int server)
[number of states][2]
.
The number of states is: number of server + queue capacity + 1.
First element is the number of calls in this state, the second element is the mass probability of this state.arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the patience rate (or 1 over the average patience time)capacity
- the capacity of the queue (cannot be negative)server
- the number of serversnull
if it cannot be computedpublic double getProbDelayApprox(double server)
server
- the number of serverspublic static double getProbDelayApprox(double arrivalRate, double serviceRate, double patienceRate, double server)
This method returns an approximation of double, double, int, int)
.
The formula used is taken from Garnett et al. (2002).
This is an approximation formula for heavy traffic systems.
It assumes an unlimited queue capacity.
This approximation should be used when when the exact formula cannot be computed
(because of numerical limitation).
We suggest to use this approximation if the load (arrival rate / service rate) is greater than 500.
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandons due to impatience (or 1 divided by the average patience time).
This parameter must be greater than 0.server
- the number of serverspublic double getServiceLevelApprox(int server, double awt)
server
- the number of serversawt
- the acceptable waiting timepublic static double getServiceLevelApprox(double arrivalRate, double serviceRate, double patienceRate, double server, double awt)
We suggest to use this approximation if the load (arrival rate / service rate) is greater than 500.
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandons (or 1 divided by the average patience time).
This parameter must be greater than 0.server
- the number of serversawt
- the acceptable waiting timepublic double getAbandonProbApprox(int server)
double, double, double)
.
We suggest to use this approximation if the load (arrival rate / service rate) is greater than 500.
server
- the number of serverspublic static double getAbandonProbApprox(double arrivalRate, double serviceRate, double patienceRate, double server)
arrivalRate
- the arrival rate.serviceRate
- the service rate.patienceRate
- the rate of abandonments (or 1 divided by the average patience time).
This parameter must be greater than 0.server
- the number of servers.public double getAverageWaitTimeApprox(int server)
We suggest to use this approximation if the load (arrival rate / service rate) is greater than 500.
server
- the number of serverspublic static double getAverageWaitTimeApprox(double arrivalRate, double serviceRate, double patienceRate, double server)
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonments (or the inverse of patience time)server
- the number of serverspublic double getAverageQueueLengthApprox(int server)
We suggest to use this approximation if the load (arrival rate / service rate) is greater than 500.
server
- the number of serverspublic static double getAverageQueueLengthApprox(double arrivalRate, double serviceRate, double patienceRate, double server)
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonments (or the inverse of patience time)server
- the number of serverspublic double getServiceLevel(int server, double awt)
double, double, int, int, double)
.
The service level formula is
SL1(τ) (see class description).getServiceLevel
in interface MMcDelay
server
- the number of serversawt
- the acceptable waiting timepublic double getServiceLevel2(int server, double awt)
server
- the number of serversawt
- the acceptable waiting timepublic static double getServiceLevel(double arrivalRate, double serviceRate, double patienceRate, int capacity, int server, double awt)
This algorithm is described in the appendix of Avramidis et al. (2009).
The "good" abandonments (the calls that abandoned before waiting awt
) are
excluded from the call count.
This measure of the service level is more consistent with the definition of
SL1(τ)
(see class description) and PerformanceMeasureType.SERVICELEVEL
.
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonment (or 1 divided by the average patience time).
This parameter must be greater than 0.capacity
- the capacity of the queue. If unknown or unlimited, we suggest to give a number
proportional (in the order of) to the square-root of the load.
Selecting a capacity too large (much more than the number of waiting calls) will decrease
the speed of the algorithm.server
- the number of serversawt
- the acceptable waiting timepublic static double getServiceLevel2(double arrivalRate, double serviceRate, double patienceRate, int capacity, int server, double awt)
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonment (or 1 divided by the average patience time).
This parameter must be greater than 0.capacity
- the capacity of the queue. If the queue size is unknown or unlimited, we
suggest to set a value proportional (in the order of) to the square-root of the load.server
- the number of serversawt
- the acceptable waiting timepublic double getAbandonProb(int server)
double, double, int, int)
.server
- the number of serverspublic static double getAbandonProb(double arrivalRate, double serviceRate, double patienceRate, int capacity, int server)
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonment (or 1 divided by the average patience time).capacity
- the capacity of the queue. If the queue size is unknown or unlimited, we
suggest to set a value proportional (in the order of) to the square-root of the load.server
- the number of serverspublic double getAverageWaitTime(int server)
server
- the number of serverspublic static double getAverageWaitTime(double arrivalRate, double serviceRate, double patienceRate, int capacity, int server)
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonments (or 1 divided by the average patience time).
This parameter must be greater than 0.capacity
- the maximum queue size limitserver
- the number of serverspublic double getAverageQueueLength(int server)
server
- the number of serverspublic static double getAverageQueueLength(double arrivalRate, double serviceRate, double patienceRate, int capacity, int server)
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonments (or 1 divided by the average patience time).
This parameter must be greater than 0.capacity
- the maximum queue size limitserver
- the number of serverspublic int minServer(double awt, double slTarget)
public static int minServer(double arrivalRate, double serviceRate, double patienceRate, int capacity, double awt, double slTarget)
double, double, int, int, double)
.
That is :
Note: it calls the function double, double, double, double)
instead if the traffic load (arrival rate / service rate) is greater than 700.
This function uses a binary search.
arrivalRate
- the exponential arrival rateserviceRate
- the exponential service ratepatienceRate
- the rate of abandonments (or 1 divided by the average patience time).
This parameter must be greater than 0.capacity
- the capacity of the queueawt
- the acceptable waiting timeslTarget
- the service level target; it must be in the interval [0, 1], inclusivelypublic int minServer2(double awt, double slTarget)
The method calls double, double, int, double, double)
.
awt
- the acceptable waiting timeslTarget
- the service level target; it must be in the interval [0, 1], inclusivelypublic static int minServer2(double arrivalRate, double serviceRate, double patienceRate, int capacity, double awt, double slTarget)
double, double, int, int, double)
.
That is :
Note: it calls the function double, double, double, double)
instead if the traffic load (arrival rate / service rate) is greater than 700.
This function uses a binary search.
arrivalRate
- the exponential arrival rateserviceRate
- the exponential service ratepatienceRate
- the rate of abandonments (or 1 divided by the average patience time).
This parameter must be greater than 0.capacity
- the capacity of the queueawt
- the acceptable waiting timeslTarget
- the service level target; it must be in the interval [0, 1], inclusivelypublic int minServerApprox(double awt, double slTarget)
If the number of server can be fractional, then we recommend to use
the function double, double, double, double)
.
awt
- the acceptable waiting timeslTarget
- the service level target; it must be in the interval [0, 1]public static int minServerApprox(double arrivalRate, double serviceRate, double patienceRate, double awt, double slTarget)
double, double, double, double)
.
The queue is assumed to have an infinite capacity.
That is:
If the number of server can be fractional, then we recommend to use
the function double, double, double, double)
.
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonments (or 1 divided by the average patience time).
This parameter must be greater than 0.awt
- the acceptable waiting timeslTarget
- the target service level; it must be in the interval [0, 1]public static double minServerApproxDouble(double arrivalRate, double serviceRate, double patienceRate, double awt, double slTarget)
double, double, double, double)
.
That is:
arrivalRate
- the arrival rateserviceRate
- the service ratepatienceRate
- the rate of abandonments (or 1 divided by the average patience time).
This parameter must be greater than 0.awt
- the acceptable waiting timeslTarget
- the target service level; it must be in the interval [0, 1]public static void main(String[] args) throws Exception
<SPAN CLASS="MATH"><</SPAN>arrival rate<SPAN CLASS="MATH">></SPAN> <SPAN CLASS="MATH"><</SPAN>service rate<SPAN CLASS="MATH">></SPAN> <SPAN CLASS="MATH"><</SPAN>patience rate<SPAN CLASS="MATH">></SPAN> <SPAN CLASS="MATH"><</SPAN>number of servers<SPAN CLASS="MATH">></SPAN> <SPAN CLASS="MATH"><</SPAN>awt<SPAN CLASS="MATH">></SPAN> <SPAN CLASS="MATH"><</SPAN>capacity<SPAN CLASS="MATH">></SPAN>
.Exception