-
-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance of small constraints #1654
Comments
The following test may help in testing performance. It includes large non-convex QCQP feasibility problems from the power system domain, which can be solved with Ipopt. At the time of writing this model build times are similar in time to the solve time, about 2 seconds and 1 second respectively. @mlubin did a quick review. He found type annoations and the @expression macro could provide a 20% performance boost, but thought that overall model build time is most likely related to this issue. |
Closing this for a few reasons:
I think in this case we're going to be unavoidably slower than 0.18, but that's a trade-off we made for using OrderedDict instead of pushing terms into a vector and then processing them later. |
This came up again in #3729. We should investigate other approaches for having a "small dict" as the backing data structure in AffExpr for the common case of an affine expression with one or two elements. (See MOI.Utilities.CleverDict for a related example.) |
Not a huge offender, but here is yet another common usage of small constraints: https://github.com/TulipaEnergy/TulipaEnergyModel.jl/blob/72889d1642c3bc3b1f12b624031b2d6b5d6cca87/src/constraints/transport.jl#L65 |
Creating small constraints like
is rather costly compared to JuMP v0.18. The reason is that creating a
OrderedDict
of two elements is a lot slower than creating aVector
of two elements:Maybe we could create a custom dict optimized for a small number of elements that would not create the internal dictionary if there is 2 elements or less.
That would avoid creating a dictionary for small number of elements.
The text was updated successfully, but these errors were encountered: