Hi everyone,
I'm trying to build the following model :
- The model in modele.mod
- Three data files in data1.dat, data2.dat, data3.dat that contains all the parameters and timeseries needed for the model
- A main in main.mod that contains the iterative loop to change a parameter (a 1D array with a float) then solve the problem several times
I tried to build this following the examples I found here : - AI and Data Science
How to ... with OPL
Linkedin |
remove preview |
|
How to ... with OPL |
OPL is a very easy to use modeling language within CPLEX. Let me start here a list of some examples and links I gave in the past to answer very simple and common questions: how to . |
View this on Linkedin > |
|
|
But I have troubles when I run my main.mod, Cplex doesn't find my data (a lot of "External data element XXXX was not defined") and I don't manage to change my parameter properly. Here is my main.mod :
float paramreservoir[NumReservoir];
main {
var source = new IloOplModelSource("Modele.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
for(var k=100;k<=500;k+=50) {
var opl = new IloOplModel(def,cplex)
var data2= new IloOplDataElements();
data2.VolumeInitial=thisOplModel.paramreservoir;
data2.VolumeInitial[1]=k;
opl.addDataSource(data2);
writeln("Solve with Reservoir =", k);
opl.generate();
if ( cplex.solve() ) {
curr = cplex.getObjValue();
writeln("OBJECTIVE: ",curr);
writeln();
}
else {
writeln("No solution!");
break;
}
Does someone has an idea ?
Thanks a lot for the help
------------------------------
Grégoire Turzo
------------------------------