So i have a simple linear program written in my .mod file. However, i want to use different input parameters (+10%, +20% etc…) for each run. The .dat files are all identical except the changed parameters. I used an example from this forum and added the main block into my .mod (see below) to solve these instances, however i am getting an error that .datfiles is not available. I also tried to put it into a separate mod, but still without success. I would appreciate any help.
{string} datFiles={“+10% N.dat”,”+20% N.dat”};
main{
var src = new IloOplModelSource(“Fall 2_NP.mod”);
var cplex = new IloCplex();
var def = new IloOplModelDefinition(src);
for(var datFile in thisOplModel.datFiles){
var opl = new IloOplModel(def, cplex);
var data = new IloOplDataSource(datFile);
opl.addDataSource(data);
var details=opl.dataElements;
opl.generate();
if(cplex.solve()){
writeln(“Gesamtkosten =” + cplex.getObjValue());}
else{
writeln(“No Solution”);}
}}
Source: Error using different .dat files