Gurobi - Branch Priority

I wish I could use the Gurobi attribute “Branch Priority”. So I tried to use it that way and it gave an error. Is there a smarter way to do this?

MOI.set(model,Gurobi.ModelAttribute("BranchPriority"), u)

u is the variable that I want to branch on

Thanks in advance!

You need to pass a value for this attribute, not just the variable u; see the Gurobi documentation.

There is an example in the Gurobi.jl tests with the correct MOI syntax.
Just don’t forget to pass an integer value for BranchPriority, e.g.:

MOI.set(model, Gurobi.VariableAttribute("BranchPriority"), u, 1)

The function signature is also shown in the MOI docs:

set(model::ModelLike, attr::AbstractVariableAttribute, v::VariableIndex, value)
1 Like

Thanks a lot!!!