Optimal use of CPLEX Java for high throughput

I solve big optimization problems with CPLEX Java API. I'm just now

IloCplex cplex = new IloCplex();
... add lots of variables and constraints ...
cplex.solve();
cplex.end();

This works great, but I often repeat this process when I just change performance factors. Each time I repeat, I create a new object cplexand recreate all the variables.

Is there a more efficient way to do this? The IBM documentation has a language such as β€œadding a model to an instance of a model,” which sounds strange, but I thought it was a hint of the possibility of reusing things.

Any suggestions from more experienced users would be great. Thank.

+5
source share
1 answer

( ), IloCplex. .

retval = cplex.solve();
// verify that the solve was successful

// change coeficients on constraints (or in the objective)
cplex.setLinearCoef(constraint, newCoef, variable);
cplex.setLinearCoef(objective, newObjCoef, variable);

// change right bounds on constraints
constraint.setBounds(newLB, newUB);

// change variable bounds
var.setBounds(newLB, newUB);

retval = cplex.solve();
// verify the solve
+6

All Articles