Originally posted by: SystemAdmin
[Max said:]
Hey,
Iôm using OPL 5.5. In my project I read data from an Excel File, which includes 200 sheets. There is one variable that changes with every new simulation. I need to start this number of simulations in order to get as many results as possible for my Lp. So I created the following loop to make ILOG work by itself:
main {
for ( var n = 1; n <=200; n++ ) {<br />
var cplex = new IloCplex;
var src = new IloOplModelSource("model1.mod");
var def = new IloOplModelDefinition(src);
var model = new IloOplModel(def,cplex);
var data = new IloOplDataSource("data.dat");
var data1 = new IloOplDataElements();
[b]data1.loc = "Szenario"
n"!L11:O210";[/b]
model.addDataSource(data1);
model.addDataSource(data);
model.generate();
if(cplex.solve()) {
zfwert = cplex.getObjValue();
}
modell.end();
data.end();
def.end();
cplex.end();
src.end();
}
}
The loc-variable is initialized in the modell following:
string loc = ...;
The excel-part of my data-file looks like this:
SheetConnection sheet("Test2.xlsm");
v from SheetRead(sheet,loc);
The variable v should change every new run. In this forum I saw a thread where someone explained how to link a string with an integer, what I did like it was explained. It seems to work fine, but as I try to run the model I get a message "Excel range is unknown". The range I wrote is surely correct, thats not the point. But I don`t know why it won't run and I ask you if anyone could take a look at my problem and maybe has a suggestion how to solve it.
Thanks in advance!
Max
#DecisionOptimization#OPLusingCPLEXOptimizer