ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.router
Class ExpDelayRouter

java.lang.Object
  extended by umontreal.iro.lecuyer.contactcenters.router.Router
      extended by umontreal.iro.lecuyer.contactcenters.router.ExpDelayRouter
All Implemented Interfaces:
NewContactListener

public class ExpDelayRouter
extends Router

Represents a router using the expected delay to assign agent groups to new contacts. When a contact is routed to an agent group, it is assigned a free agent of this particular group. If all agents in the target group are busy, the contact enters a waiting queue specific to the target agent group. The contact cannot move across waiting queues.

A waiting queue is associated with each agent group i. When a new contact of type k arrives, the router uses the weighted expected delays Ei(t)/$ \wTG$(k, i) for each waiting queue to take its decisions. Here, Ei(t) is a prediction of the waiting time for the new contact arrived at time t if sent to queue i while $ \wTG$(k, i) is a user-defined constant weight determining the importance of contacts of type k for agents in group i. Two decision modes are available: deterministic, or stochastic. In deterministic mode, the router chooses the agent group with the minimal weighted expected delay. In stochastic mode, the router chooses agent group i with probability

pi(t) = $\displaystyle {\frac{{\wTG(k,i)/E_i(t)}}{{\htsum_{j=0}^{I-1} \wTG(k,j)/E_i(t)}}}$

independently of the other contacts. With this formula, the smaller is the weighted expected delay for an agent group i, the higher is the probability of selection of group i. When an agent becomes free, it picks up a new contact from its associated waiting queue only.

Note that the routing of a contact of type k to an agent in group i can be prevented by fixing $ \wTG$(k, i) = 0. Increasing $ \wTG$(k, i) increases the probability of a contact of type k to be routed to an agent in group i.

The expected delay is estimated using a waiting time predictor. The default predictor is the LastWaitingTimePerQueuePredictor which predicts the waiting time using the last observed waiting time before a service.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.contactcenters.router.Router
BLOCKTYPE_CANTQUEUE, BLOCKTYPE_NOLINE, BLOCKTYPE_QUEUEFULL, DEQUEUETYPE_BEGINSERVICE, DEQUEUETYPE_FANTOM, DEQUEUETYPE_NOAGENT, DEQUEUETYPE_TRANSFER, dqTypeRet
 
Constructor Summary
ExpDelayRouter(double[][] weightsTG, RandomStream stream)
          Constructs a new router using expected delays, with a weights matrix weightsTG, a random stream stream.
ExpDelayRouter(double[][] weightsTG, RandomStream stream, WaitingTimePredictor pred)
          Equivalent to ExpDelayRouter(double[][],RandomStream) with a user-defined waiting time predictor pred.
 
Method Summary
 boolean canServe(int i, int k)
          Returns true if and only if some agents in group i are authorized to serve contacts of type k by this router.
protected  void checkWaitingQueues(AgentGroup group)
          This method is called when the agent group group contains no more online agents, i.e., AgentGroup.getNumAgents() returns 0.
 String getDescription()
           
 RandomStream getStreamAgentSelection()
          Returns the random stream used for agent selection.
 WaitingQueueType getWaitingQueueType()
          Returns an indicator describing how the implemented routing policies organizes waiting queues.
 double[][] getWeightsTG()
          Returns the weights matrix defining $ \wTG$(k, i).
 void init()
          This method is called at the beginning of the simulation to reset the state of this router.
protected  EndServiceEvent selectAgent(Contact contact)
          Begins the service of the contact contact by trying to assign it a free agent.
protected  DequeueEvent selectContact(AgentGroup group, Agent agent)
          Returns a dequeue event representing a queued contact to be served by the agent agent in agent group group.
protected  DequeueEvent selectWaitingQueue(Contact contact)
          Selects a waiting queue and puts the contact contact into it.
 void setStreamAgentSelection(RandomStream streamAgentSelection)
          Sets the random stream for agent selection to streamAgentSelection.
 void setWeightsTG(double[][] weightsTG)
          Sets the weights matrix defining $ \wTG$(k, i) to weightsTG.
 String toLongString()
          Returns a string representation of detailed information about the router.
 
Methods inherited from class umontreal.iro.lecuyer.contactcenters.router.Router
addExitedContactListener, agentReroutingEventsIterator, beginService, checkFreeAgents, clearExitedContactListeners, contactReroutingEventsIterator, dequeued, endContact, endService, enqueued, exitBlocked, exitDequeued, exitServed, formatAgentGroups, formatWaitingQueues, getAgentGroup, getAgentGroupListener, getAgentGroups, getAgentReroutingEvents, getContactFactory, getContactReroutingEvents, getCurrentQueueSize, getDialers, getExitedContactListeners, getNeededWaitingQueueComparator, getNeededWaitingQueueStructure, getNumAgentGroups, getNumContactTypes, getNumWaitingQueues, getReroutingDelay, getReroutingDelay, getTotalQueueCapacity, getWaitingQueue, getWaitingQueueListener, getWaitingQueues, isKeepingReroutingEvents, mustClearWaitingQueue, needsDetailedAgentGroup, newContact, notifyBlocked, notifyDequeued, notifyServed, removeExitedContactListener, restore, save, selectAgent, selectContact, selectWaitingQueue, setAgentGroup, setClearWaitingQueue, setClearWaitingQueues, setContactFactory, setKeepingReroutingEvents, setTotalQueueCapacity, setWaitingQueue, startDialers, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpDelayRouter

public ExpDelayRouter(double[][] weightsTG,
                      RandomStream stream)
