ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.router
Class LocalSpecRouter

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

public class LocalSpecRouter
extends AgentsPrefRouter

This router implements the local-specialist policy which tries to assign contacts to agents in the same region and prefers specialists to preserve generalists. This router associates a region identifier with each contact type and agent group. The originating region of a contact is determined by the region identifier associated with its type. The location of agents in an agent group is determined by the region identifier associated with the agent group. This policy is similar to agents' preference-based routing, but it adds a region tie breaker and the rank $ \rGT$(i, k) can be considered as a measurement of the specialty of agents in group i in serving contacts of type k. Often, $ \rTG$(k, i) = $ \rGT$(i, k).

When a new contact arrives, the router applies the same agent selection scheme as the agents' preference-based router, except that only agent groups within the originating region of the contact are accepted as candidates. If the contact cannot be served locally, it is added to a waiting queue corresponding to its type. After the contact spent a certain time in queue, called the overflow delay, the router tries to perform a new agent selection, this time allowing local and remote agents to serve the contact. If the contact can be served remotely, it is removed from the waiting queue before service starts. Otherwise, it stays in queue.

When an agent becomes free, the same contact selection scheme as with the agents' preference-based router is applied, except that a contact can be pulled from a waiting queue only if its originating region is the same as the location of the free agent. In other words, the local waiting queues are queried first. If, after this first pass, the agent is still free, the router performs a second pass which proceeds the same way as agents' preference-based, except that a contact can be pulled from a waiting queue only if it is in the same region as the free agent, or its waiting time is greater than the overflow delay.

Often, $ \rGT$(i, k) = s(i) for each k corresponding to a contact type the agents in group i can serve, and $ \rTG$(k, i) = $ \rGT$(i, k). The function s(i) is the skill count for agent group i, i.e., the number of contact types agents in group i can serve. An agent in group i1 is more specialist than an agent in group i2 if s(i1) < s(i2). With this format of matrix, if an agent becomes free, local waiting queues are queried first and the contact with the longest weighted waiting time is pulled. Moreover, if weights $ \wGT$(i, k) are all set to 1 (the default), only the location of the free agent induces priority for contact selection.


Field Summary
 
Fields inherited from class umontreal.iro.lecuyer.contactcenters.router.AgentsPrefRouter
bestAgent, bestGroup, bestQueue, bestQueuedContact, ranksGT, ranksTG, weightsGT, weightsTG
 
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
LocalSpecRouter(int[] typeRegion, int[] groupRegion, double overflowDelay, double[][] ranksGT)
          Constructs a local-specialist router with contact type region identifiers typeRegion, agent group region identifiers groupRegion, overflow delay overflowDelay, and contact selection ranks matrix ranksGT.
LocalSpecRouter(int[] typeRegion, int[] groupRegion, double overflowDelay, double[][] ranksTG, double[][] ranksGT)
          Constructs a local-specialist router with contact type region identifiers typeRegion, agent group region identifiers groupRegion, overflow delay overflowDelay, agent selection ranks matrix ranksTG, and contact selection ranks matrix ranksGT.
LocalSpecRouter(int[] typeRegion, int[] groupRegion, double overflowDelay, double[][] ranksTG, double[][] ranksGT, double[][] weightsTG, double[][] weightsGT)
          Constructs a local-specialist router with contact type region identifiers typeRegion, agent group region identifiers groupRegion, overflow delay overflowDelay, agent selection ranks matrix ranksTG, and contact selection ranks matrix ranksGT.
LocalSpecRouter(int[] typeRegion, int[] groupRegion, double overflowDelay, int[] skillCounts, boolean[][] m)
          Constructs a local-specialist router with contact type region identifiers typeRegion, agent group region groupRegion, overflow delay overflowDelay, skill counts skillCounts, and incidence matrix m.
 
Method Summary
protected  boolean checkFreeAgents(AgentGroup group, Agent agent)
          This method is called when the agent agent in agent group group becomes free.
 String getDescription()
           
 int getGroupRegion(int i)
          Returns the region identifier for agent group i.
 int[][] getGroupToTypeMap()
          Computes a group-to-type map from the ranks matrix by calling RoutingTableUtils.getGroupToTypeMap(double[][],int[],int[]), and returns the result.
 double getOverflowDelay()
          Returns the current overflow delay for this router.
