Skip to content

Fix getOrdering equality expansion - #494

Open
ewu63 wants to merge 12 commits into
mainfrom
fix/getordering-nonlinear-equality-expansion
Open

ewu63 wants to merge 12 commits into
mainfrom
fix/getordering-nonlinear-equality-expansion

Conversation

@ewu63

@ewu63 ewu63 commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

Purpose

There was a bug in the code that converts a single two-sided constraint to two one-sided constraints, for optimizers that cannot handle two-sided constraints directly (CONMIN, Egor, NSGA2). This meant that for these optimizers, optimization problems with nonlinear equality constraints where the constraint value is not zero could result in erroneous optimization solution. This was reproduced on the hs060 problem (added here) with Egor, where without the bugfix the solution was reported as [0.35, 0.34, 0.35] instead of [1, 1, 1].

Expected time until merged

A few days.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Testing

Added unit and regression tests.

Checklist

  • I have run ruff check and ruff format to make sure the Python code adheres to PEP-8 and is consistently formatted
  • I have formatted the Fortran code with fprettify or C/C++ code with clang-format as applicable
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@ewu63
ewu63 requested a review from marcomangano as a code owner September 23, 2026 07:06

@marcomangano marcomangano left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is the NLPQLP test failure a matter of convergence?
Also, see my comment below

lower.extend(econ["value"])
upper.extend(econ["value"])
lower.extend([-INFINITY] * len(econ["fact"]))
upper.extend(-econ["value"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Took me a second to figure the math out because I missed the change in sign of the factor. Should we add a short comment to explain? If I get this right:
a=b -> a<=b && a>=b -> a<=b && -a=<-b

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Expanded comments. Yes you are exactly correct

@codecov

codecov Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.04%. Comparing base (c791384) to head (e7a8ef2).

Files with missing lines Patch % Lines
tests/test_optProb.py 0.00% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #494      +/-   ##
==========================================
- Coverage   54.22%   51.04%   -3.18%     
==========================================
  Files           1        1              
  Lines         225      239      +14     
==========================================
  Hits          122      122              
- Misses        103      117      +14     

☔ View full report in Codecov by Harness.
📢 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.

@ewu63
ewu63 force-pushed the fix/getordering-nonlinear-equality-expansion branch from f558122 to 03001b8 Compare September 26, 2026 23:28
@ewu63
ewu63 requested a review from marcomangano September 26, 2026 23:28
@ewu63
ewu63 requested a review from sabakhshi September 30, 2026 06:59
@marcomangano
marcomangano requested a review from a team as a code owner November 17, 2026 17:21
@ewu63

ewu63 commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@sabakhshi @sanjan98 can one of you review this PR?

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