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

Sort indices while removing constraints to fix #3127 #3281

Merged
merged 4 commits into from
Jul 9, 2024

Conversation

kutlay
Copy link
Contributor

@kutlay kutlay commented Jun 2, 2024

Fixes #3127

Summary/Motivation:

Issue 3127 showed that HiGHs solution was different when the same variable was fixed and unfixed. A solution should not change after fixing and unfixing the same variable. The issue showed the hint that HiGHs solver was expecting the deleted row indices to be sorted. This fix sorts the indices before sending it to the solver.

Unfortunately, HiGHs code doesn't explain why the indices supplied to deleteRows need to be sorted: https://github.com/ERGO-Code/HiGHS/blob/13363c9f1252b015cf6527132eb9cf8f4b5bf020/src/lp_data/Highs.cpp#L2871-L2883

However, the error message indicates that they need to be sorted, so I can't think of any problems sorting the indices in pyomo other than slight degradation in performance because of sorting.

Changes proposed in this PR:

  • Sort indices before sending to the solver to be removed
  • Test the fix / unfix functionality

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

Copy link
Member

@jsiirola jsiirola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty reasonable. Thank you!

Two really minor updates to the test and I think this can be merged.

@kutlay
Copy link
Contributor Author

kutlay commented Jun 4, 2024

@jsiirola Thank you for the help! Changes are done and it should be good to go now.

@mrmundt
Copy link
Contributor

mrmundt commented Jun 13, 2024

@kutlay - can you please install the latest version of black and run black -S -C on your code? Thank you!

@kutlay
Copy link
Contributor Author

kutlay commented Jun 18, 2024

@mrmundt sorry for the delay, the black reformatting is done. You can kick off the workflow again.

@mrmundt
Copy link
Contributor

mrmundt commented Jun 18, 2024

@kutlay - FYI, the pypy job will fail, but it's not your fault.

@blnicho blnicho requested a review from emma58 July 2, 2024 19:10
@blnicho
Copy link
Member

blnicho commented Jul 8, 2024

We're waiting for Jenkins to run on this before merging.

Copy link

codecov bot commented Jul 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.46%. Comparing base (53d5cad) to head (072c2c5).
Report is 912 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3281      +/-   ##
==========================================
+ Coverage   86.46%   88.46%   +1.99%     
==========================================
  Files         801      867      +66     
  Lines       96758    98214    +1456     
==========================================
+ Hits        83661    86883    +3222     
+ Misses      13097    11331    -1766     
Flag Coverage Δ
linux 86.27% <ø> (ø)
osx 75.56% <ø> (ø)
other 86.46% <ø> (+<0.01%) ⬆️
win 83.76% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mrmundt mrmundt merged commit 86aa282 into Pyomo:main Jul 9, 2024
32 checks passed
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.

HiGHS solver does not update the model correctly after variable fix/unfix
5 participants