protected  double getReroutingDelay(DequeueEvent dqEv, int numReroutings)
          Returns the delay, in simulation time units, after which a queued contact should be rerouted.
protected  double getScoreForAgentSelection(Contact ct, AgentGroup testGroup, Agent testAgent)
          Returns the score for contact ct associated with agent group testGroup and agent testAgent.
protected  double getScoreForContactSelection(AgentGroup group, DequeueEvent ev)
          Returns the score for the association between the agent group group and the queued contact represented by ev.
 int getTypeRegion(int k)
          Returns the region identifier for contact type k.
 int[][] getTypeToGroupMap()
          Computes a type-to-group map from the ranks matrix by calling RoutingTableUtils.getTypeToGroupMap(double[][],int[],int[]), and returns the result.
protected  EndServiceEvent selectAgent(Contact ct)
          Begins the service of the contact contact by trying to assign it a free agent.
protected  EndServiceEvent selectAgent(DequeueEvent dqEv, int numReroutings)
          Selects an agent for serving a queued contact in the context of rerouting.
 void setGroupRegion(int i, int r)
          Sets the region identifier for agent group i to r.
 void setOverflowDelay(double overflowDelay)
          Sets the overflow delay to overflowDelay.
 void setTypeRegion(int k, int r)
          Sets the region identifier for contact type k to r.
 String toLongString()
          Returns a string representation of detailed information about the router.
 
Methods inherited from class umontreal.iro.lecuyer.contactcenters.router.AgentsPrefRouter
canServe, checkWaitingQueues, getAgentSelectionScore, getContactSelectionScore, getRankForAgentSelection, getRankForContactSelection, getRankGT, getRanksGT, getRanksTG, getRankTG, getStreamAgentSelection, getStreamContactSelection, getWaitingQueueType, getWeightGT, getWeightsGT, getWeightsTG, getWeightTG, needsDetailedAgentGroup, selectAgent, selectContact, selectWaitingQueue, selectWaitingQueue, setAgentSelectionScore, setContactSelectionScore, setRanksGT, setRanksTG, setStreamAgentSelection, setStreamContactSelection, setWeightsGT, setWeightsTG
 
Methods inherited from class umontreal.iro.lecuyer.contactcenters.router.Router
addExitedContactListener, agentReroutingEventsIterator, beginService, 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, getTotalQueueCapacity, getWaitingQueue, getWaitingQueueListener, getWaitingQueues, init, isKeepingReroutingEvents, mustClearWaitingQueue, newContact, notifyBlocked, notifyDequeued, notifyServed, removeExitedContactListener, restore, save, 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

LocalSpecRouter

public LocalSpecRouter(int[] typeRegion,
                       int[] groupRegion,
                       double overflowDelay,
                       int[] skillCounts,
                       boolean[][] m)
Constructs a local-specialist router with contact type region identifiers typeRegion, agent group region groupRegion, overflow delay overflowDelay, skill counts skillCounts, and incidence matrix m. The rank function $ \rGT$(i, k) is set to skillCounts[i] if m[i][k] is true and otherwise while $ \rTG$(k, i) = $ \rGT$(i, k). The incidence matrix has one row per agent group and one column per contact type; the boolean m[i][k] determines if an agent group i can serve a contact type k. If skillCounts is null, the skill count for agent group i is determined by counting the number of k values for which m[i][k] is true. The weights matrices are initialized with 1's.

Parameters:
typeRegion - the contact type region identifiers.
groupRegion - the agent group region identifiers.
overflowDelay - the delay before overflow is allowed.
skillCounts - the number of skills for each agent group.
m - the incidence matrix.
Throws:
NullPointerException - if typeRegion, groupRegion, or m are null.
IllegalArgumentException - if the overflow delay is negative or the incidence matrix is non rectangular.

LocalSpecRouter

public LocalSpecRouter(int[] typeRegion,
                       int[] groupRegion,
                       double overflowDelay,
                       double[][] ranksGT)
Constructs a local-specialist router with contact type region identifiers typeRegion, agent group region identifiers groupRegion, overflow delay overflowDelay, and contact selection ranks matrix ranksGT. The agent selection ranks matrix is generated by transposing the contact selection matrix. The weights matrices are initialized with 1's.

Parameters:
typeRegion - the contact type region identifiers.
groupRegion - the agent group region identifiers.
overflowDelay - the delay before overflow is allowed.
ranksGT - the matrix giving the $ \rGT$(i, k) function.
Throws:
NullPointerException - if typeRegion, groupRegion, or ranks are null.
IllegalArgumentException - if the overflow delay is negative.

