I am trying to write the result data to an external file because of an error I got after running the code for 16 hours.
I found the code above, it works for the variables with one index but my variables are not with one index. There are even variables with 4 indexes. How can I adapt this code to my situation?
execute{
var ofile = new IloOplOutputFile("modelRun.txt");
ofile.writeln("Data:");
for(var i in thisOplModel.r){
ofile.writeln("d["+i+"+"]="+thisOplModel.d[i]]);
}
ofile.writeln("Optimal objective value="+cplex.getObjValue());
ofile.writeln("Optimal variable values:");
for(i in thisOplModel.r){
ofile.writeln("x["+i+"]="+thisOplModel.x[i]);
}
ofile.close();
}
Thank you for any help!
If x is a 4D array instead of:
for(i in thisOplModel.r){
ofile.writeln("x["+i+"]="+thisOplModel.x[i]);
}
you could directly write:
ofile.writeln("x="+thisOplModel.x);