ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.contact
Class DirichletArrivalProcess

java.lang.Object
  extended by umontreal.iro.lecuyer.contactcenters.contact.ContactArrivalProcess
      extended by umontreal.iro.lecuyer.contactcenters.contact.PoissonUniformArrivalProcess
          extended by umontreal.iro.lecuyer.contactcenters.contact.DirichletArrivalProcess
All Implemented Interfaces:
ContactSource, Initializable, Named, ToggleElement

public class DirichletArrivalProcess
extends PoissonUniformArrivalProcess

Represents an arrival process where the number of arrivals are spread in periods using a Dirichlet distribution [3]. Let's define the vector of ratios

Q = (Q1,…, QP) = (A1/A,…, AP/A),

where Ap denotes the number of arrivals during main period p and

A = $\displaystyle \htsum_{{p=1}}^{P}$Ap

is the total number of arrivals. The number of arrivals during the preliminary and the wrap-up periods, A0 and AP+1 respectively, are always 0 for this process.

At the beginning of each replication, A is generated from a probability distribution such as gamma. A vector Q is then generated from a Dirichlet distribution [12] with parameters (α1,…, αP). Each component of Q is multiplied with A to get $ \tilde{{\mathbf{A}}}$ before the vector A is obtained by rounding each component of $ \tilde{{\mathbf{A}}}$ to the nearest integer.

Since per-period numbers of arrivals are generated directly rather than through arrival rates, this process does not arise as a Poisson arrival process. However, inter-arrival times are generated as if the Ap* = round(BAp) were Poisson variates. As a result, for each main period, the arrival process generates Ap* uniforms ranging from the beginning to the end of the period, and the uniforms are sorted to get inter-arrival times.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.contactcenters.contact.PoissonUniformArrivalProcess
times
 
Fields inherited from class umontreal.iro.lecuyer.contactcenters.contact.ContactArrivalProcess
contactEvent
 
Constructor Summary
DirichletArrivalProcess(PeriodChangeEvent pce, ContactFactory factory, double[] alphas, RandomStream stream, RandomVariateGen agen)
          Constructs a new Dirichlet arrival process with period-change event pce, contact factory factory, Dirichlet parameters alphas, random number stream stream, and generator agen for the number of arrivals.
 
Method Summary
 double getAlpha(int p)
          Returns the value of the αp parameter for the Dirichlet distribution.
 double getExpectedArrivalRate(int p)
          Determines the expected arrival rate in period p for this arrival process assuming that the expected value of the busyness factor is 1.
static DirichletArrivalProcess getInstanceFromMLE(PeriodChangeEvent pce, ContactFactory factory, RandomStream stream, RandomStream streamArr, Class<? extends Distribution> aDistClass, int[][] arrivals, int numObs, int numPeriods)
          Similar to getInstanceFromMLE(PeriodChangeEvent,ContactFactory,RandomStream,RandomVariateGen,int[][],int,int), but also estimates the parameters for A.
static DirichletArrivalProcess getInstanceFromMLE(PeriodChangeEvent pce, ContactFactory factory, RandomStream stream, RandomVariateGen agen, int[][] arrivals, int numObs, int numPeriods)
          Constructs a new arrival process with Dirichlet parameters estimated by the maximum likelihood method based on the numObs observations in array arrivals.
static double[] getMLE(int[][] arrivals, int numObs, int numPeriods)
          Estimates the Dirichlet parameters of an arrival process from the number of arrivals in the array arrivals.
 RandomVariateGen getNumArrivalsGenerator()
          Returns the random variate generator used for the total number of arrivals A.
 void init()
          Initializes the new arrival process.
 void initWithFixedA(double a)
          Initializes the number of arrivals with a fixed A a.
 void setAlphas(double[] alphas)
          Sets the Dirichlet parameters αp for this object.
 void setNumArrivalsGenerator(RandomVariateGen agen)
          Changes the random variate generator for the number of arrivals to agen.
 void setStream(RandomStream stream)
          Sets the random number stream to stream for generating uniforms.
 String toString()
           
 
