Skip to main content

Against all common sense I attempted (a special type of) branch-and-price. How am I shooting myself in the foot, exactly?




  • Official comment
    Tobias Achterberg
    Gurobi Staff Gurobi Staff

    You are adding variables with model.addVar() from within your callback? This just cannot work. What you have in your hand as a user is the original user model. But the branch-and-cut is performend on a different model, namely the presolved model. Moreover, the LP relaxation is yet another model. Even if you could modify the user model from within your callback, there is nothing in Gurobi's source code that would then transfer the changes to the presolved model and to the LP relaxation.

    I would claim that the model.addVar() call is just doing nothing (except raising the exception). How do you see that the variables are added to the model (your point 8)?



  • Alberto Santini

    Hi Tobias.

    First of all, thanks for replying and the explanation. I was checking point 8. from calling \(\texttt{model.write()}\) at the end, but then I must have been mistaken.

    So, just to be clear: there is no way (hacky or legitimate) to add a variable to a model once it's being solved, even if this variable is continuous and valid in all nodes of the tree, right? Even if I add a callback, copy the model, fix the variables, get the duals and solve a pricing subproblem, then I have absolutely no way to insert the resulting column back into the model while it is solved, right? If I were to abort the optimisation, add the column, and call \(\texttt{optimize()}\) again, would I lose all information about the B&B tree generated up to that point?



Please sign in to leave a comment.