Customized branching rule



1 comment

  • Jaromił Najman

    Hi Amin,

    1. What are the fundamental differences between BranchPrioirty and VarBranch?

    With the VarBranch parameter you can set the metric used for variable selection when branching. Setting a BranchPriority provides the user the possibility to manually increase or decrease the importance of a variable w.r.t. to branching. This means that by increasing the BranchPriority attribute for a specific variable (\x\) tells Gurobi to branch on (\x\) more often.

    2. Is a simple example available that helps me to figure out how to change the attributes? ( For instance, for the variable vector (y_1, ... y_100), how can I change attributes for all y_i?)

    You can set the parameter VarBranch via the setParam function. You can set the BranchPriority attribute via the variable setAttr function. One possible way to set the attribute would be

    y = m.addVars(100, vtype=GRB.BINARY, name="y")
    for i in range(100):

    3. Does changing the attributes mentioned above improve the effect of the B&B in practice?

    It depends on the given problem. Setting branching priority values can have drastic effects on the optimization time if you have certain knowledge on the variable importance, e.g., you know that the complexity of the problem mainly depends on a few integer variables so it might help to branch on the first.
    A general statement cannot be made for the VarBranch parameter, so it is best to experiment with this parameter on your own.

    I need to branch on variable y to see if Gurobi finds the optimal solution faster or not.

    If it is only 1 binary variable, you should consider formulating 2 problems with fixed (\y\) values and solve them independently.

    Best regards,

    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk