Skip to content

[codex] Refine MindtPy no-discrete short-circuit routing#1

Merged
bernalde merged 4 commits intointernal/mindtpy-short-circuit-basefrom
mindtpy-short-circuit-routing-followup
Apr 7, 2026
Merged

[codex] Refine MindtPy no-discrete short-circuit routing#1
bernalde merged 4 commits intointernal/mindtpy-short-circuit-basefrom
mindtpy-short-circuit-routing-followup

Conversation

@bernalde
Copy link
Copy Markdown
Owner

@bernalde bernalde commented Apr 6, 2026

Summary

  • reuse structure already classified during MindtPy utility-block setup instead of re-walking constraint polynomial degree in the no-discrete short-circuit path
  • classify continuous short-circuit models as LP, QP, QCP, or NLP and route QP/QCP cases to the configured mip_solver only when that solver interface explicitly supports the required quadratic structure
  • preserve the current no-fallback-on-failure behavior and mirror direct-solve results against the objective on the original model

Root cause

The no-discrete short-circuit path was doing two things that made future routing work harder:

  • it duplicated structural analysis that had already happened during utility-block setup
  • it treated every continuous non-LP model as an NLP, so continuous QP/QCP models never used the configured MIP solver even when that solver could handle them directly

Impact

This keeps the short-circuit path scoped and predictable while enabling capability-aware routing for continuous quadratic models. Unsupported quadratic cases still go through the NLP solver, and MIP failures are not silently retried with NLP.

Validation

  • Black formatting verified in the active conda base environment for the touched files
  • conda run -n base python -m pytest pyomo/contrib/mindtpy/tests/test_mindtpy_no_discrete.py -q

bernalde pushed a commit that referenced this pull request Apr 6, 2026
* TXP-7757: removed most deprecation warnings up to current unpublished release

* Fixed more warnings

* Missing version agnostic functions

* Fixed version specific LPStatus enums + renamed get-lb/ub methods

* Suggested improvements
bernalde pushed a commit that referenced this pull request Apr 6, 2026
bernalde pushed a commit that referenced this pull request Apr 6, 2026
Removed the tabulate dependency and replaced it with simple logger output.
Fixed _solve_GDP_subproblem so primal_bound is None when the solver fails (not just on preprocessing infeasibility).
bernalde pushed a commit that referenced this pull request Apr 6, 2026
[Xpress] Remove deprecation warnings (#1)
Copy link
Copy Markdown
Owner Author

@bernalde bernalde left a comment

Choose a reason for hiding this comment

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

Overall the classification and routing logic is sound and the new tests are well-structured. The main concern is a subtle overlap in the new constraint lists that, while currently harmless, will mislead readers and could easily cause counting bugs. A few smaller items follow.

All 22 tests pass (including the 6 integration tests against ipopt + appsi_highs). The broader MindtPy suite (78 tests) also passes without regressions.

Copy link
Copy Markdown
Owner Author

bernalde commented Apr 7, 2026

I addressed the actionable review items in a014410. The main behavioral change is that the direct-solve structure cache now uses boolean structural flags instead of overlapping lists, which keeps short-circuit classification independent of quadratic_strategy without ambiguous list membership. I also removed the eager objective-degree lookup, hoisted the duplicated problem-type label map, added the HiGHS TODO note, renamed the generic test fake, and added regression coverage for LP routing, the QCP plus unsupported quadratic-objective branch, and the quadratic_strategy == 2 structural case. Validation on this branch was conda run -n base python -m pytest pyomo/contrib/mindtpy/tests/test_mindtpy_no_discrete.py -q, which now passes with 25 tests.

Copy link
Copy Markdown
Owner Author

@bernalde bernalde left a comment

Choose a reason for hiding this comment

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

All six items from the first review are addressed. Tests grew from 22 to 25 and all pass, including the integration tests against ipopt + appsi_highs. The broader MindtPy suite (81 tests) also passes without regressions.

The switch from full lists to boolean flags for quadratic/nonquadratic classification is a clean simplification that eliminates the overlap concern entirely. The new test_short_circuit_qcp_detection_ignores_quadratic_strategy test is a good addition that directly validates the interaction between quadratic_strategy=2 and the short-circuit routing.

One minor remaining nit below, otherwise this looks good to go.

Copy link
Copy Markdown
Owner Author

bernalde commented Apr 7, 2026

I did a full pass over this PR and one additional cleanup stood out before it goes upstream: the docstrings around the no-discrete short-circuit path in pyomo/contrib/mindtpy/algorithm_base_class.py still described only LP/NLP behavior, even though this branch now classifies and routes continuous models as LP/QP/QCP/NLP and may use either the configured MIP solver or the NLP solver. That cleanup is now addressed in da366fb, which updates the model_is_valid() and _mirror_direct_solve_results() docstrings to match the implemented behavior.

Copy link
Copy Markdown
Owner Author

@bernalde bernalde left a comment

Choose a reason for hiding this comment

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

The classification and routing logic is sound, the switch from parallel constraint lists to boolean flags is cleaner, and the test suite is well-structured. The items below are what I found after a pass through the final state of the branch.

- Fix stale Returns docstring in model_is_valid: LP, QP, QCP, or NLP
- Defer working_obj fetch into the obj_degree is None fallback branch
- Add Parameters section to _classify_short_circuit_problem docstring
- Add comment in _mip_solver_supports_capability explaining that unknown
  APPSI solvers fall through conservatively to return False
- Add test_short_circuit_mixed_degree_model_routes_to_nlp to cover the
  case where both has_quadratic_constraints and has_nonquadratic_constraints
  are True (model with quadratic and cubic constraints must route to NLP)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bernalde bernalde marked this pull request as ready for review April 7, 2026 13:45
@bernalde bernalde merged commit b9fa6fd into internal/mindtpy-short-circuit-base Apr 7, 2026
9 of 10 checks passed
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.

1 participant