public final class UtilStochCP extends Object
Modifier and Type | Method and Description |
---|---|
static double |
computeCost(int[] staffing,
int[][] rPlus,
int[][] rMinus,
double[] staffCost,
ScenariosParams scenParams)
Computes the cost of the stochastic solution of all the scenarios.
|
static double |
computeCost(int[] staffing,
int[][] rPlus,
int[][] rMinus,
double[] staffCost,
ScenariosParams scenParams,
List<Integer> coveredScenarios)
Computes the cost of the stochastic solution of the covered scenarios.
|
static boolean |
correctRounding(int[] y,
int[][] rPlus,
int[][] rMinus)
Corrects the rounded solution (for all scenarios) such that
y[i] + rPlus[i][m] <SPAN CLASS="MATH">></SPAN>= rMinus[i][m] . |
static String |
formatSL(DoubleMatrix2D sl,
int period)
Formats the service levels into a String.
|
static double |
getAverageCoverRMinus(StochSolution sol)
Computes the average amount of agents removed by decrement recourse over
all covered scenarios.
|
static double |
getAverageCoverRPlus(StochSolution sol)
Computes the average amount of agents added by increment recourse over
all covered scenarios.
|
static double[] |
getColumn(double[][] mat,
int column)
Returns the column of a matrix as an array.
|
static int[] |
getColumn(int[][] mat,
int column)
Returns the column of a matrix as an array.
|
static int[] |
getEffectiveStaffing(int[] staffing,
int[] rPlus,
int[] rMinus)
Computes the real staffing, after applying the recourse variables to the staffing solution.
|
static double[] |
getRecourseMinusCost(ScenariosParams scenParams,
double[] staffCost)
Retrieves the recourse cost vector for removing one agent, for each group.
|
static double[] |
getRecoursePlusCost(ScenariosParams scenParams,
double[] staffCost)
Retrieves the recourse cost vector for adding one agent, for each group.
|
static double |
getStdCoverRMinus(StochSolution sol)
Computes the standard deviation of the sum of agents removed by decrement recourse for
a covered scenario.
|
static double |
getStdCoverRPlus(StochSolution sol)
Computes the standard deviation of the sum of agents added by increment recourse for
a covered scenario.
|
static void |
increaseSimLength(CallCenterSim sim,
double factor,
boolean verbose)
Increases the simulation length by factor
factor
(or decreases, if this parameter is smaller than 1). |
static void |
increaseSimLength(SimParams simParams,
double factor,
boolean verbose)
Increases the simulation length by factor
factor
(or decreases, if this parameter is smaller than 1). |
static boolean |
isSLFeasible(CallCenter cc,
DoubleMatrix2D sl,
int period)
Checks if the given service level measures is feasible for the given call center
at the specified period.
|
static void |
multiSim(List<? extends CallCenterSim> simList,
int numCPU)
Simulates many call centers in parallel.
|
static void |
multiSimSolution(List<? extends CallCenterSim> simList,
StochSolution sol,
int numCPU)
Simulates all the covered scenarios, in parallel.
|
public static boolean correctRounding(int[] y, int[][] rPlus, int[][] rMinus)
y[i] + rPlus[i][m] <SPAN CLASS="MATH">></SPAN>= rMinus[i][m]
.
If y[i] + rPlus[i][m] <SPAN CLASS="MATH"><</SPAN> rMinus[i][m]
, then set rMinus[i][m] = y[i] + rPlus[i][m]
.
The given parameters will be modified if required.
This method return true
or false
if it has corrected to given parameters or not.
y
- the staffing vector which contains the number of agents in each grouprPlus
- the recourse matrix for adding agents with indexes [group][scenario]
rMinus
- the recourse matrix for removing agents with indexes [group][scenario]
true
if this method has corrected the solution, else false
public static double[] getRecoursePlusCost(ScenariosParams scenParams, double[] staffCost)
scenParams
- the scenario parametersstaffCost
- the staffing cost, used only if ScenariosParams.useCostMult
is set to true
public static double[] getRecourseMinusCost(ScenariosParams scenParams, double[] staffCost)
scenParams
- the scenario parametersstaffCost
- the staffing cost, used only if ScenariosParams.useCostMult
is set to true
public static int[] getEffectiveStaffing(int[] staffing, int[] rPlus, int[] rMinus)
staffing
- the non-recourse staffing vectorrPlus
- the recourse variables for adding agentsrMinus
- the recourse variables for removing agentsIllegalStateException
- if the effective staffing has a negative valuepublic static double getAverageCoverRPlus(StochSolution sol)
sol
- the stochastic solution to compute frompublic static double getStdCoverRPlus(StochSolution sol)
sol
- the stochastic solution to compute frompublic static double getAverageCoverRMinus(StochSolution sol)
sol
- the stochastic solution to compute frompublic static double getStdCoverRMinus(StochSolution sol)
sol
- the stochastic solution to compute frompublic static int[] getColumn(int[][] mat, int column)
mat
- the matrixcolumn
- the column index to be returned as an arraypublic static double[] getColumn(double[][] mat, int column)
mat
- the matrixcolumn
- the column index to be returned as an arraypublic static double computeCost(int[] staffing, int[][] rPlus, int[][] rMinus, double[] staffCost, ScenariosParams scenParams, List<Integer> coveredScenarios)
rPlus
and rMinus
are compute using
the parameters scenParams
and staffCost
.staffing
- the staffing vector (non-recourse variables)rPlus
- the recourse variables for adding agents, with indices [group][scenario]
rMinus
- the recourse variables for removing agents, with indices [group][scenario]
staffCost
- the cost per agent per group vectorscenParams
- the scenario parameters, to get the probabilitiescoveredScenarios
- the list of covered scenariospublic static double computeCost(int[] staffing, int[][] rPlus, int[][] rMinus, double[] staffCost, ScenariosParams scenParams)
rPlus
and rMinus
are compute using
the parameters scenParams
and staffCost
.
This function is similar to int[][], int[][], double[], umontreal.iro.lecuyer.ccoptim.stochcp.ScenariosParams, java.util.List)
,
but it includes all scenarios.
staffing
- the staffing vector (non-recourse variables)rPlus
- the recourse variables for adding agents, with indices [group][scenario]
rMinus
- the recourse variables for removing agents, with indices [group][scenario]
staffCost
- the cost per agent per group vectorscenParams
- the scenario parameters, to get the probabilitiespublic static boolean isSLFeasible(CallCenter cc, DoubleMatrix2D sl, int period)
cc
- the call center model, it must contain the service level targetssl
- the service level measuresperiod
- the period to checktrue
if the service level matrix satisfies all the service level targets,
otherwise it returns false
public static void increaseSimLength(SimParams simParams, double factor, boolean verbose)
factor
(or decreases, if this parameter is smaller than 1).
If the simulator uses the parameter BatchSimParams
, then it
will increase the batch size by calling BatchSimParams.setBatchSize(javax.xml.datatype.Duration)
.
If the simulator uses the parameter RepSimParams
, then it
will increase the minimum number of replications by calling
RepSimParams.setMinReplications(int)
.simParams
- the simulation parameters. It can be of class
BatchSimParams
or RepSimParams
.factor
- the multiplicative factorverbose
- if true
then prints new simulation lengthpublic static void increaseSimLength(CallCenterSim sim, double factor, boolean verbose)
factor
(or decreases, if this parameter is smaller than 1).
If the simulator uses the parameter BatchSimParams
, then it
will increase the batch size by calling BatchSimParams.setBatchSize(javax.xml.datatype.Duration)
.
If the simulator uses the parameter RepSimParams
, then it
will increase the minimum number of replications by calling
RepSimParams.setMinReplications(int)
.
This method executes double, boolean)
.
sim
- the simulator to be modifiedfactor
- the multiplicative factorverbose
- if true
then prints new simulation lengthpublic static void multiSim(List<? extends CallCenterSim> simList, int numCPU)
simList
- the list of simulators to executenumCPU
- the number of threads to run in parallelpublic static void multiSimSolution(List<? extends CallCenterSim> simList, StochSolution sol, int numCPU)
int)
, this method will compute the
effective staffing vector using int[], int[])
and replace the STAFFINGVECTOR
parameter in the simulator only for
the covered scenarios defined in StochSolution.getCoveredScenarios()
.
No changes in the staffing vector and no simulation will be performed for the
non-covered scenarios.
The simulation results must be fetched from the simulators by the user.
The size of the list of simulators given in parameter must be equal to the number of scenarios (covered and non-covered), even the simulators will not be executed.
simList
- the list of simulators, the size must be equal to the number of scenarios in the stochastic problem.
The staffing vector in the simulators of the covered scenarios will be replaced by the corresponding stochastic solution.sol
- the stochastic solution, where only the covered scenarios will be simulatednumCPU
- the number of threads to run in parallelpublic static String formatSL(DoubleMatrix2D sl, int period)
sl
- the service level matrixperiod
- the period to check the SL feasibility.
This value must be 0 if using the simulation parameter RepSimParams
.