Methods inherited from class umontreal.iro.lecuyer.contactcenters.contact.PoissonUniformArrivalProcess
computeArrivalTimes, getArrivalRate, getArrivalRate, getArrivals, getExpectedArrivalRate, getPeriodChangeEvent, getStream, nextTime, setArrivals
 
Methods inherited from class umontreal.iro.lecuyer.contactcenters.contact.ContactArrivalProcess
addNewContactListener, clearNewContactListeners, getArrivalRates, getBusynessFactor, getContactFactory, getExpectedArrivalRateB, getExpectedArrivalRateB, getExpectedArrivalRates, getExpectedArrivalRatesB, getExpectedBusynessFactor, getName, getNewContactListeners, getNextArrivalTime, init, isStarted, notifyNewContact, removeNewContactListener, setBusynessFactor, setContactFactory, setExpectedBusynessFactor, setName, setSimulator, simulator, start, start, startStationary, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DirichletArrivalProcess

public DirichletArrivalProcess(PeriodChangeEvent pce,
                               ContactFactory factory,
                               double[] alphas,
                               RandomStream stream,
                               RandomVariateGen agen)
Constructs a new Dirichlet arrival process with period-change event pce, contact factory factory, Dirichlet parameters alphas, random number stream stream, and generator agen for the number of arrivals.

Parameters:
pce - the period change event.
factory - the contact factory instantiating contacts.
alphas - the parameters of the Dirichlet distribution.
stream - the random number stream for Dirichlet vectors and uniform arrival times.
agen - the random variate generator for the number of arrivals.
Throws:
IllegalArgumentException - if there is not an α value for each main period, or if one α value is negative or 0.
NullPointerException - if one argument is null.
Method Detail

getNumArrivalsGenerator

public RandomVariateGen getNumArrivalsGenerator()
Returns the random variate generator used for the total number of arrivals A.

Returns:
the random variate generator for the total number of arrivals.

setNumArrivalsGenerator

public void setNumArrivalsGenerator(RandomVariateGen agen)
Changes the random variate generator for the number of arrivals to agen.

Parameters:
agen - the new random variate generator for the number of arrivals.
Throws:
NullPointerException - if the parameter is null.

getAlpha

public double getAlpha(int p)
Returns the value of the αp parameter for the Dirichlet distribution.

Parameters:
p - the index of the parameter.
Returns:
the value of the parameter.

setStream

public void setStream(RandomStream stream)
Description copied from class: PoissonUniformArrivalProcess
Sets the random number stream to stream for generating uniforms.

Overrides:
setStream in class PoissonUniformArrivalProcess
Parameters:
stream - the new random number stream.

setAlphas

public void setAlphas(double[] alphas)
Sets the Dirichlet parameters αp for this object.

Parameters:
alphas - a new vector of parameters.
Throws:
IllegalArgumentException - if the length of alphas does not correspond to the number of main periods or if one of the α parameter is negative or 0.
NullPointerException - if alphas is null.

initWithFixedA

public void initWithFixedA(double a)
Initializes the number of arrivals with a fixed A a.

Parameters:
a - the total number of arrivals.
Throws:
IllegalArgumentException - if a is negative or 0.

init

public void init()
Description copied from class: ContactArrivalProcess
Initializes the new arrival process. If this method is overridden by a subclass, it is important to call super.init() in order to ensure that everything is initialized correctly.

Specified by:
init in interface ContactSource
Specified by:
init in interface Initializable
Overrides:
init in class PoissonUniformArrivalProcess

toString

public String toString()
Overrides:
toString in class PoissonUniformArrivalProcess

getExpectedArrivalRate

