ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.msk.model
Class RouterManager

java.lang.Object
  extended by umontreal.iro.lecuyer.contactcenters.msk.model.RouterManager

public class RouterManager
extends Object

Manages the creation of the router as well as the data structures containing routing information. This class provides the necessary facility to read and validate routing tables stored in RouterParams instances, construct missing routing tables according to the rules specified in RouterParams, and create the appropriate Router instance used for simulation.


Constructor Summary
RouterManager(CallCenter cc, RouterParams par)
          Constructs a new router manager using the call center model cc, and the router's parameters par.
 
Method Summary
static void addRouterFactory(RouterFactory rf)
          Registers the router factory rf for router managers.
 void clearRegionMap()
          Clears the internal region map used by initTypeRegions() and initGroupRegions().
protected  Router createRouter(RouterParams par)
          Constructs and returns the router to be managed.
 double[][] getDelaysGT()
          Returns the currently used group-to-type delays matrix.
 int[] getGroupRegions()
          Returns the currently used group regions.
 int[][] getGroupToTypeMap()
          Returns the currently used group-to-type map.
 boolean[][] getIncidenceMatrixGT()
          Returns the currently used group-to-type incidence matrix.
 boolean[][] getIncidenceMatrixTG()
          Returns the currently used type-to-group incidence matrix.
 Map<String,Object> getProperties()
           
 double[] getQueueWeights()
          Returns the currently used queue weights vector.
 double[][] getRanksGT()
          Returns the currently used group-to-type matrix of ranks.
 SortedMap<Double,double[][]> getRanksGTDelay()
          Returns a map giving the auxiliary matrices of ranks with associated minimal waiting times.
 double[][] getRanksTG()
          Returns the currently used type-to-group matrix of ranks.
 String getRegion(int id)
          Returns the region name corresponding to region identifier id.
 int getRegion(String regStr)
          Returns the region identifier corresponding to the region name regStr.
 Router getRouter()
          Returns a reference to the router managed by this object.
 CallCenterRoutingStageInfo[][] getRoutingStages()
           
 int getSkillCount(int i)
          Returns the skill count for agent group i, i.e., the number of call types agents in this group can serve.
 int[] getSkillCounts()
          Returns the currently used skill counts.
 int[] getTypeRegions()
          Returns the currently used type regions vector.
 int[][] getTypeToGroupMap()
          Returns the currently used type-to-group map.
 double[][] getWeightsGT()
          Returns the currently used group-to-type matrix of weights.
 double[][] getWeightsTG()
          Returns the currently used type-to-group matrix of weights.
 void init()
           
 void initAgentsPrefBased(RouterParams par, AgentsPrefRouter router1)
          Initializes an agents preference-based router using the parameters par.
 void initDelays(RouterParams par)
          Initializes the matrix of delays from the router's parameters par.
 void initGroupRegions()
          Initializes the agent group region identifiers used by the local-specialist routing policy.
 void initGroupToTypeMap(RouterParams par)
          Initializes the group-to-type map from the router parameters par, or constructs a new group-to-type map from other information if RouterParams.getRoutingTableSources() defines the groupToTypeMap attribute.
 void initIncidenceMatrixGT(RouterParams par)
          Initializes the group-to-type incidence matrix from the router parameters par, or constructs a new group-to-type incidence matrix from other information if RouterParams.getRoutingTableSources() defines the incidenceMatrixGT attribute.
 void initIncidenceMatrixTG(RouterParams par)
          Initializes the type-to-group incidence matrix from the router parameters par, or constructs a new type-to-group incidence matrix from other information if RouterParams.getRoutingTableSources() defines the incidenceMatrixTG attribute.
 void initQueueWeights(RouterParams par)
          Initializes the queue weights using the router's parameters par.
 void initRanksGT(RouterParams par)
          Initializes the group-to-type matrix of ranks from the router parameters par, or constructs a new group-to-type matrix of ranks from other information if RouterParams.getRoutingTableSources() defines the ranksGT attribute.
 void initRanksGTUpdate(RouterParams par)
          Initializes the auxiliary group-to-type matrix of ranks associated with minimal waiting times.
 void initRanksTG(RouterParams par)
          Initializes the type-to-group matrix of ranks from the router parameters par, or constructs a new type-to-group matrix of ranks from other information if RouterParams.getRoutingTableSources() defines the ranksTG attribute.
 void initSkillCounts(RouterParams par)
          Initializes the skill counts using the router's parameters par.
 void initStages(RouterParams par)
          Initializes the routing stages for the overflow-and-priority routing policy from parameters in par.
 void initTypeRegions()
          Initializes the call type region identifiers used by the local-specialist routing policy.
 void initTypeToGroupMap(RouterParams par)
          Initializes the type-to-group map from the router parameters par, or constructs a new type-to-group map from other information if RouterParams.getRoutingTableSources() defines the typeToGroupMap attribute.
 void initWeightsGT(RouterParams par)
          Initializes the group-to-type matrix of weights using the router's parameters par.
 void initWeightsTG(RouterParams par)
          Initializes the type-to-group matrix of weights using the router's parameters par.
 void setDelaysGT(double[][] delaysGT)
          Sets the group-to-type delays matrix to delaysGT.
 void setGroupRegions(int[] groupRegions)
          Sets the currently used group regions to groupRegions.
 void setGroupToTypeMap(int[][] groupToTypeMap)
          Sets the group-to-type map to groupToTypeMap.
 void setIncidenceMatrixGT(boolean[][] incidenceMatrixGT)
          Sets the group-to-type incidence matrix to incidenceMatrixGT.
 void setIncidenceMatrixTG(boolean[][] incidenceMatrixTG)
          Sets the type-to-group incidence matrix to incidenceMatrixTG.
 void setQueueWeights(double[] queueWeights)
          Sets the vector of queue weights to queueWeights.
 void setRanksGT(double[][] ranksGT)
          Sets the group-to-type matrix of ranks to ranksGT.
 void setRanksTG(double[][] ranksTG)
          Sets the type-to-group matrix of ranks to ranksTG.
 void setRouter(Router router)
          Sets the managed router to router.
 void setSkillCounts(int[] skillCounts)
          Sets the currently used skill counts to skillCounts.
 void setTypeRegions(int[] typeRegions)
          Sets the vector of type regions to typeRegions.
 void setTypeToGroupMap(int[][] typeToGroupMap)
          Sets the currently used type-to-group map to typeToGroupMap.
 void setWeightsGT(double[][] weightsGT)
          Sets the group-to-type matrix of weights to weightsGT.
 void setWeightsTG(double[][] weightsTG)
          Sets the type-to-group matrix of weights to weightsTG.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RouterManager

