public class StochCP extends Object
Each scenario is solving independently at first, then all the linear cuts are put
together to solve the stochastic problem.
Unlike the Two-step approach, only the linear cuts are transfered from the
individual scenario problems to the main stochastic problem.
Combining all the cuts might over-estimate the number of agents.
Thus, we suggest to lower the service level (SL) targets when executing
the cutting-plane algorithm, and correct the solution by local search at the end.
The SL targets can be lowered by setting the parameters
StochCPParams.targetSLTolCall
and StochCPParams.targetSLTolGlobal
.
The recourse variables can be enabled by setting the parameter ScenariosParams.useRecourse
to true
(default value).
Note that if the simulator parameter is RepSimParams
, then the call center
must only have 1 period.
Modifier and Type | Class and Description |
---|---|
protected class |
StochCP.AddConstraintWorker
This class allows to execute the method
int[], umontreal.iro.lecuyer.ccoptim.cp.CuttingPlaneTest, umontreal.iro.lecuyer.ccoptim.stochcp.CuttingPlaneOnly)
and execute the Cplex solver in parallel over multiple infeasible scenarios. |
protected static class |
StochCP.VariableData
Class used to identify the variables in the cutting-plane constraints.
|
static class |
StochCP.WithLog
This subprogram allows the execution of the program
StochCP and log of the output to a file. |
Modifier and Type | Field and Description |
---|---|
protected StochSolution |
bestSolution
The best stochastic solution found.
|
protected CallCenter |
cc
The call center model.
|
protected int |
currPeriod
The current period to optimize.
|
protected List<CuttingPlaneParams> |
cutpList
The cutting-plane parameters for each scenario.
|
protected int |
numGroups
The number of agent groups.
|
protected int |
numScenarios
The number of scenarios.
|
protected int |
numTypes
The number of call types.
|
protected ScenariosParams |
scenParams
The scenario parameters.
|
protected StochCPParams |
scpParams
The stochastic staffing algorithm parameters.
|
protected List<SimParams> |
simpList
The list of simulation parameters, for each scenario.
|
Constructor and Description |
---|
StochCP(StochCPParams scpParams,
ScenariosParams scenParams,
List<SimParams> simpList,
List<CuttingPlaneParams> cutpList)
Constructs the stochastic staffing optimizer.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addNewConstraints(int scenNum,
int[] effStaffing,
CuttingPlaneTest sim,
CuttingPlaneOnly cp)
Adds a new constraint, generated by subgradient cut, to the given scenario.
|
protected void |
applyTargetSLTol(CallCenterParams ccParams)
Reduces the service level targets by the values specified by
StochCPParams.targetSLTolCall
and StochCPParams.targetSLTolGlobal . |
protected void |
applyTargetSLTol(CallCenterSim sim)
Reduces the service level targets by the values specified by
StochCPParams.targetSLTolCall
and StochCPParams.targetSLTolGlobal . |
protected SubgradientInfo |
computeGradientInfo(int[] effStaffing,
CuttingPlaneTest sim,
int stepSize)
Computes the gradient for each agent group and call type, and all call types (the aggregated SL).
|
protected List<? extends CallCenterSim> |
createListSimulator()
Creates a list of simulators for each scenario.
|
StochSolution |
getBestSolution()
Returns the best solution found for the stochastic staffing problem with recourse.
|
protected List<Integer> |
getInfeasibleScenarios(StochSolution sol,
List<CuttingPlaneTest> simList,
List<Integer> scenList,
int period)
Returns a list containing the scenario numbers, from the list
scenList ,
that are not feasible after simulation. |
protected double[][] |
getSLTargets(CallCenterSim sim)
Returns the service level target matrix of a simulator.
|
int |
getStaffingPeriod()
Returns the staffing period to be optimized.
|
StochCPParams |
getStochCPParams()
Returns the parameter object
StochCPParams of this instance. |
protected static boolean |
isFeasible(int[] staffing,
int[] rPlus,
int[] rMinus,
CuttingPlaneTest sim,
int period)
Checks the feasibility of the given staffing with recourse solution with simulation.
|
protected static boolean |
isFeasible(StochSolution sol,
List<CuttingPlaneTest> simList,
List<Integer> scenList,
int period)
Checks if all the scenarios given in the list
scenList are feasible
(all the service level targets are met). |
protected void |
localSearch(double[] staffCost,
List<? extends CallCenterSim> simList,
int maxCPUSec)
Executes the local search on the best solution.
|
static void |
main(String[] args)
Optimizes the stochastic staffing problem with recourse, and find a solution that
will satisfy the service level constraints for all the scenarios.
|
void |
optimize()
Executes the stochastic staffing optimization.
|
protected List<CuttingPlaneOnly> |
optimizeScenarios(int numCPU,
List<? extends CallCenterSim> simList)
Optimizes each scenario individually and returns the list of
CuttingPlaneOnly
instances ordered by scenario index. |
protected static CuttingPlaneOnly |
optOneScenario(CallCenterSim sim,
CuttingPlaneParams cutParams)
Executes the cutting-plane algorithm
CuttingPlaneOnly and disables
automatically the local search. |
protected void |
resetSLTargets(CallCenterSim sim,
double[][] target)
Resets the service level targets of a simulator to the given values.
|
protected void |
verbosePrint(String s)
Calls the method
System.out.print(s) , where s is the argument,
if the verbose parameter StochCPParams.verbose is
set to true . |
protected void |
verbosePrintln(String s)
Calls the method
System.out.println(s) , where s is the argument,
if the verbose parameter StochCPParams.verbose is
set to true . |
protected ScenariosParams scenParams
protected StochCPParams scpParams
protected List<CuttingPlaneParams> cutpList
protected CallCenter cc
protected final int numGroups
protected final int numTypes
protected final int numScenarios
protected StochSolution bestSolution
protected final int currPeriod
RepSimParams
, then there must be only 1 period, and
this parameter must be set to 0.
If the user is using BatchSimParams
, then this value is read from
the cutting-plane parameter CuttingPlaneParams.currentPeriod
.public StochCP(StochCPParams scpParams, ScenariosParams scenParams, List<SimParams> simpList, List<CuttingPlaneParams> cutpList)
scenParams
- the scenario parameterssimpList
- a list that contains the simulation parameters for each scenariocutpList
- a list that contains the cutting-plane parameters for each scenariopublic StochCPParams getStochCPParams()
StochCPParams
of this instance.protected List<? extends CallCenterSim> createListSimulator()
protected void resetSLTargets(CallCenterSim sim, double[][] target)
sim
- the call center simulatortarget
- the new service level targets to setprotected double[][] getSLTargets(CallCenterSim sim)
[call type][main period]
, with extra row and column for
aggregated over all types and/or periods.sim
- the simulatorpublic void optimize() throws ilog.concert.IloException
ilog.concert.IloException
protected void verbosePrint(String s)
System.out.print(s)
, where s
is the argument,
if the verbose parameter StochCPParams.verbose
is
set to true
.s
- the string to printprotected void verbosePrintln(String s)
System.out.println(s)
, where s
is the argument,
if the verbose parameter StochCPParams.verbose
is
set to true
.s
- the string to printpublic int getStaffingPeriod()
RepSimParams
,
then the period to be optimized should be 0.protected void localSearch(double[] staffCost, List<? extends CallCenterSim> simList, int maxCPUSec)
simList
is null
, then the local search will
create a new simulator for each scenario.staffCost
- the cost vector of the staffing (not recourse)simList
- the list of simulators, one for each scenariomaxCPUSec
- the maximum CPU time allocated for the local searchprotected void addNewConstraints(int scenNum, int[] effStaffing, CuttingPlaneTest sim, CuttingPlaneOnly cp)
scenNum
- the scenario number to add a subgradient cuteffStaffing
- the effective staffing, used to estimate the subgradientsim
- the simulatorcp
- the cutting-plane instance where to add the new constraintprotected SubgradientInfo computeGradientInfo(int[] effStaffing, CuttingPlaneTest sim, int stepSize)
effStaffing
- the effective staffing vector (staffing including recourse actions)sim
- the simulatorstepSize
- the step size to estimate the gradient by finite difference[type][group]
. The last type is for the aggregated SL.protected static boolean isFeasible(StochSolution sol, List<CuttingPlaneTest> simList, List<Integer> scenList, int period)
scenList
are feasible
(all the service level targets are met).sol
- the solutions for all the scenariossimList
- the list of simulator for all the scenarios. The ordering
of the simulators in this list must match the scenario numbers.scenList
- the list of scenarios to be testedperiod
- the period to check for SL feasibility (0 if simulating with
RepSimParams
)true
if all the scenarios given in scenList
are feasible, otherwise false
protected List<Integer> getInfeasibleScenarios(StochSolution sol, List<CuttingPlaneTest> simList, List<Integer> scenList, int period)
scenList
,
that are not feasible after simulation.
It returns an empty list if all scenarios are feasible.sol
- the solutions for all the scenariossimList
- the list of simulator for all the scenarios. The ordering
of the simulators in this list must match the scenario numbers.scenList
- the list of scenarios to test for feasibilityperiod
- the period to check for SL feasibility (0 if simulating with
RepSimParams
)scenList
protected static boolean isFeasible(int[] staffing, int[] rPlus, int[] rMinus, CuttingPlaneTest sim, int period)
staffing
- the staffing vector (without recourse)rPlus
- the recourse of adding agentsrMinus
- the recourse of removing agentssim
- the simulator to use for the testperiod
- the period to check for SL feasibility (0 if simulating with
RepSimParams
)true
if this solution is feasible (satisfies all the service level targets),
otherwise false
protected void applyTargetSLTol(CallCenterSim sim)
StochCPParams.targetSLTolCall
and StochCPParams.targetSLTolGlobal
.
Calling this method multiple times on the same parameter object will decrease
the SL targets multiple times.
The lower bound of the SL target is 0.sim
- the call center simulator where to change the service level targetprotected void applyTargetSLTol(CallCenterParams ccParams)
StochCPParams.targetSLTolCall
and StochCPParams.targetSLTolGlobal
.
Calling this method multiple times on the same parameter object will decrease
the SL targets multiple times.
The lower bound of the SL target is 0.ccParams
- the call center parameter file where to read the service level targetsprotected List<CuttingPlaneOnly> optimizeScenarios(int numCPU, List<? extends CallCenterSim> simList)
CuttingPlaneOnly
instances ordered by scenario index.numCPU
- the number of CPU to run in parallelsimList
- the list of simulators to be used for each scenarioCuttingPlaneOnly
instance, ordered by scenario indexpublic StochSolution getBestSolution()
IllegalStateException
- if the optimization has not been executedprotected static CuttingPlaneOnly optOneScenario(CallCenterSim sim, CuttingPlaneParams cutParams) throws Exception
CuttingPlaneOnly
and disables
automatically the local search.
It returns an instance CuttingPlaneOnly
which can return
the hash map of linear constraints and variables.sim
- the simulator for this scenariocutParams
- the cutting-plane parameters, the parameter CuttingPlaneParams.useLocalSearch
will be set to false
Exception
public static void main(String[] args) throws Exception
StochCPCC
instead.
The arguments are:
args
- see the descriptionException