|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectumontreal.iro.lecuyer.contactcenters.contact.ContactArrivalProcess
public abstract class ContactArrivalProcess
Represents a contact arrival process modeling
the arrival of inbound contacts.
Such a process schedules an event for each new contact, and
broadcasts the arrival to any registered new-contact listeners.
More specifically, a single simulation event manages arrivals as follows:
upon an arrival, a new contact is instantiated using
the associated contact factory, the contact is broadcast to
any registered listener,
and the next arrival is scheduled.
The interarrival times are computed using the nextTime()
method
which needs to be implemented in a concrete subclass.
This abstract class also takes care of new-contact
listeners registration and notification.
Subclasses only needs to define nextTime()
and
optionally init()
which initializes the
arrival process at the beginning of the simulation.
It is also possible to access
the scheduled new-contact event to reschedule or cancel it as needed.
Implementing getArrivalRate(int)
, and getExpectedArrivalRate(int)
is recommended to allow programs to get the arrival rate and expected
arrival rate.
Each arrival process has an associated simulator which
is an instance of the Simulator
class.
This simulator is used
to schedule the event managing the arrival process.
It is also assumed that the user-defined contact factory attaches this
simulator to each new contact.
Failing to meet this condition might lead to unexpected behavior, and
will trigger a failed assertion if assertion checking is turned on during
execution.
The arrival process can be inflated or deflated by
a busyness factor denoted B,
a random variable with mean 1, and usually
generated once for a day.
Any arrival process can be defined as
{N(t), t≥0}, where N(t) is the
number of arrivals during the time interval [0, t).
The process affected by the busyness,
{(t), t≥0},
is given by taking
(t) = round(BN(t)),
where
round(⋅) rounds its argument to the nearest integer.
The exact way to take account of the busyness factor
depends on the specific arrival process.
For example, for Poisson processes, the busyness
is used to inflate or deflate the λ arrival rate.
The busyness factor must be set externally, because the value
of B for this arrival process is often correlated with B for
other arrival processes.
The recommended way to set B is using init(double)
.
The current value of B might be obtained using getBusynessFactor()
.
By default, it is assumed that [B] = 1. If this is not true for
a particular model, one should call
setExpectedBusynessFactor(double)
to set the expectation of the factor.
Note: the NewContactListener
implementations
are notified in the order of the list
returned by getNewContactListeners()
,
and a new-contact listener
modifying the list of listeners by using addNewContactListener(NewContactListener)
or removeNewContactListener(NewContactListener)
could result in
unpredictable behavior.
Field Summary | |
---|---|
protected Event |
contactEvent
Event representing the arrival of a new contact. |
Constructor Summary | |
---|---|
ContactArrivalProcess(ContactFactory factory)
Constructs a new contact arrival process creating contacts using the given factory. |
|
ContactArrivalProcess(Simulator sim,
ContactFactory factory)
Equivalent to ContactArrivalProcess(ContactFactory) ,
with a user-defined simulator sim. |
Method Summary | |
---|---|
void |
addNewContactListener(NewContactListener listener)
Adds the listener listener to be notified when a new contact is produced. |
void |
clearNewContactListeners()
Clears the list of new-contact listeners associated with this contact source. |
double |
getArrivalRate(double st,
double et)
Determines the mean arrival rate in time interval [s, e]. |
double |
getArrivalRate(int p)
Determines the arrival rate in period p for this arrival process. |
void |
getArrivalRates(double[] rates)
Fills the given array rates with the arrival rate for each period. |
double |
getBusynessFactor()
Returns the currently used busyness factor B, which must be greater than or equal to 0, and defaults to 1. |
ContactFactory |
getContactFactory()
Returns a reference to the associated contact factory. |
double |
getExpectedArrivalRate(double st,
double et)
Determines the expected mean arrival rate in time interval [s, e] for this arrival process assuming that the expected value of the busyness factor is 1. |
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. |
double |
getExpectedArrivalRateB(double st,
double et)
Returns the expected mean arrival rate considering the current expected busyness factor. |
double |
getExpectedArrivalRateB(int p)
Returns the expected arrival rate considering the current expected busyness factor. |
void |
getExpectedArrivalRates(double[] rates)
Fills the given array rates with the expected arrival rate for each period. |
void |
getExpectedArrivalRatesB(double[] rates)
Fills the given array rates with the expected arrival rate for each period. |
double |
getExpectedBusynessFactor()
Returns the expected value of the busyness factor for this arrival process. |
String |
getName()
Returns the name associated with this object. |
List<NewContactListener> |
getNewContactListeners()
Returns an unmodifiable list containing all the new-contact listeners registered with this contact source. |
double |
getNextArrivalTime()
Returns the simulation time of the next arrival currently scheduled by this arrival process. |
void |
init()
Initializes the new arrival process. |
void |
init(double b)
Initializes this process with a specific busyness factor B = b. |
boolean |
isStarted()
Determines if the element is enabled or disabled. |
abstract double |
nextTime()
Computes and returns the time before the next contact arrival is simulated by this object. |
void |
notifyNewContact(Contact contact)
Notifies the contact contact to every registered listener. |
void |
removeNewContactListener(NewContactListener listener)
Removes the new-contact listener listener from the list associated with this contact source. |
void |
setBusynessFactor(double b)
Sets the busyness factor to b. |
void |
setContactFactory(ContactFactory factory)
Sets the contact factory to factory. |
void |
setExpectedBusynessFactor(double bMean)
Sets the expected busyness factor for this arrival process to bMean. |
void |
setName(String name)
Sets the name of this object to name. |
void |
setSimulator(Simulator sim)
Sets the simulator attached to this contact source to sim. |
Simulator |
simulator()
Returns a reference to the simulator associated with this contact source. |
void |
start()
Enables the element represented by this object. |
void |
start(double delay)
Starts this arrival process and schedules the first arrival to happen after delay simulation time units, independently of how nextTime()
is implemented. |
void |
startStationary()
Setup the arrival process to be stationary, and starts it using the start()
method. |
void |
stop()
Disables the element represented by this object. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final Event contactEvent
Constructor Detail |
---|
public ContactArrivalProcess(ContactFactory factory)
factory
- the factory creating contacts for this arrival process.
NullPointerException
- if factory is null.public ContactArrivalProcess(Simulator sim, ContactFactory factory)
ContactArrivalProcess(ContactFactory)
,
with a user-defined simulator sim.
sim
- the simulator attached to this arrival process.factory
- the factory creating contacts for this arrival process.
NullPointerException
- if sim or factory are null.Method Detail |
---|
public Simulator simulator()
ContactSource
Any implementation of this interface
should provide a constructor
accepting the simulator as an argument.
Constructors not receiving a simulator
should use the default simulator
returned by Simulator.getDefaultSimulator()
.
simulator
in interface ContactSource
public void setSimulator(Simulator sim)
ContactSource
setSimulator
in interface ContactSource
sim
- the new simulator.public String getName()
Named
getName
in interface Named
public void setName(String name)
Named
UnsupportedOperationException
if the name is read-only.
setName
in interface Named
name
- the new name of the object.public abstract double nextTime()
public double getBusynessFactor()
public void setBusynessFactor(double b)
init()
is called, or one should
use init(double)
.
b
- the new busyness factor.
IllegalArgumentException
- if b
is negative.public double getExpectedBusynessFactor()
public void setExpectedBusynessFactor(double bMean)
bMean
- the new value of the expectation.
IllegalArgumentException
- if bMean is negative.public void init(double b)
setBusynessFactor(double)
followed by
init()
.
b
- the value of the busyness factor.
IllegalArgumentException
- if b ≤ 0.public void init()
init
in interface ContactSource
init
in interface Initializable
public ContactFactory getContactFactory()
public void setContactFactory(ContactFactory factory)
factory
- the new contact factory.
NullPointerException
- if the given contact factory is null.public void addNewContactListener(NewContactListener listener)
ContactSource
addNewContactListener
in interface ContactSource
listener
- the new-contact listener being added.public void removeNewContactListener(NewContactListener listener)
ContactSource
removeNewContactListener
in interface ContactSource
listener
- the new-contact listener being removed.public void clearNewContactListeners()
ContactSource
clearNewContactListeners
in interface ContactSource
public List<NewContactListener> getNewContactListeners()
ContactSource
getNewContactListeners
in interface ContactSource
public void start()
ToggleElement
IllegalStateException
if the element is already enabled.
start
in interface ToggleElement
public void startStationary()
start()
method.
When an arrival process is started using
this method, its parameters do not evolve
with time. This can be useful, e.g., to
simulate a single period as if it was infinite
in the model.
If the arrival process does not
support stationary mode, this
method throws an
unsupported-operation exception.
The default behavior of this method
is to throw this exception.
public void start(double delay)
nextTime()
is implemented. If delay is set to
Double.POSITIVE_INFINITY
, no arrival
is scheduled.
Any subsequent inter-arrival
times will be generated with nextTime()
as usual.
delay
- the first inter-arrival time.public void stop()
ToggleElement
IllegalStateException
if the element is already disabled.
stop
in interface ToggleElement
public boolean isStarted()
ToggleElement
isStarted
in interface ToggleElement
public double getNextArrivalTime()
public double getArrivalRate(int p)
If arrival rate is random, this returns the arrival rate
for the current replication.
One should use getExpectedArrivalRate(int)
or getExpectedArrivalRateB(int)
to get the
expected arrival rate.
If the arrival rate is not available,
throws an UnsupportedOperationException
.
p
- the queried period index.
public void getArrivalRates(double[] rates)
getArrivalRate (p)
.
rates
- the array filled with rates.public double getExpectedArrivalRate(int p)
getArrivalRate(int)
.
If
[B]≠1, one should use
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.
p
- the queried period index.
public void getExpectedArrivalRates(double[] rates)
getExpectedArrivalRate (p)
.
rates
- the array filled with rates.public double getExpectedArrivalRateB(int p)
getExpectedArrivalRate(int)
, and
the value returned by getExpectedBusynessFactor()
.
p
- the tested period.
public void getExpectedArrivalRatesB(double[] rates)
getExpectedArrivalRateB (p)
.
rates
- the array filled with rates.public double getArrivalRate(double st, double et)
If arrival rate is random, this returns the arrival rate
for the current replication.
One should use getExpectedArrivalRate(double,double)
or getExpectedArrivalRateB(double,double)
to get the
expected arrival rate.
This method returns 0 if e≤s.
If the arrival rate is not available,
throws an UnsupportedOperationException
.
This is the default behavior of this
method if not overridden by a subclass.
st
- the starting time s.et
- the ending time e.
public double getExpectedArrivalRate(double st, double et)
getArrivalRate(double,double)
.
If
λ(t) is the arrival rate at time t, this
method returns
If
[B]≠1, one should use
getExpectedArrivalRateB(double,double)
which takes the expectation of the busyness factor into account.
This method returns 0 if e≤s.
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.
st
- the starting time s.et
- the ending time e.
public double getExpectedArrivalRateB(double st, double et)
getExpectedArrivalRate(double,double)
, and
the value returned by getExpectedBusynessFactor()
.
st
- the starting time s.et
- the ending time e.
public String toString()
toString
in class Object
public void notifyNewContact(Contact contact)
contact
- the contact to be notified.
|
ContactCenters V. 0.9.9. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |