public class MGAPriorityDelayMin extends Object implements RunTimeLimit
The user can select any of the 3 policies to optimize (alone or together).
The priority routing is generated as follows. For each type-to-group element, there is a "maximum rank" value. To generate the effective rank of group i in call type k, it generates a random value from [0, maximum rank of group i in type k]. Then, it sorts in decreasing order the generated values of all groups that can serve call type k to obtain the priority list. Next, the equality property is generated randomly between each successive group in the list. Thus, the equality property is associated with the position in the preference list and not the actual groups. This is done similarly for the group-to-type ranks.
The delay times and idle agent thresholds are optimized with the MGA, using truncated normal distributions. Negative random values are automatically replaced by 0.
Priority routing is implemented using ranksGT
and ranksTG
.
The user must give as input a call center model with routing policy AGENTSPREF
,
AGENTSPREFWITHDELAYS
or MINIDLEAGENTS
.
Modifier and Type | Class and Description |
---|---|
static class |
MGAPriorityDelayMin.Delays
Represent the delay parameters.
|
static class |
MGAPriorityDelayMin.MinIdleAgents
Represent the minimum idle agent thresholds parameter.
|
static class |
MGAPriorityDelayMin.PriorityRanks
Implements the structure to contain the priority rules.
|
static class |
MGAPriorityDelayMin.Results
Implements the class to contain a routing solution and the cost associated
with this solution.
|
Modifier and Type | Field and Description |
---|---|
protected MGAPriorityDelayMin.Results |
bestResults
To contain the best solution found, or
null if
the optimization has not been executed. |
protected CallCenter |
cc
The call center model, must be the same as the simulator.
|
protected ArrayList<ArrayList<Integer>> |
groupToTypeSkillset
For priority routing: A list of list to represent the skill set of each agent group.
|
protected int[][] |
indexGTList
For priority routing.
|
protected int[][] |
indexTGList
For priority routing.
|
protected double[] |
initDelayGT
Set the initial means and standard deviations of the delay distributions in seconds.
|
protected double |
initMeanDelaySec
Initial mean the delay distribution in seconds (modeled as a normal distribution).
|
protected double |
initMeanMinAgents
Initial mean of the minimum idle agent threshold distribution (modeled as a normal distribution).
|
protected double[] |
initMinAgents
Set the initial means and standard deviations of the minimum number of idle agent
thresholds.
|
protected double[][] |
initProbMaxGT
Same as
initProbMaxTG but for the type-to-group priority ranks. |
protected double[][] |
initProbMaxTG
Set the initial maximal value of the distribution of the type-to-group priority rank
generator.
|
protected double |
initStdDelaySec
Initial standard deviation of the delay distribution in seconds (modeled as a normal distribution).
|
protected double |
initStdMinAgents
Initial standard deviation of the minimum idle agent threshold distribution (modeled as a normal distribution).
|
protected int |
lastRunTimeSec
Saves the execution time in second of the last run.
|
protected boolean |
mgaSmoothing
If true, then perform a linear smoothing when updating the distributions of the parameters
at the end of each iteration of the MGA.
|
protected double |
minMinAgentsStd
The minimum standard deviation when generating the minimum idle agent threshold.
|
protected int |
numGroups
The number of agent groups.
|
protected double |
numNormalRatio
Refer to
AbstractMGAWeightRouting.numNormalRatio . |
protected int |
numTypes
The number of call types.
|
protected RoutingObjectiveFunc |
objFunc
The objective function to minimize.
|
protected boolean |
optimDelay
Decide to optimize the time delays (if true) or not.
|
protected boolean |
optimMinAgents
Decide to optimize the minimum idle agent thresholds (if true) or not.
|
protected boolean |
optimPriority
Decide to optimize the priority ranks (if true) or not.
|
protected int |
optTimeLimitSec
The optimization time limit in seconds.
|
protected double |
priorityEqualSlackProb
The slack probability when generating equal priority rules, and it is used
to avoid too fast convergence.
|
protected boolean |
roundMinIdleAgents
Select to round the idle agent threshold to integer or not.
|
protected RandomStream |
rs
The
RandomStream used by this optimizer. |
protected CallCenterSim |
sim
The call center simulator.
|
protected double |
simRepRatio
Refer to
AbstractMGAWeightRouting.simRepRatio . |
protected ArrayList<ArrayList<Integer>> |
typeToGroupSkillset
For priority routing: A list of list to represent the set of groups that can serve each call type.
|
Constructor and Description |
---|
MGAPriorityDelayMin(CallCenterSim sim,
RoutingObjectiveFunc objFunc)
Constructs the optimizer with the given call center model (simulator) and
objective function to minimize.
|
Modifier and Type | Method and Description |
---|---|
double |
eval(MGAPriorityDelayMin.PriorityRanks pr,
MGAPriorityDelayMin.Delays d,
MGAPriorityDelayMin.MinIdleAgents min) |
void |
exportSolution(String outputFn)
Exports the routing solution into a new call center XML parameter file.
|
protected double[] |
genTruncatedNormal(double[] mean,
double[] std)
Generates independent normal variables with the given means and standard deviations.
|
MGAPriorityDelayMin.Results |
getBestResults()
Returns the best solution found,
bestResults . |
double |
getBestScore()
Get the score of the best solution found
bestResults ,
or null if not optimization run has been executed. |
double |
getInitMeanDelaySec()
Returns the initial mean of the delay distributions in second unit when the user
does not manually initialize the delays with
setInitDelays(double[][]) . |
double |
getInitMeanMinAgents()
Get the initial mean of the idle agent threshold distributions.
|
double |
getInitStdDelaySec()
Returns the initial standard deviation of the delay distributions in second unit if the user
does not manually initialize the delay distributions with
setInitDelays(double[][]) . |
double |
getInitStdMinAgents()
Get the initial standard deviation of the idle agent threshold distributions when
the user does not manually initialize the threshold matrix
with
setInitMinIdleAgents(double[][]) . |
int |
getLastRunTimeSec()
Get the run time in seconds of the last execution.
|
boolean |
getMGASmoothing()
Get the MGA smoothing parameter.
|
double |
getMinMinAgentsStd()
Get the minimum standard deviation for the minimum idle agent generator (when the thresholds
are set to be rounded).
|
boolean |
getOptimDelay()
Return if the algorithm will optimize the delays (true) or not (false).
|
boolean |
getOptimMinAgents()
Return if the algorithm will optimize the minimum idle agent thresholds (true) or not (false).
|
boolean |
getOptimPriority()
Return if the algorithm will optimize the priority ranks (true) or not (false).
|
double |
getPriorityEqualSlackProb()
Get the probability slack for equality when optimizing the priority routing.
|
boolean |
getRoundMinIdleAgents()
Check if the idle agent threshold parameters will be rounded or not.
|
ArrayList<Pair<Integer,Integer>> |
getSkillIndexList()
Get the list representing the order of the elements (group, type) of
the delay and min idle agent parameter vectors.
|
int |
getTimeLimitSec()
Get the time limit in seconds.
|
protected void |
initPriorityGT(double[][] probMaxGT,
double[][] probEqGT)
Initializes the distribution parameters (maximal value of uniform distributions and equality probabilities)
for group-to-type priority rules.
|
protected void |
initPriorityTG(double[][] probMaxTG,
double[][] probEqTG)
Initializes the distribution parameters (maximal value of uniform distributions and equality probabilities)
for type-to-group priority rules.
|
static void |
main(String[] args) |
void |
optimize(int popSize,
int popEliteSize,
int maxIt,
int maxNoImprIt,
double tol)
Executes the modified genetic algorithm (MGA) optimization.
|
static double[] |
roundArray(double[] d)
Returns a new array of doubles where the elements of d have been rounded.
|
void |
setInitDelays(double[][] delaysGT)
Initialize the means and standard deviations of the delay distributions.
|
void |
setInitMeanDelaySec(double d)
Set the initial mean of all delay distributions in second unit.
|
void |
setInitMeanMinAgents(double m)
Sets the initial mean of all idle agent threshold distributions.
|
void |
setInitMinIdleAgents(double[][] minIdleAgentsGT)
Initialize the means of the idle agent threshold distributions.
|
void |
setInitPriority(double[][] ranksTG,
double[][] ranksGT)
Initialize the ranksTG and ranksGT for the optimization.
|
void |
setInitStdDelaySec(double s)
Sets the initial standard deviation of all delay distributions in second unit.
|
void |
setInitStdMinAgents(double s)
Set the initial standard deviation of all idle agent threshold distributions.
|
void |
setMGASmoothing(boolean s)
Set the MGA distribution parameters update smoothing.
|
void |
setMinMinAgentsStd(double d)
Set the minimum standard deviation for the minimum idle agent generator (only
when the thresholds are set to be rounded).
|
void |
setOptimDelay(boolean b)
Select to optimize the delays (true) or not (false).
|
void |
setOptimMinAgents(boolean b)
Select to optimize the minimum idle agent thresholds (true) or not (false).
|
void |
setOptimPriority(boolean b)
Select to optimize the priority ranks (true) or not (false).
|
void |
setPriorityEqualSlackProb(double s)
Set the probability slack for equal priority when optimizing the priority routing,
such that the Bernouilli parameter will be in the interval [s, 1 - s], where
s is the slack value.
|
void |
setRoundMinIdleAgents(boolean s)
Choose if the idle agent threshold parameters should be rounded or not.
|
void |
setTimeLimitSec(int sec)
Set the time limit in seconds.
|
protected boolean |
updateBestResults(MGAPriorityDelayMin.Results r)
Internal method to update the best results found
bestResults
if its score is lower than the current best results. |
protected CallCenter cc
protected CallCenterSim sim
protected RoutingObjectiveFunc objFunc
protected int numTypes
protected int numGroups
protected ArrayList<ArrayList<Integer>> typeToGroupSkillset
numTypes
lists (one for each call type).protected ArrayList<ArrayList<Integer>> groupToTypeSkillset
protected int[][] indexTGList
[numTypes][numGroups]
where
it contains the index of each group in typeToGroupSkillset
, or -1 if
a pair (type, group) is not in the list.protected int[][] indexGTList
[numGroups][numTypes]
where
it contains the index of each call type in groupToTypeSkillset
, or -1 if
a pair (group, type) is not in the list.protected MGAPriorityDelayMin.Results bestResults
null
if
the optimization has not been executed.protected RandomStream rs
RandomStream
used by this optimizer.protected double simRepRatio
AbstractMGAWeightRouting.simRepRatio
.protected double numNormalRatio
AbstractMGAWeightRouting.numNormalRatio
.protected double initMeanDelaySec
protected double initStdDelaySec
protected double initMeanMinAgents
protected double initStdMinAgents
protected double[][] initProbMaxTG
null
, then it will use the initialize all these parameters to equal values.protected double[][] initProbMaxGT
initProbMaxTG
but for the type-to-group priority ranks.protected double[] initDelayGT
initStdDelaySec
.
If null
, then it will initialize all means to initMeanDelaySec
and
the standard deviations are all set to initStdDelaySec
.
protected double[] initMinAgents
protected boolean optimPriority
protected boolean optimDelay
protected boolean optimMinAgents
protected boolean mgaSmoothing
protected double minMinAgentsStd
roundMinIdleAgents
is set to true).
This value is only used when generating the thresholds, and it is not used
in the variance convergence test.
That is, if the threshold of a particular pair (type, group)
is the same for all elite solutions,
then the variance will be 0 in the convergence test.protected boolean roundMinIdleAgents
protected double priorityEqualSlackProb
protected int lastRunTimeSec
protected int optTimeLimitSec
public MGAPriorityDelayMin(CallCenterSim sim, RoutingObjectiveFunc objFunc)
sim
- the call center simulator.objFunc
- the objective function to minimize.public ArrayList<Pair<Integer,Integer>> getSkillIndexList()
public void setOptimPriority(boolean b)
b
- select to optimize the priority ranks or not.public boolean getOptimPriority()
public void setOptimDelay(boolean b)
b
- select to optimize the delays or not.public boolean getOptimDelay()
public void setOptimMinAgents(boolean b)
b
- select to optimize the minimum idle agent thresholds or not.public boolean getOptimMinAgents()
public void setMGASmoothing(boolean s)
s
- set to use update smoothing.public boolean getMGASmoothing()
public void setPriorityEqualSlackProb(double s)
s
- the probability slack value.public double getPriorityEqualSlackProb()
public void setMinMinAgentsStd(double d)
d
- the minimum standard deviation for the minimum idle agent generator.public double getMinMinAgentsStd()
public void setInitMeanDelaySec(double d)
setInitDelays(double[][])
.d
- the initial mean of all delay distributions in second unit.public double getInitMeanDelaySec()
setInitDelays(double[][])
.public void setInitStdDelaySec(double s)
setInitDelays(double[][])
.s
- the initial standard deviation of all delay distributions in second unitpublic double getInitStdDelaySec()
setInitDelays(double[][])
.public void setInitMeanMinAgents(double m)
setInitMinIdleAgents(double[][])
.m
- the initial mean of all idle agent threshold distributions.public double getInitMeanMinAgents()
setInitMinIdleAgents(double[][])
.public void setInitStdMinAgents(double s)
setInitMinIdleAgents(double[][])
.s
- the initial standard deviation of the idle agent threshold distributions.public double getInitStdMinAgents()
setInitMinIdleAgents(double[][])
.public void setRoundMinIdleAgents(boolean s)
s
- choose if the idle agent threshold parameters should be rounded or not.public boolean getRoundMinIdleAgents()
public void setTimeLimitSec(int sec)
RunTimeLimit
setTimeLimitSec
in interface RunTimeLimit
sec
- the time limit in seconds.public int getTimeLimitSec()
RunTimeLimit
getTimeLimitSec
in interface RunTimeLimit
public int getLastRunTimeSec()
RunTimeLimit
getLastRunTimeSec
in interface RunTimeLimit
public void setInitPriority(double[][] ranksTG, double[][] ranksGT)
ranksTG
- the initial ranksTG.ranksGT
- the initial ranksGT.public void setInitDelays(double[][] delaysGT)
initStdDelaySec
.
Give null value to use auto-initialization
with parameters initMeanDelaySec
and initStdDelaySec
.delaysGT
- the initial means and standard deviations of the delay distributions.public void setInitMinIdleAgents(double[][] minIdleAgentsGT)
initStdMinAgents
.
Give null value to use auto-initialization
with parameters initMeanMinAgents
and initStdMinAgents
.minIdleAgentsGT
- the initial means and standard deviations of
the minimum idle agent threshold distributions.protected void initPriorityTG(double[][] probMaxTG, double[][] probEqTG)
Note: this method will modify the array given in parameters.
probMaxTG
- will contain the maximum values of the uniform distributions,
must be initialized as new double[numTypes][] (must contain numTypes
rows).probEqTG
- will contain the probabilities of equality between priority positions,
must be initialized as new double[numTypes][] (must contain numTypes
rows).protected void initPriorityGT(double[][] probMaxGT, double[][] probEqGT)
probMaxGT
- will contain the maximum values of the uniform distributions,
must be initialized as new double[numTypes][].probEqGT
- will contain the probabilities of equality between priority positions,
must be initialized as new double[numTypes][].public void optimize(int popSize, int popEliteSize, int maxIt, int maxNoImprIt, double tol)
popSize
- the population size during one iteration of the MGA.popEliteSize
- the elite population size.maxIt
- the maximum number of iterations of the MGA.maxNoImprIt
- stopping condition: the maximum number of consecutive iterations without improving
the quantile cost (that is, the cost of the most expensive solutin in the elite population).tol
- the convergence tolerance on the maximum standard deviation of the distributions.
The optimization stops when all the standard deviation measures of the elite population is
below this value.public double eval(MGAPriorityDelayMin.PriorityRanks pr, MGAPriorityDelayMin.Delays d, MGAPriorityDelayMin.MinIdleAgents min)
protected double[] genTruncatedNormal(double[] mean, double[] std)
mean
- an array that contains the mean parameter of each variable.std
- an array that contains the standard deviation parameter of each variable.
We set a (automatic) lower bound of 1E-10 on the standard deviation parameter.public static double[] roundArray(double[] d)
d
- the array of doubles to round.protected boolean updateBestResults(MGAPriorityDelayMin.Results r)
bestResults
if its score is lower than the current best results.r
- the results to check.public double getBestScore()
bestResults
,
or null if not optimization run has been executed.public void exportSolution(String outputFn)
outputFn
- the name of XML file to export to.public MGAPriorityDelayMin.Results getBestResults()
bestResults
.