public RouterManager(CallCenter cc,
                     RouterParams par)
              throws RouterCreationException
Constructs a new router manager using the call center model cc, and the router's parameters par.

Parameters:
cc - the call center model.
par - the router's parameters.
Throws:
RouterCreationException - if a problem occurs during the construction of the router.
Method Detail

getRouter

public Router getRouter()
Returns a reference to the router managed by this object.

Returns:
the managed router.

setRouter

public void setRouter(Router router)
Sets the managed router to router.

Parameters:
router - the new managed router.

getProperties

public Map<String,Object> getProperties()

initTypeToGroupMap

public void initTypeToGroupMap(RouterParams par)
Initializes the type-to-group map from the router parameters par, or constructs a new type-to-group map from other information if RouterParams.getRoutingTableSources() defines the typeToGroupMap attribute. This method does nothing if a type-to-group map was already constructed. The obtained type-to-group map can be accessed through getTypeToGroupMap() after this method succeeds, and an illegal-argument exception is thrown if this method fails.

Parameters:
par - the router's parameters.

initGroupToTypeMap

public void initGroupToTypeMap(RouterParams par)
Initializes the group-to-type map from the router parameters par, or constructs a new group-to-type map from other information if RouterParams.getRoutingTableSources() defines the groupToTypeMap attribute. This method does nothing if a group-to-type map was already constructed. The obtained group-to-type map can be accessed through getGroupToTypeMap() after this method succeeds, and an illegal-argument exception is thrown if this method fails.

