How the flow control script works
Illustrated via the model solpoolscript.mod.
The model solpoolscript.mod is
a variation of scalableWarehouse.mod and
has been written to illustrate how the flow control script works.
It contains the main flow control script
shown in the following code extract.
Flow control script for pool solutions (solpoolscript.mod)
main {
thisOplModel.generate();
cplex.solve();
if (cplex.populate()) {
var nsolns = cplex.solnPoolNsolns;
writeln("Number of solutions found = ",nsolns);
writeln();
for (var s=0; s<nsolns; s++) {
thisOplModel.setPoolSolution(s);
writeln("solution #", s, ": objective = ", cplex.getObjValue(s));
write("Open = [ ");
for (var i in thisOplModel.Warehouses)
write(thisOplModel.Open[i], " ");
writeln("]");
writeln("---------");
}
}
}
This flow control script
creates and extracts the model, and populates the solution pool after a regular MIP solve
thisOplModel.generate(); cplex.solve(); if (cplex.populate()) {gets the number of solutions in the solution pool
var nsolns = cplex.solnPoolNsolns; writeln("Number of solutions found = ",nsolns);uses the solutions in the model
writeln(); for (var s=0; s<nsolns; s++) { thisOplModel.setPoolSolution(s);gets the objective values for those solutions
writeln("solution #", s, ": objective = ", cplex.getObjValue(s));writes the results to the Scripting Log
write("Open = [ "); for (var i in thisOplModel.Warehouses) write(thisOplModel.Open[i], " "); writeln("]"); writeln("---------");