LocalSpecRouter

public LocalSpecRouter(int[] typeRegion,
                       int[] groupRegion,
                       double overflowDelay,
                       double[][] ranksTG,
                       double[][] ranksGT)
Constructs a local-specialist router with contact type region identifiers typeRegion, agent group region identifiers groupRegion, overflow delay overflowDelay, agent selection ranks matrix ranksTG, and contact selection ranks matrix ranksGT. The weights matrices are initialized with 1's.

Parameters:
typeRegion - the contact type region identifiers.
groupRegion - the agent group region identifiers.
overflowDelay - the delay before overflow is allowed.
ranksTG - the matrix giving the $ \rTG$(k, i) function.
ranksGT - the matrix giving the $ \rGT$(i, k) function.
Throws:
NullPointerException - if typeRegion, groupRegion, or ranks are null.
IllegalArgumentException - if the overflow delay is negative.

LocalSpecRouter

public LocalSpecRouter(int[] typeRegion,
                       int[] groupRegion,
                       double overflowDelay,
                       double[][] ranksTG,
                       double[][] ranksGT,
                       double[][] weightsTG,
                       double[][] weightsGT)
Constructs a local-specialist router with contact type region identifiers typeRegion, agent group region identifiers groupRegion, overflow delay overflowDelay, agent selection ranks matrix ranksTG, and contact selection ranks matrix ranksGT. The weights matrices are set to weightsTG, and weightsGT.

Parameters:
typeRegion - the contact type region identifiers.
groupRegion - the agent group region identifiers.
overflowDelay - the delay before overflow is allowed.
ranksTG - the matrix giving the $ \rTG$(k, i) function.
ranksGT - the matrix giving the $ \rGT$(i, k) function.
weightsTG - the weights matrix defining $ \wTG$(k, i).
weightsGT - the weights matrix defining $ \wGT$(i, k).
Throws:
NullPointerException - if typeRegion, groupRegion, ranks or weights matrices are null.
IllegalArgumentException - if the overflow delay is negative.
Method Detail

getOverflowDelay

public double getOverflowDelay()
Returns the current overflow delay for this router.

Returns:
the current overflow delay.

setOverflowDelay

public void setOverflowDelay(double overflowDelay)
Sets the overflow delay to overflowDelay.

Parameters:
overflowDelay - the new overflow delay.
Throws:
IllegalArgumentException - if the overflow delay is negative.

getTypeRegion

public int getTypeRegion(int k)
Returns the region identifier for contact type k.

Parameters:
k - the contact type identifier.
Returns:
the associated region identifier.
Throws:
ArrayIndexOutOfBoundsException - if k is negative or greater than or equal to the number of contact types.

setTypeRegion

public void setTypeRegion(int k,
                          int r)
Sets the region identifier for contact type k to r.

Parameters:
k - the contact type identifier.
r - the new region identifier.
Throws:
ArrayIndexOutOfBoundsException - if k is negative or greater than or equal to the number of contact types.

getGroupRegion

public int getGroupRegion(int i)
Returns the region identifier for agent group i.

Parameters:
i - the agent group identifier.
Returns:
the associated region identifier.
Throws:
ArrayIndexOutOfBoundsException - if i is negative or greater than or equal to the number of agent groups.

setGroupRegion

public void setGroupRegion(int i,
                           int r)
Sets the region identifier for agent group i to r.

Parameters:
i - the agent group identifier.
r - the new region identifier.
Throws:
ArrayIndexOutOfBoundsException - if i is negative or greater than or equal to the number of agent groups.

getTypeToGroupMap

public int[][] getTypeToGroupMap()
Computes a type-to-group map from the ranks matrix by calling RoutingTableUtils.getTypeToGroupMap(double[][],int[],int[]), and returns the result.

Overrides:
getTypeToGroupMap in class AgentsPrefRouter
Returns:
the computed type-to-group map.

getGroupToTypeMap

public int[][] getGroupToTypeMap()
Computes a group-to-type map from the ranks matrix by calling RoutingTableUtils.getGroupToTypeMap(double[][],int[],int[]), and returns the result.

Overrides:
getGroupToTypeMap in class AgentsPrefRouter
Returns:
the computed group-to-type map.

selectAgent