Parameters:
par - the router's parameters.

initRanksTG

public void initRanksTG(RouterParams par)
Initializes the type-to-group matrix of ranks from the router parameters par, or constructs a new type-to-group matrix of ranks from other information if RouterParams.getRoutingTableSources() defines the ranksTG attribute. This method does nothing if a type-to-group matrix of ranks was already constructed. The obtained matrix can be accessed through getRanksTG() after this method succeeds, and an illegal-argument exception is thrown if this method fails.

Parameters:
par - the router's parameters.

initRanksGT

public void initRanksGT(RouterParams par)
Initializes the group-to-type matrix of ranks from the router parameters par, or constructs a new group-to-type matrix of ranks from other information if RouterParams.getRoutingTableSources() defines the ranksGT attribute. This method does nothing if a group-to-type matrix of ranks was already constructed. The obtained matrix can be accessed through getRanksGT() after this method succeeds, and an illegal-argument exception is thrown if this method fails.

Parameters:
par - the router's parameters.

initRanksGTUpdate

public void initRanksGTUpdate(RouterParams par)
Initializes the auxiliary group-to-type matrix of ranks associated with minimal waiting times. This method does nothing if no ranksGTUpdate elements is given in par. These matrices can be retrieved using the getRanksGTDelay() method.

Parameters:
par - the router's parameters.

initWeightsTG

public void initWeightsTG(RouterParams par)
Initializes the type-to-group matrix of weights using the router's parameters par. If no such matrix is defined, a matrix filled with 1's is created. An illegal-argument exception is thrown if any error occurs during the construction and validation of the matrix of weights. The matrix can be accessed using the getWeightsTG() method if this method succeeds.

Parameters:
par - the router's parameters.

initWeightsGT

public void initWeightsGT(RouterParams par)
Initializes the group-to-type matrix of weights using the router's parameters par. If no such matrix is defined in par, one is initialized from the queue weights. An illegal-argument exception is thrown if any error occurs during the construction and validation of the matrix of weights. The matrix can be accessed using the getWeightsGT() method if this method succeeds.

Parameters:
par - the router's parameters.

initDelays

public void initDelays(RouterParams par)
Initializes the matrix of delays from the router's parameters par. If no matrix of delays is defined in par, this method creates a I×K matrix filled with 0's. The constructed matrix can be accessed using getDelaysGT().

Parameters:
par - the router's parameters.

initQueueWeights

public void initQueueWeights(RouterParams par)
Initializes the queue weights using the router's parameters par. If no queue weights are specified in par, this method creates a vector of queue weights using the weights associated with each call type. The queue weights can be accessed using the getQueueWeights() method if this method succeeds.

Parameters:
par - the router's parameters.

initIncidenceMatrixTG

public void initIncidenceMatrixTG(RouterParams par)
Initializes the type-to-group incidence matrix from the router parameters par, or constructs a new type-to-group incidence matrix from other information if RouterParams.getRoutingTableSources() defines the incidenceMatrixTG attribute. This method does nothing if a type-to-group incidence matrix was already constructed. The obtained matrix can be accessed through getIncidenceMatrixTG() after this method succeeds, and an illegal-argument exception is thrown if this method fails.

Parameters:
par - the router's parameters.

initIncidenceMatrixGT

public void initIncidenceMatrixGT(RouterParams par)
Initializes the group-to-type incidence matrix from the router parameters par, or constructs a new group-to-type incidence matrix from other information if RouterParams.getRoutingTableSources() defines the incidenceMatrixGT attribute. This method does nothing if a group-to-type incidence matrix was already constructed. The obtained matrix can be accessed through getIncidenceMatrixGT() after this method succeeds, and an illegal-argument exception is thrown if this method fails.

