ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.router
Class QueueAtLastGroupRouter

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

public class QueueAtLastGroupRouter
extends Router

This router uses a queue-at-last-group policy. When a new contact of type k arrives, the serving agent is selected the same way as with queue priority routing policy: each agent group ik, 0, ik, 1,… of the type-to-group map is tested to find a free agent. However, if no agent can serve the contact, the contact is put into a waiting queue associated with the last agent group in the ordered list rather than the contact type. As usual, if the router's queue capacity is exceeded, the contact is blocked. When an agent requests a new contact to be served, it looks into its associated waiting queue only. If no contact is available in that queue, the agent remains free. The loss-delay approximation, presented in [2], assumes that the contact center uses this policy.


Field Summary
static int DELAY
          Agent group is a delay station; see isDelay(int, int).
static int LOSS
          Agent group is a loss station; see isLoss(int, int).
static int LOSSDELAY
          Agent group is a loss and delay station.
static int NONE
          Agent group which is neither loss nor delay.
protected  int[][] typeToGroupMap
          Contains the type-to-group map routing table.
 
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
QueueAtLastGroupRouter(int numGroups, int[][] typeToGroupMap)
          Constructs a new queue at last group router with a type-to-group map typeToGroupMap.
 
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 formatTypeToGroupMap()
          Calls RoutingTableUtils.formatTypeToGroupMap(int[][]) with the type-to-group map associated with this router.
 int getAgentGroupType(int i)
          Returns the type of the agent group i regarding all contact types.
 int getAgentGroupType(int k, int i)
          Determines the type of agent group i for contacts of type k.
 String getDescription()
           
 int[][] getTypeToGroupMap()
          Returns the type-to-group map associated with this router.
 int[] getTypeToGroupMap(int k)
          Returns the ordered list concerning contact type k in the type-to-group map.
 WaitingQueueType getWaitingQueueType()
          Returns an indicator describing how the implemented routing policies organizes waiting queues.
 boolean isDelay(int k, int i)
          Determines if the agent group i is a delay station regarding the contact type k, i.e., it queues contacts of type k if it cannot serve them immediately.
 boolean isLoss(int k, int i)
          Determines if the agent group i is a loss station regarding the contact type k, i.e., it forwards contacts of type k it cannot serve immediately to other agent groups in the system, without queueing them.
 boolean isLossDelay(int i)
          Determines if the agent group i is a loss/delay station, i.e., it queues some contacts it cannot serve while forwarding some other contacts to other agent groups.
 boolean isPureDelay(int i)
          Determines if the agent group i is a pure delay station, i.e., it queues all contacts it cannot serve immediately.
 boolean isPureLoss(int i)
          Determines if the agent group i is a pure loss station, i.e., it forwards all contacts to another agent group.
protected  EndServiceEvent selectAgent(Contact ct)
          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 ct)
          Selects a waiting queue and puts the contact contact into it.
 void setTypeToGroupMap(int[][] tg)
          Sets the type-to-group map associated with this router to tg.
 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, init, 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
 

Field Detail

NONE

public static final int NONE
Agent group which is neither loss nor delay.

See Also:
Constant Field Values

LOSS

public static final int LOSS
Agent group is a loss station; see isLoss(int, int).

See Also:
Constant Field Values

DELAY

public static final int DELAY
Agent group is a delay station; see isDelay(int, int).

See Also:
Constant Field Values

LOSSDELAY

public static final int LOSSDELAY
Agent group is a loss and delay station.

See Also:
Constant Field Values

typeToGroupMap

protected int[][] typeToGroupMap
Contains the type-to-group map routing table.

Constructor Detail

QueueAtLastGroupRouter

public QueueAtLastGroupRouter(int numGroups,
                              int[][] typeToGroupMap)
Constructs a new queue at last group router with a type-to-group map typeToGroupMap.

Parameters:
numGroups - the number of agent groups.
typeToGroupMap - the type-to-group map.
Method Detail

getTypeToGroupMap

public int[][] getTypeToGroupMap()
Returns the type-to-group map associated with this router.

Returns:
the associated type-to-group map.

getTypeToGroupMap

public int[] getTypeToGroupMap(int k)
Returns the ordered list concerning contact type k in the type-to-group map.

