Hi,
let s go on with https://www.linkedin.com/pulse/what-optimization-how-can-help-you-do-more-less-zoo-buses-fleischer/
On top of model files (.mod) and data files (.dat) we can also add settings to tell CPLEX how to behave.
We have several options:
1) Through scripting in OPL
execute
{
cplex.tilim=20;
}
int nbKids=300;
float costBus40=500;
float costBus30=400;
dvar int+ nbBus40;
dvar int+ nbBus30;
minimize
costBus40*nbBus40 +nbBus30*costBus30;
subject to
{
40*nbBus40+nbBus30*30>=nbKids;
}
execute
{
writeln("time limit = ",cplex.tilim);
}
which gives
// solution (optimal) with objective 3800
time limit = 20
2) We can use a settings file (.ops)
and then you add the .ops to the run configuration
and then with zoo.mod
int nbKids=300;
float costBus40=500;
float costBus30=400;
dvar int+ nbBus40;
dvar int+ nbBus30;
minimize
costBus40*nbBus40 +nbBus30*costBus30;
subject to
{
40*nbBus40+nbBus30*30>=nbKids;
}
execute
{
writeln("time limit = ",cplex.tilim);
}
we ll get
// solution (optimal) with objective 3800
time limit = 20
3) You may also read a .ops file from the flow control part (main)
int nbKids=300;
float costBus40=500;
float costBus30=400;
dvar int+ nbBus40;
dvar int+ nbBus30;
minimize
costBus40*nbBus40 +nbBus30*costBus30;
subject to
{
40*nbBus40+nbBus30*30>=nbKids;
}
execute
{
writeln("time limit = ",cplex.tilim);
}
main
{
thisOplModel.generate();
cplex.solve();
thisOplModel.postProcess();
thisOplModel.applyOpsSettings(null, thisOplModel.resolvePath("zoo.ops"));
cplex.solve();
thisOplModel.postProcess();
}
which gives
time limit = 2147483647
time limit = 20
regards
Many other simple OPL examples at https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/
#DecisionOptimization#OPLusingCPLEXOptimizer