Parameters:
par - the router's parameters.

initSkillCounts

public void initSkillCounts(RouterParams par)
Initializes the skill counts using the router's parameters par. If no skill count is specified in par, the skill counts are initialized from agent groups' skillCount attribute. If the skill count is not specified explicitly for at least one agent group, the group-to-type incidence matrix is initialized and used to count the number of call types accessible for this agent group.

Parameters:
par - the router's parameters.

getRoutingStages

public CallCenterRoutingStageInfo[][] getRoutingStages()

initStages

public void initStages(RouterParams par)
Initializes the routing stages for the overflow-and-priority routing policy from parameters in par. This method does nothing if the stages, returned by the getRoutingStages() method, are already initialized. Otherwise, it processes parameters in par to initialize the stages.

Parameters:
par - the routing parameters.

createRouter

protected Router createRouter(RouterParams par)
                       throws RouterCreationException
Constructs and returns the router to be managed. This method uses RouterParams.getRouterPolicy() to get a type identifier for the router's policy. It then retrieves parameters and initializes a router specific to the given type. If the name of the policy corresponds to a constant in RouterPolicyType, the method handles its construction directly. Otherwise, it queries every factory registered using addRouterFactory(RouterFactory) until it gets one capable of creating the policy. If no such factory exists, it uses the ServiceLoader class to find a router policy factory dynamically. If that last step fails, the method throws a router-creation exception.

Parameters:
par - the parameters of the router.
Returns:
the constructed router.
Throws:
RouterCreationException - if an error occurs during the construction.

addRouterFactory

public static void addRouterFactory(RouterFactory rf)
Registers the router factory rf for router managers. If the user-specified router policy does not correspond to a predefined policy, the registered factories are queried to find one capable of creating a router. This method must be called before the call-center simulator is initialized.

Parameters:
rf - the new router factory to register.

initAgentsPrefBased

public void initAgentsPrefBased(RouterParams par,
                                AgentsPrefRouter router1)
Initializes an agents preference-based router using the parameters par. This method sets the score type for contact and agent selection as well as random streams for randomized selections if it is enabled.

Parameters:
par - the router's parameters.
router1 - the router object.

getRegion

public String getRegion(int id)
Returns the region name corresponding to region identifier id. This must be called after initTypeRegions() or initGroupRegions(), and throws a NoSuchElementException if no region name has been associated with the given identifier.

Parameters:
id - the region identifier.
Returns:
the corresponding region name.
Throws:
NoSuchElementException - if no region name is associated with the corresponding region identifier.

getRegion

public int getRegion(String regStr)
Returns the region identifier corresponding to the region name regStr. This method must be called only after initTypeRegions() or initGroupRegions(), and throws a NoSuchElementException if no identifier is associated with regStr.

Parameters:
regStr - the tested region name.
Returns:
the corresponding region identifier.
Throws:
NoSuchElementException - if no region identifier is associated with the given region name.

clearRegionMap

public void clearRegionMap()
Clears the internal region map used by initTypeRegions() and initGroupRegions(). After this method is called, it is not possible to get the region name corresponding to the region identifiers.


initTypeRegions

public void initTypeRegions()
Initializes the call type region identifiers used by the local-specialist routing policy. This method obtains a region name for each call type, and maps each identical name to the same integer. At the end of this process, the array returned by getTypeRegions() associates a region identifier to each call type.

The region name of a call type is computed as follows. First, the call type factory is obtained using CallCenter.getCallFactory(int). If the properties returned by CallFactory.getProperties() contains a property named region, its value is used as the region string. Otherwise, the name of the call type, returned by CallFactory.getName(), is split using the semicolon as a delimiter, and the region corresponds to the string following the semicolon.


initGroupRegions

