Originally posted by: BrunoAsiv
Hi,
I'm trying to solve multiple very similar models in a user cut callback and I'm wondering what is the most efficient between rebuilding the model every time or simply modifying the existing model. Here's a brief outline of what needs to change between models based on the code structure:
loop 1
{
loop 2
{
change the right hand term of |N| + |A| constraints
loop 3
{
set the coefficient of a variable to 0 in the objective function;
set the coefficient of a variable to 1 in the objective function;
add a constraint where one variable == 0;
remove a constraint where one variable == 0;
solve the instance and calculate cuts;
}
}
}
In my current code, instead of changing the right hand terms of the constraints, I actually remove them and rebuild them (I didn't notice at first I only needed to change the rht). Removing the constraints from the model has proven to be extremely slow which is why I'm asking this question.
To give an idea of the number of constraints: my models are based on a graph G=(N,A) where |N| is the number of nodes and |A| is the number of arcs. I have a total of |N| + |A| constraints of which I need to modify the right hand term.
Also, if I were to simply modify the model between each instance, which function would set the right hand term of the IloExpr representing my constraints ?
Thank you.
#CPLEXOptimizers#DecisionOptimization