I'm trying to solve some quadratic integer programming problem with IBM ILOG CPLEX Optimization studio. So I would like to do solve the following quadratic integer programming problem, all the parameters has been defined.
float q = 0;
maximize
sum(i in RR) sum(j in RR) (Num[i][j]*x[i]*x[j] - q*Den[i][j]*x[i]*x[j]);
subject to {
forall (i in R) sum(j in R) x[I*i + j] == 1;
forall (i in R) sum(j in R) x[I*j + i] == 1;
}
The program manage to find the solution. But I also would like to solve for several values of q. So I setup the following main script loop, updating q for every iteration and solve.
main {
var count = 1;
thisOplModel.generate();
var mdl = thisOplModel;
while (1) {
writeln("Running with q = " + mdl.q);
cplex.solve();
count = count + 1;
if (count > 20) break;
// prepare next iteration
var def = mdl.modelDefinition;
var data = mdl.dataElements;
if ( mdl!=thisOplModel ) {
mdl.end();
}
mdl = new IloOplModel(def,cplex);
data.q = count;
mdl.addDataSource(data);
mdl.generate();
}
}
But when I tried to run this, I got the error:
I think the idea of what I'm trying to do should be clear, could anyone advice me how to do it properly? Thank you!