0

I'm using the Gurobi Python interface gurobipy. I have a model formulation with a lot of variables. I would like to initialize less important variables that are supposed to be binary as continuous variables, and to change them to binary when needed. However, this will not happen very often.

I have tried the solution from the answer to a similar question, but this needs to rebuild the model. Rebuilding the model in the callback routine at GRB.Callback.MIPSOL causes a crash.

Is this possible? Or am I supposed to introduce all variables as binary, and deal with these cases in GRB.Callback.MIPNODE?

1 Answer 1

2

Gurobi Optimizer does not support changing variable types (VType attribute) inside a callback. The better way to handle the "less important variables" is to set their BranchPriority attribute to a negative value (< 0).

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your quick response! I'm setting the branching priority by hand already, and the less important variables all have branching priority 1, whereas the others have higher values. Does this achieve the same goal, or is there something special about negative branching priorities that I'm missing?
The key issue is that the low priority variables should have a smaller value of BranchPriority; I assumed you used the default value of BranchPriority (0) for all other variables.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.