protected EndServiceEvent selectAgent(Contact ct)
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.

Overrides:
selectAgent in class AgentsPrefRouter
Parameters:
ct - 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.

selectAgent

protected EndServiceEvent selectAgent(DequeueEvent dqEv,
                                      int numReroutings)
Description copied from class: Router
Selects an agent for serving a queued contact in the context of rerouting. The event dqEv is used to represent the dequeued contact, while numReroutingsDone indicates the number of reroutings that has happened so far. The method should return the end-service event corresponding to the contact's new service by an agent, or null for the contact to stay in queue.

Overrides:
selectAgent in class Router
Parameters:
dqEv - the dequeue event representing the queued contact.
numReroutings - the number of preceding reroutings.
Returns:
the end-service event, or null.

getReroutingDelay

protected double getReroutingDelay(DequeueEvent dqEv,
                                   int numReroutings)
Description copied from class: Router
Returns the delay, in simulation time units, after which a queued contact should be rerouted. The value of numReroutingsDone gives the number of preceding reroutings, and dqEv is the dequeue event. If this delay is negative, infinite, or NaN, no rerouting happens for the contact. numReroutings will be -1 when this method is called at the time the contact is queued. By default, this method returns Double.POSITIVE_INFINITY.

Overrides:
getReroutingDelay in class Router
Parameters:
dqEv - the dequeue event representing the queued contact.
numReroutings - the number of reroutings so far.
Returns:
the rerouting delay.

checkFreeAgents

protected boolean checkFreeAgents(AgentGroup group,
                                  Agent agent)
Description copied from class: Router
This method is called when the agent agent in agent group group becomes free. If the given agent is null, the method assumes that one or more arbitrary agents in the group became free. The method must select a contact to be transferred to the free agent. The selected contacts come from waiting queues, and must be removed from the queues with dequeue type Router.DEQUEUETYPE_BEGINSERVICE before they are transferred to agents. The method returns true if and only if at least one free agent could be made busy.

The default implementation calls Router.selectContact(AgentGroup,Agent) to get a new dequeue event representing the removed contact, extracts the contact, and routes it to an agent, until group has no more free agent.

Overrides:
checkFreeAgents in class Router
Parameters:
group - the affected agent group.
agent - the agent having ended its service.
Returns:
true if some free agents became busy, false otherwise.

getScoreForAgentSelection

protected double getScoreForAgentSelection(Contact ct,
                                           AgentGroup testGroup,
                                           Agent testAgent)
Description copied from class: AgentsPrefRouter
Returns the score for contact ct associated with agent group testGroup and agent testAgent. When selecting an agent for contact ct, if there are several agent groups with the same minimal rank, the agent group with the greatest score is selected. Returning a negative infinite score prevents an agent group from being selected. The default AgentsPrefRouter.selectAgent(Contact,double,boolean[],int) method calls this method with testAgent = null if testGroup is not an instance of DetailedAgentGroup, otherwise the method is called with testAgent = testGroup.getLongestIdleAgent().

By default, this returns a score depending on the return value of AgentsPrefRouter.getAgentSelectionScore(). This can return the longest weighted idle time (the default), the weighted number of free agents, or the weight only. See AgentSelectionScore for more information.

Overrides:
getScoreForAgentSelection in class AgentsPrefRouter
Parameters:
ct - the contact being assigned an agent.
testGroup - the tested agent group.
testAgent - the tested agent, can be null.
Returns:
the score given to the association between the contact and the agent.

getScoreForContactSelection

protected double getScoreForContactSelection(AgentGroup group,
                                             DequeueEvent ev)
Description copied from class: AgentsPrefRouter
Returns the score for the association between the agent group group and the queued contact represented by ev. If contacts can be pulled from several waiting queues with the same minimal rank, the router takes the contact with the greatest score. A negative infinite score prevents a contact from being dequeued.

By default, this returns a score depending on the return value of AgentsPrefRouter.getContactSelectionScore(). This can return the weighted waiting time (the default), the weighted number of queued agents, or the weight only. See ContactSelectionScore for more information.

Overrides:
getScoreForContactSelection in class AgentsPrefRouter
Parameters:
group - the agent group to which pulled contacts would be assigned.
ev - the dequeue event.
Returns:
the assigned score.

getDescription

public String getDescription()
Overrides:
getDescription in class AgentsPrefRouter

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 AgentsPrefRouter
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.