Skip to content

Conversation

viens-code
Copy link
Contributor

Fixes #3725

Summary/Motivation:

Adds the ability to do best effort solution pool collection

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.

@viens-code
Copy link
Contributor Author

Is this a my code issue or an issue with win/3.9 and 3.13?
It didn't get to the pyomo tests and my only changes were in contrib.alternative_solutions

@mrmundt
Copy link
Contributor

mrmundt commented Sep 11, 2025

@viens-code - neither were related to your code. The 3.9 one was a spurious failure; the 3.13 one is now just happening everywhere (yay broken infrastructure). I'm looking into it.

Copy link
Member

@jsiirola jsiirola left a comment

Choose a reason for hiding this comment

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

One requested change for a test, but more fundamentally, why is this needed? Can't users get exactly the same behavior with

gurobi_generate_solutions(..., solver_options={'PoolSearchMode': 2})

Comment on lines 56 to 59
try:
gurobi_generate_solutions(m, pool_search_mode=0)
except AssertionError as e:
pass
Copy link
Member

Choose a reason for hiding this comment

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

This is a weak test: not only will any assertion that fails pass, but not raising any error at all will also pass. The recommended / standard way to test an error is to check both the error type and the message:

with self.assertRaisesRegex(AssertionError, "pool_search_mode must be 1 or 2"):
    gurobi_generate_solutions(m, pool_search_mode=0)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed over to the suggested format

@viens-code
Copy link
Contributor Author

First, will make the tweaks to the testing logic to update to your suggestion, thank you for that.

To the larger point, there are a couple of things going on with the alternative_solutions package.
One of which is trying to make the alternative solutions methods easier to use for people who couldn't/wouldn't write the custom functionality for themselves.

Yes an advanced user could change from enforced enumerate (mode 2) to best effort (mode 1) with the manual flag if they knew about it.
The functionality add here was about adding best-effort solution discovery as a clear option in contrib.alternative_solutions.

It also parallels how things like num_solutions are handled as parameters outside solver_options.
We could do solver_options={'PoolSolutions': num_solutions} instead there too.

@blnicho
Copy link
Member

blnicho commented Sep 17, 2025

@viens-code as you're working on additional changes, please make sure to merge main into your branch. This will resolve the win/3.13 failure which is coming from a testing infrastructure issue.

@viens-code
Copy link
Contributor Author

Changes to that test structure done

@viens-code
Copy link
Contributor Author

@mrmundt @blnicho
So we seem to have different failures on win/3.10, are these also just Pyomo CI issues like before?

@blnicho
Copy link
Member

blnicho commented Sep 22, 2025

@viens-code seems like it was a temporary CI issue. Re-running the win/3.10 job seems to have resolved it.

Copy link

codecov bot commented Sep 22, 2025

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.31%. Comparing base (e173cb5) to head (b65b5e0).

Files with missing lines Patch % Lines
pyomo/contrib/alternative_solutions/solnpool.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3726      +/-   ##
==========================================
- Coverage   89.31%   89.31%   -0.01%     
==========================================
  Files         896      896              
  Lines      103682   103688       +6     
==========================================
+ Hits        92605    92610       +5     
- Misses      11077    11078       +1     
Flag Coverage Δ
builders 29.10% <0.00%> (+<0.01%) ⬆️
default 85.93% <85.71%> (?)
expensive 35.86% <0.00%> (?)
linux 86.96% <85.71%> (-2.09%) ⬇️
linux_other 86.96% <85.71%> (-0.01%) ⬇️
osx 83.10% <85.71%> (+<0.01%) ⬆️
win 85.21% <85.71%> (-0.01%) ⬇️
win_other 85.21% <85.71%> (-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.

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.

Add support for Best Effort Solution Collection in Gurobi Solution Pool in Contrib.alternative_solutions
6 participants