Originally posted by: naoseinao
Hi there,
I have an main opl file to run a model with different parameters. My problem is that I run out of memory, as oplrun apparently does not free up not used RAM sufficiently by default. It uses 10-15GB, but reserves more than double of that RAM, that by time (after a week or so) it runs out of memory. I could remove the already solved problems from my array to continue where it stopped, but I would prefer it running through, though. Reading the Knowledge Center I only found options to reduce the memory load. That is not what I am looking for, I look for an option to free the memory after finishing solving one problem or running into a time limit.
Following an excerpt from my main.mod calling model.mod:
// === MAIN ===
var src = new IloOplModelSource("model.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(src);
var filenameResults = "results.csv";
var f = new IloOplOutputFile(filenameResults);
f.close();
for (var ci = 1; ci < thisOplModel.noOfClasses; ci++) { // int noOfClasses = 1;
var param1 = thisOplModel.classes[ci][1]; // int classes[1..noOfClasses][1..2] = [...];
var param2 = thisOplModel.classes[ci][2];
for (var i = 1; i <= instances; i++) { // var instances = 100;
var opl = new IloOplModel(def, cplex);
var filename = param1 + "-" + param2 + "-" + i + ".dat";
var result = "\"(" + param1 + ", " + param2 + ")\";" + i;
writeOplConfig(readConfiguration(filename), filename);
opl.addDataSource(new IloOplDataSource(folderOplData + filename));
opl.generate();
cplex.tilim = 3600; // Would a memory limit help to free up not anymore used memory?
if (cplex.solve()) {
result = result + "," + cplex.getBestObjValue();
if (cplex.getCplexStatus() == 1) {
result = result + ",true";
} else {
result = result + ",false";
}
// Save Decision Variables in File
var rf = new IloOplOutputFile(folderDecisionVars + filename);
rf.writeln("obj = " + opl.obj);
rf.writeln("a = " + opl.a);
rf.writeln("b = " + opl.b);
rf.close();
} else {
writeln("No solution");
result = result + ",n/a";
}
opl.end(); // Should free up used memory...
f = new IloOplOutputFile(filenameResults, true);
f.writeln(result);
f.close();
}
}
#DecisionOptimization#OPLusingCPLEXOptimizer