Skip to content

getTermsQuadractic correctly returns linear terms#1132

Merged
Joao-Dionisio merged 13 commits intomasterfrom
getTermsQuadractic
Feb 3, 2026
Merged

getTermsQuadractic correctly returns linear terms#1132
Joao-Dionisio merged 13 commits intomasterfrom
getTermsQuadractic

Conversation

@Joao-Dionisio
Copy link
Member

Fix #1083

I also added getVarFarkasCoef() because I was to lazy to rebase. Still no test, as a more convoluted pricer would need to be implemented (see the end of the previous sentence).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #1083 where getTermsQuadratic() was not correctly returning all linear terms for variables that also appear in quadratic or bilinear terms. The fix stores the original polynomial expression in the constraint's data attribute and uses it to reconstruct all linear coefficients. Additionally, the PR adds a new getVarFarkasCoef() method for retrieving Farkas coefficients, though this remains untested.

Key Changes

  • Modified getTermsQuadratic() to return all linear coefficients by recovering them from the original expression stored in Constraint.data
  • Added storage of original Expr objects in quadratic constraints to preserve full coefficient information
  • Added new getVarFarkasCoef() method with declaration in the header file

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
tests/test_nonlinear.py Adds comprehensive test for mixed linear/quadratic constraints to validate that getTermsQuadratic() now correctly returns all linear terms
src/pyscipopt/scip.pxi Implements the fix by storing original expressions in constraint data and extracting linear terms from them; adds new getVarFarkasCoef() method
src/pyscipopt/scip.pxd Declares the external SCIP function SCIPgetVarFarkasCoef
CHANGELOG.md Documents the fix and addition of the new method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@DominikKamp
Copy link
Contributor

Otherwise, this looks okay for now.

Joao-Dionisio and others added 2 commits February 3, 2026 16:31
Co-authored-by: DominikKamp <130753997+DominikKamp@users.noreply.github.com>
@Joao-Dionisio Joao-Dionisio merged commit 95f8261 into master Feb 3, 2026
3 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.

BUG: in linearterms of function Model.getTermsQuadratic(cons)

3 participants