Skip to content

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.

# even if SCIP's internal quadratic representation does not expose
# all linear coefficients explicitly.
if PyCons.data is None:
PyCons.data = quadcons.expr
Copy link
Member

Choose a reason for hiding this comment

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

We cannot get the data from SCIP instead of this added complexity?

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)

2 participants