Hi,
I am running a CP model for certain number of iterations. For each iteration, a set of initial data is randomly generated. I am using control flow to run the iterations. As I using epsilon-constraint method in the multi-objective problem I am solving, I have to specify one of the objective functions as a constraint while minimizing the other objective function. In some cases, the model may not be solved as the problem constraints are not satisfied because of the initial data that is randomly generated. My problem that once the model is not solved, the remaining iterations are not completed. How can I run the next iteration in case the current iteration fails. Please find below the control flow code:
int IterationNum=50;
{int} Set=asSet(1..IterationNum);
main{
var DIR="C:\\Users\\"
var csvFileName0="w_0.875_seeds_obj.csv";
var ofile0 =new IloOplOutputFile(DIR+csvFileName0);
ofile0.writeln("I",",","E",",","M",",","C");
function SolveOPL_CPModel(IterNum)
{
var MyCPModel_source = new IloOplModelSource("Model.mod");
var MyCPModel_cplex = new IloCP();
var MyCPModel_def = new IloOplModelDefinition(MyCPModel_source);
var MyCPModel_opl = new IloOplModel(MyCPModel_def,MyCPModel_cplex);
var MyCPModel_data = new IloOplDataSource("Data.dat");
var MyCPModel_dataelts= new IloOplDataElements();
MyCPModel_opl.settings.mainEndEnabled=true;
MyCPModel_opl.settings.warnings=false;
MyCPModel_dataelts.IterNum=IterNum;
MyCPModel_opl.addDataSource(MyCPModel_dataelts);
MyCPModel_opl.addDataSource(MyCPModel_data);
MyCPModel_opl.generate();
if(MyCPModel_cplex.solve()) MyCPModel_opl.postProcess();
for(var a in MyCPModel_opl.objective_function)
ofile0.writeln(a.IterNum+0 ,",",a.E,",",a.M,",",a.C)
MyCPModel_opl.end();
MyCPModel_dataelts.end();
MyCPModel_source.end();
MyCPModel_cplex.end();
MyCPModel_def.end();
MyCPModel_data.end();
}
for(var IterNum in thisOplModel.Set) SolveOPL_CPModel(IterNum)
ofile0.close();
}
Thanks in advance,
Mohamed
------------------------------
Mohamed Awad
------------------------------