In MIPNODE callback: reliable way to detect variables fixed by branching in Python?
回答済みHello,
I am working on a custom lazy-constraint callback for a binary MIP and need to reliably identify which variables have been fixed to 0 or 1 by branching decisions at the current node.
What I would like to detect:
A variable x is fixed at the current node when its local lower bound = upper bound (LB = UB = 0 or LB = UB = 1).
Problem in Python:
The functions `cbGetNodeLB(var)` and `cbGetNodeUB(var)` do not exist in the gurobipy API.
The only per-variable information available in MIPNODE (when node LP is optimal) is `cbGetNodeRel(var)` which is the LP relaxation value at the node. Here is what I have tried.val = model.cbGetNodeRel(x[v])if abs(val - 0) <= 1e-6: fixed_to_0elif abs(val - 1) <= 1e-6: fixed_to_1
My questions:
- How can we detect fixed binary variables without relying on the integrality of the LP optimum?
- If this is not possible, is checking the LP value (within a small tolerance as above) a reliable proxy for identifying variables that are truly fixed due to branching or bound changes?
-
Hi Parisa,
need to reliably identify which variables have been fixed to 0 or 1 by branching decisions at the current node.
Unfortunately this is just not possible, and this is by design. Making this information available would compromise our IP.
If this is not possible, is checking the LP value (within a small tolerance as above) a reliable proxy for identifying variables that are truly fixed due to branching or bound changes?
No it would not, many variables will naturally be at a bound without having been branched upon.
If you need to work with this sort of information you want you will need to use an open source solver like SCIP. For example with their Python interface you can access local variable bounds:
https://pyscipopt.readthedocs.io/en/latest/api/variable.html
- Riley
1 -
Thank you! That is very helpful.
0
サインインしてコメントを残してください。
コメント
2件のコメント