public class TestSimulator extends Object implements CuttingPlaneTest
Modifier and Type | Field and Description |
---|---|
protected CallCenter |
cc
The call center model.
|
protected CuttingPlaneParams |
cutp
The cutting-plane parameters.
|
protected ContactCenterEval |
eval
The call center evaluator (by simulation or approximation).
|
protected int |
evalCount
The total number of simulations executed, by calling
evalNumAgents() and evalStaffing(int[]) . |
protected int |
evalTimeSec
The total execution time taken by the simulations.
|
protected int[] |
numAgents
The current staffing vector.
|
protected int |
numGroups
The number of agent groups in this call center.
|
protected int |
numTypes
The number of call type in this call center.
|
protected int |
subgEvalCount
The number of subgradients estimated for the global SL or for every call types.
|
protected boolean |
verbose |
Constructor and Description |
---|
TestSimulator(ContactCenterEval eval,
CallCenter cc,
CuttingPlaneParams cutParams)
Constructs the TestSimulator that will call the simulator.
|
Modifier and Type | Method and Description |
---|---|
DoubleMatrix2D |
evalNumAgents()
Evaluates the service level (SL) of the staffing vector set with
CuttingPlaneTest.setNumAgents(int[]) . |
protected DoubleMatrix2D |
evalStaffing(int[] staffing)
Calls the simulator to evaluate the given staffing.
|
protected SubgradientInfo |
generateGlobalSubg(int[] staffing,
DoubleMatrix2D sl,
int subStep)
Generates and returns the subgradient for the global service level.
|
protected SubgradientInfo |
generatePerCallSubg(int[] staffing,
DoubleMatrix2D sl,
int subStep)
Generates and returns the subgradient of the service level per call type.
|
protected SubgradientInfo |
generateSubg(int[] numAgents,
DoubleMatrix2D sl)
Generates and returns the subgradients, it can be for global or per call type.
|
CallCenter |
getCallCenter()
Returns the call center model.
|
int |
getEvalCount()
Returns the number simulation calls.
|
int |
getEvalTimeSeconds()
Returns the total time spent in simulation in seconds.
|
double |
getMinSLH()
Returns the service level (SL) of the call type that has the worst
unsatisfied SL for the cut generation by heuristic.
|
int |
getMinSLIndexH()
Returns the index of the call type that has the worst unsatisfied SL
for the cut generation by heuristic.
|
int |
getMinSLIndexS()
Returns the index of the call type that has the worst unsatisfied SL for
the cut generation by subgradients.
|
double |
getMinSLS()
Returns the service level (SL) of the call type that has the worst unsatisfied SL for
the cut generation by subgradient.
|
DoubleMatrix2D |
getServiceLevel()
Returns the service level of the last solution vector
evaluated with
CuttingPlaneTest.evalNumAgents() , or
null if no staffing has yet been evaluated. |
int |
getSubgEvalCount()
Returns the number of subgradient approximated.
|
SubgradientInfo |
getSubgradientInfo()
Returns the subgradient for the global service level (SL) or for each call type, or
null if no subgradient is needed. |
boolean |
isFeasible()
Checks if the service level matrix returned by
CuttingPlaneTest.getServiceLevel() is
feasible (satisfies all service level targets). |
boolean |
needsCuts()
Evaluates the current staffing vector set by
setNumAgents(int[]) , and
checks if the problem still needs linear cuts (heuristic or subgradient type). |
static void |
printServiceLevel(DoubleMatrix2D sl)
Prints the service level (SL) per call type and the global SL.
|
void |
setNumAgents(int[] numAgents)
Sets a new staffing vector (performs deep copy).
|
void |
setVerbose(boolean verbose)
Prints information to screen.
|
protected final CallCenter cc
protected final CuttingPlaneParams cutp
protected final ContactCenterEval eval
protected int[] numAgents
protected final int numGroups
protected final int numTypes
protected boolean verbose
protected int evalCount
evalNumAgents()
and evalStaffing(int[])
.protected int evalTimeSec
protected int subgEvalCount
public TestSimulator(ContactCenterEval eval, CallCenter cc, CuttingPlaneParams cutParams)
eval
- the contact center evaluator that can compute the service levelcc
- the call center parameterscutParams
- the parameters of the cutting plane optimizerpublic boolean needsCuts()
setNumAgents(int[])
, and
checks if the problem still needs linear cuts (heuristic or subgradient type).
It checks if the given staffing vector is the optimal solution and if not,
it will generate a cut (either heuristic or subgradient). The conditions for
the cuts are described in the general algorithm of
CuttingPlaneOptimizer
.
The subgradient is computed by finite differences, by adding subStep
number of agents in each group iteratively, and estimating the service level.
needsCuts
in interface CuttingPlaneTest
true
if needs a new cut, otherwise false
(and
the optimal solution has been found)protected DoubleMatrix2D evalStaffing(int[] staffing)
lastNumAgentsSL
.staffing
- the staffing vector to needsCuts1public DoubleMatrix2D evalNumAgents()
CuttingPlaneTest
CuttingPlaneTest.setNumAgents(int[])
.
If this vector was the last vector to be simulated, then this method
will simply return the last simulated SL, and avoid making a useless
call to the simulator.evalNumAgents
in interface CuttingPlaneTest
protected SubgradientInfo generateSubg(int[] numAgents, DoubleMatrix2D sl)
CuttingPlaneParams.pivotPerCallSL
and the global SL target is not met, then this method will compute the subgradient
of the global SL function.
Otherwise, it will compute the subgradients of the SL function per call type.numAgents
- the staffing point to generate subgradientssl
- the current service levelprotected SubgradientInfo generateGlobalSubg(int[] staffing, DoubleMatrix2D sl, int subStep)
staffing
- the staffing point to generate subgradientssl
- the service level with the solution staffing
subStep
- the step length of the subgradientprotected SubgradientInfo generatePerCallSubg(int[] staffing, DoubleMatrix2D sl, int subStep)
staffing
- the staffing point to generate subgradientssl
- the service level with the solution staffing
subStep
- the step length of the subgradientpublic SubgradientInfo getSubgradientInfo()
null
if no subgradient is needed.getSubgradientInfo
in interface CuttingPlaneTest
public int getMinSLIndexH()
CuttingPlaneTest
CuttingPlaneParams.minEachSLH
.
Returns -1
if the SLs of all call types are equal or above
CuttingPlaneParams.minEachSLH.getMinSLIndexH
in interface CuttingPlaneTest
public int getMinSLIndexS()
CuttingPlaneTest
Returns -1 if the SLs of all call types are equal or above their SL targets
getMinSLIndexS
in interface CuttingPlaneTest
public double getMinSLH()
CuttingPlaneTest
CuttingPlaneTest.getMinSLIndexH()
.getMinSLH
in interface CuttingPlaneTest
public double getMinSLS()
CuttingPlaneTest
CuttingPlaneTest.getMinSLIndexH()
.getMinSLS
in interface CuttingPlaneTest
public void setNumAgents(int[] numAgents)
CuttingPlaneTest
setNumAgents
in interface CuttingPlaneTest
numAgents
- the staffing vectorpublic final void setVerbose(boolean verbose)
verbose
- if true
, then prints to screen.public int getEvalCount()
public int getSubgEvalCount()
public int getEvalTimeSeconds()
public DoubleMatrix2D getServiceLevel()
CuttingPlaneTest
CuttingPlaneTest.evalNumAgents()
, or
null
if no staffing has yet been evaluated.getServiceLevel
in interface CuttingPlaneTest
public boolean isFeasible()
CuttingPlaneTest
CuttingPlaneTest.getServiceLevel()
is
feasible (satisfies all service level targets).isFeasible
in interface CuttingPlaneTest
true
if the service level matrix satisfies all targets, otherwise false
public CallCenter getCallCenter()
CuttingPlaneTest
getCallCenter
in interface CuttingPlaneTest
public static void printServiceLevel(DoubleMatrix2D sl)
sl
- the service level to print