Constructs a new router using expected delays, with a weights matrix weightsTG, a random stream stream. The K×I weights matrix is used to determine the number of contact types and agent groups while stream determines the mode of the router. If stream is null, the router is in deterministic mode. Otherwise, it is in stochastic mode.

Parameters:
weightsTG - the weights matrix.
stream - the random stream used in stochastic mode.

ExpDelayRouter

public ExpDelayRouter(double[][] weightsTG,
                      RandomStream stream,
                      WaitingTimePredictor pred)
Equivalent to ExpDelayRouter(double[][],RandomStream) with a user-defined waiting time predictor pred.

Parameters:
weightsTG - the weights matrix.
stream - the random stream used in stochastic mode.
pred - the waiting time predictor.
Method Detail

getWaitingQueueType

public WaitingQueueType getWaitingQueueType()
Description copied from class: Router
Returns an indicator describing how the implemented routing policies organizes waiting queues. The supported modes of organization cover the most common cases only: waiting queues corresponding to contact types or agent groups. For any other modes, the WaitingQueueType.GENERAL must be used.

By default, this method returns WaitingQueueType.GENERAL.

Overrides:
getWaitingQueueType in class Router
Returns:
the organization mode of waiting queues.

getWeightsTG

public double[][] getWeightsTG()
Returns the weights matrix defining $ \wTG$(k, i).

Returns:
the weights matrix defining $ \wTG$(k, i).

setWeightsTG

public void setWeightsTG(double[][] weightsTG)
Sets the weights matrix defining $ \wTG$(k, i) to weightsTG.

Parameters:
weightsTG - the new weights matrix defining $ \wTG$(k, i).
Throws:
NullPointerException - if weightsTG is null.
IllegalArgumentException - if weightsTG is not rectangular or has wrong dimensions.

getStreamAgentSelection

public RandomStream getStreamAgentSelection()
Returns the random stream used for agent selection. If the agent selection is not randomized, this returns null.

Returns:
the random stream for agent selection.

setStreamAgentSelection

public void setStreamAgentSelection(RandomStream streamAgentSelection)
Sets the random stream for agent selection to streamAgentSelection. Setting the stream to null disables randomized agent selection.

Parameters:
streamAgentSelection - the new random stream for agent selection.

init

public void init()
Description copied from class: Router
This method is called at the beginning of the simulation to reset the state of this router.

Overrides:
init in class Router

checkWaitingQueues

protected void checkWaitingQueues(AgentGroup group)
Description copied from class: Router
This method is called when the agent group group contains no more online agents, i.e., AgentGroup.getNumAgents() returns 0. It must check each waiting queue accessible for agents in this group to determine if they need to be cleared. A queue is cleared if no agent, whether free or busy, is available to serve any contact in it.

Specified by:
checkWaitingQueues in class Router
Parameters:
group - the agent group with no more agents.

canServe

public boolean canServe(int i,
                        int k)
Description copied from class: Router
Returns true if and only if some agents in group i are authorized to serve contacts of type k by this router.

Specified by:
canServe in class Router
Parameters:
i - the agent group index.
k - the contact type index.
Returns:
determines if contacts can be served.

selectAgent

protected EndServiceEvent selectAgent(Contact contact)
Description copied from class: Router
Begins the service of the contact contact by trying to assign it a free agent. The method must select an agent group with a free agent (or a specific free agent), start the service, and return the end-service event if the service was started, or null otherwise.

Specified by:
selectAgent in class Router
Parameters:
contact - the contact being routed to an agent.
Returns:
the end-service event representing the started service, or null if the contact could not be served immediately.

selectWaitingQueue

protected DequeueEvent selectWaitingQueue(Contact contact)
Description copied from class: Router
Selects a waiting queue and puts the contact contact into it. Returns the dequeue event if the contact could be queued, or null otherwise.

Specified by:
selectWaitingQueue in class Router
Parameters:
contact - the contact being queued.
Returns:
the dequeue event representing the queued contact, or null if the contact could not be queued.

selectContact

protected DequeueEvent selectContact(AgentGroup group,
                                     Agent agent)
Description copied from class: Router
Returns a dequeue event representing a queued contact to be served by the agent agent in agent group group. If agent is null, the method must return a contact that can be served by any agent in the group. If no contact is available, this method returns null. The selected contacts come from waiting queues attached to the router. Before the selected contact is returned, it must be removed from its queue with dequeue type Router.DEQUEUETYPE_BEGINSERVICE, e.g., by using queue.removeFirst (DEQUEUETYPE_BEGINSERVICE), or queue.remove (ev, DEQUEUETYPE_BEGINSERVICE), etc.

Generally, it is sufficient to override this method instead of Router.checkFreeAgents(AgentGroup,Agent). One can override Router.checkFreeAgents(AgentGroup,Agent) to improve efficiency when looking for contacts in the same waiting queue. This method is not abstract and returns null by default in order to allow Router.checkFreeAgents(AgentGroup,Agent) to be overridden without implementing this method.

Overrides:
selectContact in class Router
Parameters:
group - the affected agent group.
agent - the agent having ended its service.
Returns:
the dequeue event representing the contact being selected.

getDescription

public String getDescription()
Overrides:
getDescription in class Router

toLongString

public String toLongString()
Description copied from class: Router
Returns a string representation of detailed information about the router. This returns a string representation of each associated waiting queue and agent group and routing policies. For a short, one-line description, Router.toString() should be used.

Overrides:
toLongString in class Router
Returns:
a string representation of detailed information about the router.

ContactCenters
V. 0.9.9.

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