Skip to content

Fix no results returned when no discrete variables are present in MindtPy#3861

Open
bernalde wants to merge 23 commits intoPyomo:mainfrom
tarikLG:main
Open

Fix no results returned when no discrete variables are present in MindtPy#3861
bernalde wants to merge 23 commits intoPyomo:mainfrom
tarikLG:main

Conversation

@bernalde
Copy link
Contributor

@bernalde bernalde commented Feb 24, 2026

Fixes #3855 .

Fixes #3855

Summary/Motivation:

This PR fixes an issue where MindtPy can short-circuit on “no discrete decisions” (LP/NLP) and then fails to reliably return a proper SolverResults and/or load primal values onto the input model, even when the direct LP/NLP solve succeeds. This behavior breaks downstream meta-solvers (e.g., GDPopt subproblem solves) that depend on Var.value to capture an incumbent.

Reference: #3855

MindtPy contains a validation/short-circuit path intended to directly solve models that do not require decomposition (e.g., LP/NLP, or models where all discrete variables are fixed). In this path, MindtPy may:

return None from solve() (bare return)

Changes proposed in this PR:

  • Ensure MindtPy always returns a SolverResults object (never None) even when the model is handled by the LP/NLP short-circuit.
  • Initialize and populate self.results before early exits, and propagate termination/status/message from the direct LP/NLP solve into MindtPy’s results.
  • Add a standalone test/test_mindtpy_no_discrete.py script

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.

Toflamus and others added 21 commits February 19, 2026 15:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Tarik Levent Guler <64302098+tarikLG@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Fix no results returned when no discrete variables are present in Min…
@bernalde bernalde marked this pull request as draft February 24, 2026 19:35
Black the format of pyomo/pyomo/contrib/mindtpy/algorithm_base_class.py
@bernalde bernalde marked this pull request as ready for review February 24, 2026 22:44
@Toflamus
Copy link
Contributor

Hi team,

I’ve investigated the current CI failures across Linux, macOS, and Windows. The failures in pyomo/contrib/solver/tests/solvers are not caused by the code changes in this PR.

The root cause is an expired GAMS license in the test environment. It appears the license might have expired a few days ago, which is why we are seeing identical failures across all platforms.

Interestingly, the tests for MindtPy are still passing (likely because they use different solver paths or have different fallback mechanisms), but the core solver tests are blocked.

Once the GAMS license is renewed in the CI environment, these tests should return to green.

@blnicho
Copy link
Member

blnicho commented Feb 25, 2026

@Toflamus we are aware of the issue and discussed it during the developer call today. This is indeed an infrastructure issue and we're working on getting it fixed.

@bernalde bernalde marked this pull request as draft March 3, 2026 18:51
@bernalde bernalde marked this pull request as ready for review March 3, 2026 18:51
@blnicho blnicho requested a review from emma58 March 3, 2026 19:48
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

❌ Patch coverage is 72.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.67%. Comparing base (bdb22dd) to head (fd70276).

Files with missing lines Patch % Lines
pyomo/contrib/mindtpy/algorithm_base_class.py 72.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3861      +/-   ##
==========================================
- Coverage   89.67%   89.67%   -0.01%     
==========================================
  Files         908      908              
  Lines      106735   106757      +22     
==========================================
+ Hits        95717    95734      +17     
- Misses      11018    11023       +5     
Flag Coverage Δ
builders 29.07% <4.00%> (-0.01%) ⬇️
default 85.95% <72.00%> (?)
expensive 35.51% <4.00%> (?)
linux 87.13% <72.00%> (-2.04%) ⬇️
linux_other 87.13% <72.00%> (-0.01%) ⬇️
oldsolvers 28.00% <4.00%> (-0.01%) ⬇️
osx 82.04% <72.00%> (-0.01%) ⬇️
win 85.55% <72.00%> (-0.01%) ⬇️
win_other 85.55% <72.00%> (-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.

MindtPy fails to return solutions for NLP or LP problem because of the short-circuit mechanism.

5 participants