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 2114 #2119

Merged
merged 20 commits into from
Jan 11, 2025
Merged

Fix 2114 #2119

merged 20 commits into from
Jan 11, 2025

Conversation

jajhall
Copy link
Member

@jajhall jajhall commented Jan 9, 2025

Highs::getCols and (Highs::getRows) now should run in linear time if the matrix is stored column-wise (row-wise). Achieved without duplicated code by creating row/column agnostic getSubVectors and getSubVectorsTranspose in HighsLpUtils

@jajhall jajhall requested a review from galabovaa January 9, 2025 16:30
@galabovaa
Copy link
Contributor

Great! The failing workflows are fixed by #2112, please review it :)

@jajhall
Copy link
Member Author

jajhall commented Jan 9, 2025

This was meant to be a draft PR

@odow
Copy link
Collaborator

odow commented Jan 10, 2025

This branch is faster, but I still get (using my benchmark from #2114):

Running HiGHS 1.9.0 (git hash: 8787bebac): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 1000  0.02s user 0.01s system 89% cpu 0.026 total
Running HiGHS 1.9.0 (git hash: 8787bebac): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 2000  0.03s user 0.01s system 94% cpu 0.035 total
Running HiGHS 1.9.0 (git hash: 8787bebac): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 4000  0.08s user 0.01s system 97% cpu 0.094 total
Running HiGHS 1.9.0 (git hash: 8787bebac): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 8000  0.30s user 0.02s system 98% cpu 0.321 total
Running HiGHS 1.9.0 (git hash: 8787bebac): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 16000  1.03s user 0.04s system 99% cpu 1.068 total
Running HiGHS 1.9.0 (git hash: 8787bebac): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 32000  4.66s user 0.07s system 99% cpu 4.738 total

Ideally, if the matrix is stored in row-major, querying the row function should be O(1)? I want this benchmark to have O(N) scaling.

…rsTranspose by reference, not value; formatted
@odow
Copy link
Collaborator

odow commented Jan 11, 2025

Muuuuuch better! This looks great.

Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 1000  0.01s user 0.01s system 82% cpu 0.023 total
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 2000  0.01s user 0.00s system 91% cpu 0.018 total
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 4000  0.02s user 0.00s system 93% cpu 0.024 total
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 8000  0.03s user 0.01s system 95% cpu 0.037 total
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 16000  0.06s user 0.01s system 95% cpu 0.066 total
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 32000  0.11s user 0.01s system 96% cpu 0.120 total
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 64000  0.21s user 0.01s system 98% cpu 0.224 total
(base) oscar@MacBookPro HiGHS % time ./examples/main 128000
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 128000  0.42s user 0.02s system 98% cpu 0.444 total
(base) oscar@MacBookPro HiGHS % time ./examples/main 256000
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 256000  0.88s user 0.04s system 98% cpu 0.931 total
(base) oscar@MacBookPro HiGHS % time ./examples/main 512000
Running HiGHS 1.9.0 (git hash: a5f01ca95): Copyright (c) 2025 HiGHS under MIT licence terms
./examples/main 512000  1.62s user 0.07s system 98% cpu 1.704 total

@jajhall jajhall merged commit 5886353 into latest Jan 11, 2025
272 checks passed
@jajhall jajhall deleted the fix-2114 branch January 11, 2025 01:23
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.

3 participants