I have a MILP modelled using the C++ API of Cplex. The MILP is solved several times and after each solve certain constraints are modified and variables are removed or added. Before starting the process of modifying constraints and variables, I would like to save the old state. Therefore, I would like to create a copy of the current constraints and variables I have, before modifying them, so that I can fall back on those values. I don't know how to do that, because e.g.
IloNumVarArray p(env, n);
IloNumVarArray p_save(env,n);
for (int i = 0; i < n; i++)
{
p_save[i] = p[i];
}
just seems to create a copy of the handle object and not the implementation object (?). Using the above code, if I modify p later on, let's say
p[2].end();
the same modification happens with `p_save`, i.e. `p_save[2]`is an empty handle. How can I copy `p` so that when I modify `p`later on the copy `p_save` is not modified?
#DecisionOptimization#Support#SupportMigration