Repository navigation
Add addConsLinear() to avoid creating expressions in MILPs - #1273
Open
Joao-Dionisio wants to merge 1 commit into
Open
Joao-Dionisio wants to merge 1 commit into
Joao-Dionisio wants to merge 1 commit into
Conversation
addConsLinear() for avoiding creating expressions in MILPs addConsLinear() to avoid creating expressions in MILPs
Member
Author
|
Despite the numbers we started from being already pretty small, this often matters in industrial applications. We academics may be used to the actual solving to take most of the solving time, but often the problems are actually super easy if presolving detects a certain structure, they're just huge. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I've been running some experiments comparing the performance of different Python interfaces. PySCIPOpt lands in a pretty nice second place, behind only OR-Tools. Still, why not try to get first place? :)
For each nonzero,
quicksum(a * x[j] for ...)builds a newExpr, hashes aTerm, and inserts it into a dict.addConsthen goes throughExprConsand iterates that dict again to fill the C arrays. OR-Tools does a single C++ call per coefficient (ct.SetCoefficient(x[j], a)) and creates no Python objects.In this PR, I'm adding an
addConsLinear()function, similar to whataddConsKnapsack()andaddConsSOS1()do, adding the constraints directly while skipping the expression building.I locally timed the building 13 MIPLIB 2017 instances with more than 100k nonzeros each. Here are the results:
quicksum+addCons(s)addConsLinear(s)PS: In my tests, the matrix API is not faster than just using normal loops.
@Zeroto521 would you mind taking a look, please?