I am trying to solve a subproblem iteratively by calling it in the flow control. My subproblems contain sets of tuples. I am wondering if it is possible to access the tuple element inside the flow control (e.g. for updating data using for loop)?
I provided an example at https://github.com/AlexFleischerParis/howtowithoplchange/blob/master/changetupleset.mod
sub.mod
tuple t
{
int e1;
int e2;
}
{t} y=...;
execute
{
writeln("y=",y);
}
dvar float x;
maximize x;
subject to {
x<=sum(i in y)i.e2;
}
execute
{
writeln("x=",x);
}
and then the main block in main.mod
tuple t
{
int e1;
int e2;
}
{t} s={<1,1>};
main {
var source = new IloOplModelSource("sub.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
for(var k=1;k<=5;k++)
{
var opl = new IloOplModel(def,cplex);
var data2= new IloOplDataElements();
data2.y=thisOplModel.s;
Opl.item(thisOplModel.s,0).e2=Opl.item(thisOplModel.s,0).e2+1;
data2.y.add(k,k+1);
opl.addDataSource(data2);
opl.generate();
if (cplex.solve()) {
writeln("OBJ = " + cplex.getObjValue());
} else {
writeln("No solution");
}
data2.end();
opl.end();
}
}