public void initGroupRegions()
Initializes the agent group region identifiers used by the local-specialist routing policy. This method obtains a region name for each agent group, and maps each identical name to the same integer. At the end of this process, the array returned by getGroupRegions() associates a region identifier to each call type.

The region name of an agent group is computed as follows. First, the agent group manager is obtained using CallCenter.getAgentGroupManager(int). If the properties returned by getProperties() contains a property named region, its value is used as the region string. Otherwise, the name of the call type, returned by getName(), is split using the semicolon as a delimiter, and the region corresponds to the string following the semicolon.


getGroupToTypeMap

public int[][] getGroupToTypeMap()
Returns the currently used group-to-type map. If initGroupToTypeMap(RouterParams) or setGroupToTypeMap(int[][]) were never called, this method returns null. Otherwise, this method returns an array of I arrays giving an order list of call types for each agent group.

Returns:
the currently used group-to-type map.

setGroupToTypeMap

public void setGroupToTypeMap(int[][] groupToTypeMap)
Sets the group-to-type map to groupToTypeMap.

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

getIncidenceMatrixGT

public boolean[][] getIncidenceMatrixGT()
Returns the currently used group-to-type incidence matrix. If initIncidenceMatrixGT(RouterParams) or setIncidenceMatrixGT(boolean[][]) were never called, this method returns null. Otherwise, this returns a I×K incidence matrix.

Returns:
the currently used group-to-type incidence matrix.

setIncidenceMatrixGT

public void setIncidenceMatrixGT(boolean[][] incidenceMatrixGT)
Sets the group-to-type incidence matrix to incidenceMatrixGT.

Parameters:
incidenceMatrixGT - the group-to-type incidence matrix.

getIncidenceMatrixTG

public boolean[][] getIncidenceMatrixTG()
Returns the currently used type-to-group incidence matrix. If initIncidenceMatrixTG(RouterParams) or setIncidenceMatrixTG(boolean[][]) were never called, this method returns null. Otherwise, this returns a K×I incidence matrix.

Returns:
the currently used type-to-group incidence matrix.

setIncidenceMatrixTG

public void setIncidenceMatrixTG(boolean[][] incidenceMatrixTG)
Sets the type-to-group incidence matrix to incidenceMatrixTG.

Parameters:
incidenceMatrixTG - the type-to-group incidence matrix.

getQueueWeights

public double[] getQueueWeights()
Returns the currently used queue weights vector. If initQueueWeights(RouterParams) or setQueueWeights(double[]) were never called, this method returns null. Otherwise, element k of the returned array gives the weight for contact type k when entering in queue.

Returns:
the vector of queue weights.

setQueueWeights

public void setQueueWeights(double[] queueWeights)
Sets the vector of queue weights to queueWeights.

Parameters:
queueWeights - the new vector of queue weights.

getRanksGT

public double[][] getRanksGT()
Returns the currently used group-to-type matrix of ranks. If initRanksGT(RouterParams) or setRanksGT(double[][]) were never called, this method returns null. Otherwise, it returns a I×K matrix of ranks.

Returns:
the currently used group-to-type matrix of ranks.

setRanksGT

public void setRanksGT(double[][] ranksGT)
Sets the group-to-type matrix of ranks to ranksGT.

Parameters:
ranksGT - the new matrix of ranks.

getRanksGTDelay

public SortedMap<Double,double[][]> getRanksGTDelay()
Returns a map giving the auxiliary matrices of ranks with associated minimal waiting times. Each entry of the returned map has a key giving the minimal waiting time, and a value corresponding to the matrix of ranks. If no auxiliary matrix of ranks were given in routing parameters, this returns an empty map.

Returns:
the map of auxiliary matrices of ranks.

getRanksTG

public double[][] getRanksTG()
Returns the currently used type-to-group matrix of ranks. If initRanksTG(RouterParams) or setRanksTG(double[][]) were never called, this method returns null. Otherwise, it returns a K×I matrix of ranks.

Returns:
the currently used type-to-group matrix of ranks.