Parameters:
k - the index of the contact type.
Returns:
the ordered list.

setTypeToGroupMap

public void setTypeToGroupMap(int[][] tg)
Sets the type-to-group map associated with this router to tg.

Parameters:
tg - the new type-to-group map.

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.

getAgentGroupType

public int getAgentGroupType(int k,
                             int i)
Determines the type of agent group i for contacts of type k. This returns LOSS if the group is a loss station, i.e., isLoss(int, int) returns true, DELAY if it is a delay station (isDelay(int, int) returns true), and NONE otherwise.

Parameters:
k - the contact type.
i - the agent group.
Returns:
the status of agent group for the contact type.
Throws:
IndexOutOfBoundsException - if i or k are negative, i is greater than or equal to Router.getNumAgentGroups() or k is greater than or equal to Router.getNumContactTypes().

isLoss

public boolean isLoss(int k,
                      int i)
Determines if the agent group i is a loss station regarding the contact type k, i.e., it forwards contacts of type k it cannot serve immediately to other agent groups in the system, without queueing them. If the group is not in the ordered list for the contact type or if the group appears at the end of the ordered list, this returns false. Otherwise, this returns true.

Parameters:
k - the contact type identifier being tested.
i - the agent group identifier being tested.
Returns:
true if the agent group is a loss station.
Throws:
IndexOutOfBoundsException - if i or k are negative, i is greater than or equal to Router.getNumAgentGroups() or k is greater than or equal to Router.getNumContactTypes().

isDelay

public boolean isDelay(int k,
                       int i)
Determines if the agent group i is a delay station regarding the contact type k, i.e., it queues contacts of type k if it cannot serve them immediately. If the group is at the last position in the ordered list for the contact type k, this returns true. Otherwise, this returns false.

Parameters:
k - the contact type identifier being tested.
i - the agent group identifier being tested.
Returns:
true if the agent group is a delay station.
Throws:
IndexOutOfBoundsException - if i or k are negative, i is greater than or equal to Router.getNumAgentGroups() or k is greater than or equal to Router.getNumContactTypes().

getAgentGroupType

public int getAgentGroupType(int i)
Returns the type of the agent group i regarding all contact types. This returns LOSS if the group is a pure loss station (isPureLoss(int) returns true), DELAY if it is a pure delay station (isPureDelay(int) returns true), LOSSDELAY for a loss/delay station (isLossDelay(int) returns true), and NONE otherwise.

Parameters:
i - the agent group being tested.
Returns:
the type of the tested agent group.
Throws:
ArrayIndexOutOfBoundsException - if i is negative or greater than or equal to Router.getNumAgentGroups().

isPureLoss

public boolean isPureLoss(int i)
Determines if the agent group i is a pure loss station, i.e., it forwards all contacts to another agent group.

Parameters:
i - the agent group identifier being tested.
Returns:
true if the agent group is a pure loss station, false otherwise.
Throws:
ArrayIndexOutOfBoundsException - if i is negative or greater than or equal to Router.getNumAgentGroups().

isPureDelay

public boolean isPureDelay(int i)
Determines if the agent group i is a pure delay station, i.e., it queues all contacts it cannot serve immediately.

Parameters:
i - the agent group identifier being tested.
Returns:
true if the agent group is a pure delay station, false otherwise.
Throws:
ArrayIndexOutOfBoundsException - if i is negative or greater than or equal to Router.getNumAgentGroups().

isLossDelay

public boolean isLossDelay(int i)
Determines if the agent group i is a loss/delay station, i.e., it queues some contacts it cannot serve while forwarding some other contacts to other agent groups.

Parameters:
i - the agent group identifier being tested.
Returns:
true if the agent group is a loss/delay station, false otherwise.
Throws:
ArrayIndexOutOfBoundsException - if i is negative or greater than or equal to Router.getNumAgentGroups().

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

Specified by:
selectAgent in class Router
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.

selectWaitingQueue

protected DequeueEvent selectWaitingQueue(Contact ct)
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:
ct - 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.

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.

formatTypeToGroupMap

public String formatTypeToGroupMap()
Calls RoutingTableUtils.formatTypeToGroupMap(int[][]) with the type-to-group map associated with this router.

Returns:
the type-to-group map, formatted as a string.

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.