Remove constraints in LP solver #4506
Replies: 2 comments 2 replies
-
you can change the bounds of the variables directly, no need to add a constraint. |
Beta Was this translation helpful? Give feedback.
-
You can delete variables/constraints with the MathOpt API. However, many sovlers (including GLOP/Gurobi) are not so fast at doing incremental solves in response to a deletion, IIRC (I haven't looked at this in a few years). If you are only deleting a single varaible, it is often faster to force it to be zero instead by changing the bounds. If you have a large number of deletions to do (cut/column management) and memory is an issue, deletion makes more sense (you still may want to batch the deletions, this is solver dependent). |
Beta Was this translation helpful? Give feedback.
-
I'm a teaching assistant for a course on constraint programming where we'd like students to implement the Branch&Bound algorithm using OR-Tools as a LP solver backend. To do so it would be nice if OR-Tools exposed an interface to remove constraints.
As far as I can see there's no way to remove constraints from a LP solver. Ideally I'd like to do something like:
What's the best (if any) way to accomplish this? I tried to just rebuild the entire model anytime a constraint needed to be removed but that led to seg faults.
I'm using the Python bindings for the latest version of OR-Tools. If a solution is exposed in the Java bindings (nothing that I could see from the documentation) that would be fine as well.
#3926 discusses the same issue but doesn't provide a response as the author of that thread had different objectives.
Beta Was this translation helpful? Give feedback.
All reactions