setRanksTG

public void setRanksTG(double[][] ranksTG)
Sets the type-to-group matrix of ranks to ranksTG.

Parameters:
ranksTG - the new matrix of ranks.

getSkillCounts

public int[] getSkillCounts()
Returns the currently used skill counts. This method returns null if initSkillCounts(RouterParams) or setSkillCounts(int[]) were never called. Otherwise, it returns an array whose element i gives the skill count for agent group i.

Returns:
the currently used array of skill counts.

getSkillCount

public int getSkillCount(int i)
Returns the skill count for agent group i, i.e., the number of call types agents in this group can serve. This method returns Integer.MAX_VALUE if initSkillCounts(RouterParams) or setSkillCounts(int[]) were never called.

Parameters:
i - the index of the agent group.
Returns:
the skill count.

setSkillCounts

public void setSkillCounts(int[] skillCounts)
Sets the currently used skill counts to skillCounts.

Parameters:
skillCounts - the new skill counts.

getTypeRegions

public int[] getTypeRegions()
Returns the currently used type regions vector. This method returns null if initTypeRegions() or setTypeRegions(int[]) were never called. Otherwise, index k of the returned array gives the region identifier for calls of type k.

Returns:
the vector of type regions.

setTypeRegions

public void setTypeRegions(int[] typeRegions)
Sets the vector of type regions to typeRegions.

Parameters:
typeRegions - the new vector of type regions.

getGroupRegions

public int[] getGroupRegions()
Returns the currently used group regions. This method returns null if initGroupRegions() or setGroupRegions(int[]) were never called. Otherwise, index i of the returned array gives the region identifier for agents in group i.

Returns:
the currently used group regions.

setGroupRegions

public void setGroupRegions(int[] groupRegions)
Sets the currently used group regions to groupRegions.

Parameters:
groupRegions - the new group regions.

getTypeToGroupMap

public int[][] getTypeToGroupMap()
Returns the currently used type-to-group map. If initTypeToGroupMap(RouterParams) or setTypeToGroupMap(int[][]) were never called, this method returns null. Otherwise, it returns an array of K arrays giving an ordered list of agent groups for each call type.

Returns:
the currently used type-to-group map.

setTypeToGroupMap

public void setTypeToGroupMap(int[][] typeToGroupMap)
Sets the currently used type-to-group map to typeToGroupMap.

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

getWeightsGT

public double[][] getWeightsGT()
Returns the currently used group-to-type matrix of weights. If initWeightsGT(RouterParams) or setWeightsGT(double[][]) were never called, this method returns null. Otherwise, it returns a I×K matrix of weights.

Returns:
the currently used group-to-type matrix of weights.

setWeightsGT

public void setWeightsGT(double[][] weightsGT)
Sets the group-to-type matrix of weights to weightsGT.

Parameters:
weightsGT - the new matrix of weights.

getWeightsTG

public double[][] getWeightsTG()
Returns the currently used type-to-group matrix of weights. If initWeightsTG(RouterParams) or setWeightsTG(double[][]) were never called, this method returns null. Otherwise, it returns a K×I matrix of weights.

Returns:
the currently used type-to-group matrix of weights.

setWeightsTG

public void setWeightsTG(double[][] weightsTG)
Sets the type-to-group matrix of weights to weightsTG.

Parameters:
weightsTG - the new matrix of weights.

getDelaysGT

public double[][] getDelaysGT()
Returns the currently used group-to-type delays matrix. If initDelays(RouterParams) or setDelaysGT(double[][]) were never called, this method returns null. Otherwise, it returns a I×K matrix of delays expressed in the default time unit of the simulator.

Returns:
the currently used group-to-type delays matrix.

setDelaysGT

public void setDelaysGT(double[][] delaysGT)
Sets the group-to-type delays matrix to delaysGT.

Parameters:
delaysGT - the new delays matrix.

init

public void init()

ContactCenters
V. 0.9.9.

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