Fix outer/inner bound assignment for maximization in amalgamator - #837
Open
DLWoodruff wants to merge 1 commit into
Open
Fix outer/inner bound assignment for maximization in amalgamator#837DLWoodruff wants to merge 1 commit into
DLWoodruff wants to merge 1 commit into
Conversation
The assignment branched on is_minimizing, but both branches assigned the same values; only the order of the two statements differed. For a maximization model the solver's Upper bound is the relaxation (outer) bound and the Lower bound is the incumbent (inner) bound, so the else branch had them backwards. This mirrors the handling already in spopt.py, which branches correctly. Minimization is unaffected. Fixes Pyomo#836 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #837 +/- ##
=======================================
Coverage 77.77% 77.78%
=======================================
Files 177 177
Lines 23764 23764
=======================================
+ Hits 18482 18484 +2
+ Misses 5282 5280 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #836.
In
Amalgamator.run, thebest_outer_bound/best_inner_boundassignment branched onis_minimizing, but both branches assigned the same right-hand sides — only the order of the two statements differed, which has no effect. For a maximization model the solver'sUpper boundis the relaxation (outer) bound and theLower boundis the incumbent (inner) bound, so theelsebranch had them backwards.The fix mirrors the handling already in
mpisppy/spopt.py(lines 370-373 and 432-437), which branches on the sense correctly. Minimization is unaffected, since theifbranch was already right.Why it matters
ciutils.gap_estimatorstakes the batch optimum asama_object.best_outer_bound. On a maximization model that was the incumbent rather than the relaxation bound, so the batch gap lost the conservative direction it is meant to have; that feeds the MMW confidence interval inmmw_ci.pyand the sequential-sampling drivers.Scope and testing
Deliberately minimal: two right-hand sides, plus a comment on why the mapping depends on the sense.
I have not added a regression test. The existing amalgamator tests all require a solver and a full EF solve, so covering this would mean adding a maximization example model and gating the test on solver availability — disproportionate to a two-line fix, and a maintainer call rather than mine. If you would like the coverage, the cheaper route is the one the
#TBD : Write a function doing thiscomment already suggests: extract the sense-to-bound mapping into a small helper shared withspopt.py, which would make it unit-testable with no solver at all. Happy to do that in a follow-up if you want it.Verified that
ruff check mpisppy/utils/amalgamator.pyreports the same 9 pre-existing findings before and after, so the change is lint-neutral.🤖 Generated with Claude Code