Skip to content

Conversation

michaelbynum
Copy link
Contributor

@michaelbynum michaelbynum commented Aug 12, 2025

Summary/Motivation:

This PR refactors the gurobi interfaces to achieve two goals:

  • reduce duplicate code
  • use the new contrib.observer package

Changes proposed in this PR:

  • create a directory for gurobi now that there are 3 files
  • create a base class for all of the interfaces that use gurobipy, making the direct and persistent interfaces more consistent (e.g., tc_map, postsolve, solve, mipstart)
  • modify the persistent interface to use the contrib.observer package
  • add mipstart functionality to gurobi direct
  • add a minimum gurobipy version to the direct interface (addMConstr was not added until version 9)
  • extract some of the code out of the persistent interface to create a direct interface that can be used without the overhead of the observer
  • simplified some of the persistent interface

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

codecov bot commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 90.01289% with 155 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.97%. Comparing base (2ca7dfb) to head (cfa8633).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...contrib/solver/solvers/gurobi/gurobi_persistent.py 89.82% 80 Missing ⚠️
pyomo/contrib/observer/model_observer.py 88.25% 58 Missing ⚠️
...ontrib/solver/solvers/gurobi/gurobi_direct_base.py 91.05% 11 Missing ⚠️
...omo/contrib/solver/solvers/gurobi/gurobi_direct.py 96.39% 4 Missing ⚠️
pyomo/contrib/observer/component_collector.py 94.28% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3698      +/-   ##
==========================================
+ Coverage   85.94%   87.97%   +2.03%     
==========================================
  Files         892      895       +3     
  Lines      103018   103616     +598     
==========================================
+ Hits        88535    91156    +2621     
+ Misses      14483    12460    -2023     
Flag Coverage Δ
builders 26.75% <22.87%> (+0.02%) ⬆️
default 85.79% <89.81%> (?)
expensive 34.04% <23.00%> (?)
linux 69.98% <43.26%> (-15.87%) ⬇️
linux_other 69.98% <43.26%> (?)

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.

2 participants