Skip to content

Fix bug in XpressDirect._load_slacks#3318

Merged
blnicho merged 3 commits intoPyomo:mainfrom
bknueven:xpress_slack_bug
Jul 24, 2024
Merged

Fix bug in XpressDirect._load_slacks#3318
blnicho merged 3 commits intoPyomo:mainfrom
bknueven:xpress_slack_bug

Conversation

@bknueven
Copy link
Copy Markdown
Contributor

Fixes N/A

Summary/Motivation:

Fixes a copy-paste bug in XpressDirect when slacks are loaded using PersistentSolver.load_slacks.

The bug correction collectly mirrors the behavior in XpressDirect._postsolve:

if extract_slacks:
vals = xprob.getSlack(xpress_cons)
for con, val in zip(xpress_cons, vals):
if con in self._range_constraints:
## for xpress, the slack on a range constraint
## is based on the upper bound
lb = con.lb
ub = con.ub
ub_s = val
expr_val = ub - ub_s
lb_s = lb - expr_val
if abs(ub_s) > abs(lb_s):
soln_constraints[con.name]["Slack"] = ub_s
else:
soln_constraints[con.name]["Slack"] = lb_s
else:
soln_constraints[con.name]["Slack"] = val

Changes proposed in this PR:

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
Copy Markdown
Contributor

@mrmundt mrmundt left a comment

Choose a reason for hiding this comment

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

HOORAY! Thank you for fixing the bug!

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 17, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.50%. Comparing base (92a9d3b) to head (81a42eb).
Report is 826 commits behind head on main.

Files with missing lines Patch % Lines
pyomo/solvers/plugins/solvers/xpress_direct.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3318   +/-   ##
=======================================
  Coverage   88.49%   88.50%           
=======================================
  Files         868      868           
  Lines       98436    98436           
=======================================
+ Hits        87115    87123    +8     
+ Misses      11321    11313    -8     
Flag Coverage Δ
linux 86.33% <0.00%> (ø)
osx 75.64% <0.00%> (ø)
other 86.52% <0.00%> (+<0.01%) ⬆️
win 83.83% <0.00%> (+<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.

@blnicho blnicho self-requested a review July 23, 2024 19:08
@blnicho blnicho merged commit f86ac9d into Pyomo:main Jul 24, 2024
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.

4 participants