Originally posted by: SystemAdmin
[afleischer said:]
Hello,
to get what you need you could use a main block.
Let me give you an example.
In the file oil.mod you add
string s=...;
in the file oilSheet.dat from the OPL distribution in examples\opl\oil you replace the SheetConnection line by
SheetConnection sheet(s);
then
oplrun -Ds="oilSheet.xls" callOilSheet.mod will call the example with the file name as parameter
In the model callOilSheet.mod we have
string s=...;
main {
thisOplModel.generate();
var source = new IloOplModelSource("oil.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
var opl = new IloOplModel(def,cplex);
var data0= new IloOplDataElements();
var data = new IloOplDataSource("oilSheet.dat");
data0.s=thisOplModel.s;
opl.addDataSource(data0);
opl.addDataSource(data);
opl.generate();
if (cplex.solve()) {
writeln("OBJ = " + cplex.getObjValue());
} else {
writeln("No solution");
}
opl.end();
}
#CPLEXOptimizers#DecisionOptimization