Skip to content

Conversation

whart222
Copy link
Member

@whart222 whart222 commented Jul 9, 2025

Fixes #3513 (partially) .

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 michaelbynum and emma58 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
Copy link

codecov bot commented Jul 10, 2025

Codecov Report

Attention: Patch coverage is 90.61785% with 41 lines in your changes missing coverage. Please review.

Project coverage is 87.00%. Comparing base (10d6acc) to head (834cd95).

Files with missing lines Patch % Lines
pyomo/contrib/alternative_solutions/solnpool.py 88.54% 26 Missing ⚠️
pyomo/contrib/alternative_solutions/solution.py 90.09% 10 Missing ⚠️
pyomo/contrib/alternative_solutions/balas.py 81.81% 2 Missing ⚠️
...o/contrib/alternative_solutions/gurobi_solnpool.py 94.44% 2 Missing ⚠️
pyomo/contrib/alternative_solutions/aos_utils.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3657      +/-   ##
==========================================
- Coverage   89.05%   87.00%   -2.05%     
==========================================
  Files         890      820      -70     
  Lines      102617   101335    -1282     
==========================================
- Hits        91384    88167    -3217     
- Misses      11233    13168    +1935     
Flag Coverage Δ
builders ?
linux 86.78% <90.61%> (-2.03%) ⬇️
linux_other 86.78% <90.61%> (+<0.01%) ⬆️
osx 83.11% <90.61%> (+0.01%) ⬆️
win 84.99% <90.61%> (+0.01%) ⬆️
win_other 84.99% <90.61%> (+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.

🚀 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
Added checks and warnings for num_solutions as non-positive or 1 respectively
…de=1

Added num_solution checks and warnings for non-positive and 1 values respectively. Allowed PoolSearchMode=1 if users want, but included warning about unexpected behavior
Added checks to the policies supporting max_pool_size to error on non-positive pool size
The functionality to catch invalid policies already existed in PoolManager. Added the corresponding tests for invalid policies with and without extra arguments
Added methods to get the active pool name and the list of all pool names in the PoolManager and corresponding tests
Added the placeholder for the SolutionPoolBase so it can easily be retreived elsewhere without looking at the name of the subclass
Added methods to get the active pool and all pools policy and max_pool_sizes. Added corresponding tests
.pool -> .active_pool
._pool -> ._pools
Stresses the active pool in use and the tools to touch on multiple pools
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.

Adding solution pool functionality to Pyomo
2 participants