Skip to content

Fix original constraint duals and presolve consistency - #1256

Merged
Joao-Dionisio merged 9 commits into
scipopt:masterfrom
mohitt31:dual-original-transformed-cons
Oct 18, 2026
Merged

Joao-Dionisio merged 9 commits into
scipopt:masterfrom
mohitt31:dual-original-transformed-cons

Conversation

@mohitt31

@mohitt31 mohitt31 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

getDualsolKnapsack() and getDualfarkasKnapsack() looked up the wrong constraint representation, so passing an original binding constraint returned zero instead of its transformed constraint's dual. Both now retrieve the transformed constraint before calling SCIP. getVarsAnd() also used a tuple assertion that could never fail; the assertion now rejects non-AND constraints.

When presolve removes a constraint's transformed counterpart, the linear, logicor and knapsack dual/Farkas accessors consistently return 0.0, as requested in review. The linear and logicor methods no longer try to wrap a null SCIP_CONS* in a Python Constraint. The behavior is documented and recorded in the changelog.

Tests cover nonzero knapsack dual/Farkas values through original and transformed constraints, rejection of a non-AND constraint, and all six combinations of linear/logicor/knapsack dual/Farkas accessors after presolve removes the transformed constraint. The new removed-constraint tests reproduced four failures before the consistency fix, while the two knapsack cases already passed.

Validation with SCIP 10.0.3 on macOS/ARM64: full test suite 477 passed, 108 skipped, 11 xfailed; tests/test_cons.py 33 passed, 1 xfailed. Built the Cython extension against the local SCIP library. git diff --check passes.

Follow-up to the review on #1255.

mohitt31 and others added 3 commits September 15, 2026 16:32
getDualsolKnapsack and getDualfarkasKnapsack looked up the transformed
constraint the wrong way round, so an original constraint was passed to
SCIP directly and the dual came back as 0. Follow the linear versions
instead, and return 0 when presolve has removed the constraint and there
is no transformed one to read from.

getVarsAnd asserted a two-element tuple, which never fails. Drop the
parentheses so a non-AND constraint is rejected.
@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.93%. Comparing base (9547994) to head (c19280e).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1256      +/-   ##
==========================================
+ Coverage   57.91%   57.93%   +0.02%     
==========================================
  Files          26       27       +1     
  Lines        5807     5998     +191     
==========================================
+ Hits         3363     3475     +112     
- Misses       2444     2523      +79     

☔ 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.

@Joao-Dionisio

Joao-Dionisio commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Hey @mohitt31 , thank you for your contribution, and I'm sorry for taking so long! Now it'll be much easier to keep control of the repo.

Would you rather they all return 0 there, or all raise?

I think it'd be better if the other methods returned 0 as well.

Joao-Dionisio and others added 4 commits October 11, 2026 00:34
Match the knapsack accessors when presolve removes the transformed
constraint. Cover dual and Farkas accessors for all three handlers and
document the behavior.
@mohitt31 mohitt31 changed the title Fix dual accessors for original knapsack constraints and the getVarsAnd check Fix original constraint duals and presolve consistency Oct 18, 2026
Comment thread CHANGELOG.md Outdated

@Joao-Dionisio Joao-Dionisio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you so much @mohitt31 !!

@Joao-Dionisio
Joao-Dionisio added this pull request to the merge queue Oct 18, 2026
Merged via the queue into scipopt:master with commit 2b78696 Oct 18, 2026
7 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.

2 participants