public double getExpectedArrivalRate(int p)
Description copied from class: ContactArrivalProcess
Determines the expected arrival rate in period p for this arrival process assuming that the expected value of the busyness factor is 1. The arrival rate corresponds to the expected number of arrivals per simulation time unit during the specified period; one must multiply the rate by the period duration to get the expected number of arrivals during the period. If arrival rates are deterministic, this returns the same value as ContactArrivalProcess.getArrivalRate(int).

If $ \E$[B]≠1, one should use ContactArrivalProcess.getExpectedArrivalRateB(int) which takes the expectation of the busyness factor into account.

If the expected arrival rate is not available, throws an UnsupportedOperationException. This is the default behavior of this method if not overridden by a subclass.

Overrides:
getExpectedArrivalRate in class PoissonUniformArrivalProcess
Parameters:
p - the queried period index.
Returns:
the expected arrival rate in that period.

getMLE

public static double[] getMLE(int[][] arrivals,
                              int numObs,
                              int numPeriods)
Estimates the Dirichlet parameters of an arrival process from the number of arrivals in the array arrivals. Element arrivals[i][p] corresponds to the number of arrivals on day i during period p, where i = 0,…, n - 1, and p = 0,…, P - 1, n = numObs, and P = numPeriods. This method computes ρi, p = Xi, p/Yi where Xi, p is the number of arrivals on day i during period p, and Yi is the total number of arrivals during day i. The returned array contains the Dirichlet parameters $ \hat{{\alpha}}_{0}^{}$,…,$ \hat{{\alpha}}_{{P-1}}^{}$ estimated by assuming that the ratios ρi, p follow the Dirichlet distribution.

Parameters:
arrivals - the number of arrivals during each day and period.
numObs - the number of days.
numPeriods - the number of periods.
Returns:
the estimated Dirichlet parameters.

getInstanceFromMLE

public static DirichletArrivalProcess getInstanceFromMLE(PeriodChangeEvent pce,
                                                         ContactFactory factory,
                                                         RandomStream stream,
                                                         RandomVariateGen agen,
                                                         int[][] arrivals,
                                                         int numObs,
                                                         int numPeriods)
Constructs a new arrival process with Dirichlet parameters estimated by the maximum likelihood method based on the numObs observations in array arrivals. Element arrivals[i][p] corresponds to the number of arrivals on day i during period p, where i = 0,…, n - 1, p = 0,…, P - 1, n = numObs, and P = numPeriods. The created arrival process uses the random variate generator agen to generate the total number of arrivals for each day while the Dirichlet parameters are estimated using getMLE(int[][],int,int).

Parameters:
pce - the period-change event marking the end of periods.
factory - the contact factory used to create contacts.
stream - the random stream to generate arrival times.
agen - the random variate generator for A.
arrivals - the number of arrivals.
numObs - the number of days.
numPeriods - the number of periods. parameter is estimated in addition to the arrival rates.
Returns:
the constructed arrival process.

getInstanceFromMLE

public static DirichletArrivalProcess getInstanceFromMLE(PeriodChangeEvent pce,
                                                         ContactFactory factory,
                                                         RandomStream stream,
                                                         RandomStream streamArr,
                                                         Class<? extends Distribution> aDistClass,
                                                         int[][] arrivals,
                                                         int numObs,
                                                         int numPeriods)
Similar to getInstanceFromMLE(PeriodChangeEvent,ContactFactory,RandomStream,RandomVariateGen,int[][],int,int), but also estimates the parameters for A. This method accepts a class object aDistClass which is the guessed probability distribution of A. It uses DistributionFactory to get an instance of the distribution (with estimated parameters), and constructs the arrival process by using this distribution, and the Dirichlet parameters estimated by getMLE(int[][],int,int).

Parameters:
pce - the period-change event marking the end of periods.
factory - the contact factory used to create contacts.
stream - the random stream to generate arrival times.
streamArr - the random stream for A.
aDistClass - the class of the probability distribution of A.
arrivals - the number of arrivals.
numObs - the number of days.
numPeriods - the number of periods. parameter is estimated in addition to the arrival rates.
Returns:
the constructed arrival process.

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.