Skip to content
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

Fix performance issue building large sparse linear operators #122

Merged
merged 1 commit into from
Oct 6, 2024

Conversation

odow
Copy link
Collaborator

@odow odow commented Oct 6, 2024

Closes #121

I think I had just assumed that people would build lots of small rows, rather than a big single complementarity constraint.

For n = 2048 I now get:

julia> @constraint(model, M * x .+ q  x)
[x[1] - 1, 2 x[1] + x[2] - 1, 2 x[1] + 2 x[2] + x[3] - 1, 2 x[1] + 2 x[2] + 2 x[3] + x[4] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + x[5] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + x[6] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + x[7] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + 2 x[7] + x[8] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + 2 x[7] + 2 x[8] + x[9] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + 2 x[7] + 2 x[8] + 2 x[9] + x[10] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + 2 x[7] + 2 x[8] + 2 x[9] + 2 x[10] + x[11] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + 2 x[7] + 2 x[8] + 2 x[9] + 2 x[10] + 2 x[11] + x[12] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + 2 x[7] + 2 x[8] + 2 x[9] + 2 x[10] + 2 x[11] + 2 x[12] + x[13] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + 2 x[7] + 2 x[8] + 2 x[9] + 2 x[10] + 2 x[11] + 2 x[12] + 2 x[13] + x[14] - 1, 2 x[1] + 2 x[2] + 2 x[3] + 2 x[4] + 2 x[5] + 2 x[6] + 2 x[7] + 2 x[8] + 2 x[9] + 2 x[10] + 2 x[11] + 2 x[12] + 2 x[13] + 2 x[14] + x[15] - 1, [[...4066 terms omitted...]], x[2034], x[2035], x[2036], x[2037], x[2038], x[2039], x[2040], x[2041], x[2042], x[2043], x[2044], x[2045], x[2046], x[2047], x[2048]] ∈ MathOptInterface.Complements(4096)

julia> @time optimize!(model)
  0.499948 seconds (26.03 k allocations: 297.203 MiB, 46.23% gc time)

@odow odow mentioned this pull request Oct 6, 2024
@odow odow merged commit a94619d into master Oct 6, 2024
9 checks passed
@odow odow deleted the od/large-sparse branch October 7, 2024 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Huge overhead using JuMP
1 participant