I am interested in solving a set of maximization problems where those problems only just differ in their objective. The objective functions are all linear and the constraints are all just affine. I was wondering what is the most efficient way to implement it using CPLEX since I would like the solver to reuse as much information across the different solves. The problems are solved sequentially one after the other (as shown in the for loop below). I tried to get this information from the CPLEX manual, but I was unsuccessful. Any help would be appreciated. Below I have provided a snippet from my code (in C++), any advice on improving its speed will be great.
IloEnv env;
IloModel model(env);
IloNumVarArray vec_x_vars(env);
// I call a function here to populate constraints into the model
std::vector<IloNumArray> vec_obj_coeffs; //Assume this vector contains all the different linear objectives
IloExpr obj_expr(env);
for(size_t uiIndex = 0; uiIndex < vec_objectives.size(); uiIndex++)
{
obj_expr.setLinearCoefs(vec_x_vars, vec_objectives[uiIndex]);
IloObjective obj = IloMaximize(env, obj_expr);
model.add(obj);
IloCplex cplex(model);
cplex.solve();
model.remove(obj);
}
obj_expr.end();
vec_x_vars.end();
env.end();
Is the implementation above the best possible in terms of efficiency that we can get?