pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

Sort indices while removing constraints to fix #3127

Open kutlay opened this issue 1 year ago • 4 comments

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.

kutlay avatar Jun 02 '24 04:06 kutlay

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

kutlay avatar Jun 04 '24 01:06 kutlay

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

mrmundt avatar Jun 13 '24 14:06 mrmundt

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

kutlay avatar Jun 18 '24 11:06 kutlay

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

mrmundt avatar Jun 18 '24 13:06 mrmundt

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

blnicho avatar Jul 08 '24 20:07 blnicho

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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%) :arrow_up:
win 83.76% <ø> (+<0.01%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 09 '24 05:07 codecov[bot]