Skip to content

Conversation

@whart222
Copy link
Member

@whart222 whart222 commented Jul 9, 2025

Fixes N/A (partially addresses #3513) .

Summary/Motivation:

The alternative_solutions contrib package includes a rudimentary solution pool object. This PR includes a more comprehensive capability for defining and managing solution pools.

Changes proposed in this PR:

  • PyomoPoolManager - Manages pools for Pyomo solutions
  • SolutionPool* - Classes used to define various solution pools
  • Functions in pyomo.contrib.alternative_solutions now use and return PyomoPoolManager instances.
  • PyomoSolution - Function that returns a Solution object given Pyomo model data

NOTE: This is a WIP PR. I'm submitting this now to help define expectations for finalizing this new capability.

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.

@whart222 whart222 requested review from emma58 and michaelbynum July 9, 2025 09:15
@whart222 whart222 marked this pull request as draft July 9, 2025 09:16
whart222 added 3 commits July 9, 2025 05:19
Use the Pyomo Bunch class as an alias for Munch, to avoid
introducing an additional Pyomo dependency.
@whart222
Copy link
Member Author

whart222 commented Jul 9, 2025

Note that this PR now includes updates to the Bunch class defined in pyomo.common. I have been using the public Munch class, but these revisions align the Bunch API with Munch.

whart222 added 10 commits July 9, 2025 06:38
Avoiding use of KW_ONLY, which is an internal mechanism
Using new serialization API, which is simpler. :)
1. Reworking solver matrix logic

2. Fixing test to benchmark against the solution values
@codecov
Copy link

codecov bot commented Jul 10, 2025

Codecov Report

❌ Patch coverage is 88.54962% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.32%. Comparing base (13facca) to head (f2ad6c0).
⚠️ Report is 89 commits behind head on main.

Files with missing lines Patch % Lines
pyomo/contrib/alternative_solutions/solnpool.py 90.87% 25 Missing ⚠️
...mo/contrib/alternative_solutions/gurobi_lp_enum.py 13.33% 13 Missing ⚠️
pyomo/contrib/alternative_solutions/solution.py 92.52% 8 Missing ⚠️
pyomo/contrib/alternative_solutions/balas.py 76.47% 4 Missing ⚠️
...o/contrib/alternative_solutions/gurobi_solnpool.py 90.90% 4 Missing ⚠️
pyomo/contrib/alternative_solutions/aos_utils.py 85.00% 3 Missing ⚠️
pyomo/contrib/alternative_solutions/lp_enum.py 78.57% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3657      +/-   ##
==========================================
- Coverage   89.40%   89.32%   -0.09%     
==========================================
  Files         909      910       +1     
  Lines      105541   105935     +394     
==========================================
+ Hits        94364    94631     +267     
- Misses      11177    11304     +127     
Flag Coverage Δ
builders 29.11% <30.91%> (+<0.01%) ⬆️
default 85.96% <87.40%> (?)
expensive 35.75% <30.91%> (?)
linux 86.65% <88.54%> (-2.53%) ⬇️
linux_other 86.65% <88.54%> (-0.08%) ⬇️
osx 82.81% <88.54%> (-0.06%) ⬇️
win 84.91% <88.54%> (-0.07%) ⬇️
win_other 84.91% <88.54%> (-0.07%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Added non-positive error check and value 1 warning for num_solutions in balas
Added num_solution error if num_solutions is non-positive, warning if num_solutions =1
@whart222 whart222 requested a review from mrmundt November 20, 2025 16:15
@whart222
Copy link
Member Author

It's not obvious to me why the linux slim tests are failing. Do we need to conditionally import numpy?

@blnicho
Copy link
Member

blnicho commented Nov 25, 2025

It's not obvious to me why the linux slim tests are failing. Do we need to conditionally import numpy?

@whart222 yes, numpy needs to be treated as an optional dependency so tests relying on numpy need to be skipped when it's not available.

skipif needs to come *after* the parameterize decorator
@mrmundt
Copy link
Contributor

mrmundt commented Jan 9, 2026

@whart222 - Should this PR be closed, given the followup to our discussion last month?

@blnicho blnicho closed this Jan 21, 2026
@github-project-automation github-project-automation bot moved this from Review In Progress to Done in Pyomo 6.10 Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants