Originally posted by: ALessin
Is there a way to set some .dat files as static, while changing just a few .dat files across looped problem instances?
For example, I would like to add and change several .dat files using a loop process similar to the example below. However, I also have numerous additional .dat files that remain static across all iterations. If I add all the .dat files in the manner shown below, the solution time is greatly increased. If there's a way to initialize the static .dat files before the dynamic .dat file loop, I think the solution time would decrease significantly.
Take the small model sub.mod
float maxOfx = ...;
dvar float x;
maximize x;
subject to {
x<=maxOfx;
}
You can use in some other .mod
main {
var source = new IloOplModelSource("sub.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
var opl = new IloOplModel(def,cplex);
for(var k=11;k<=20;k++)
{
var opl = new IloOplModel(def,cplex);
var data2= new IloOplDataElements();
data2.maxOfx=k;
opl.addDataSource(data2);
opl.generate();
if (cplex.solve()) {
writeln("OBJ = " + cplex.getObjValue());
} else {
writeln("No solution");
}
opl.end();
}
}
Thank you for your help!
-Aaron
#DecisionOptimization#OPLusingCPLEXOptimizer