Skip to content

Fix getObjective() to include offset - #1300

Merged
Joao-Dionisio merged 4 commits into
scipopt:masterfrom
adamj34:offset-bug
Nov 29, 2026
Merged

Joao-Dionisio merged 4 commits into
scipopt:masterfrom
adamj34:offset-bug

Conversation

@adamj34

@adamj34 adamj34 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

getObjective() previously returned only variable terms, so reading back 2*x + 7 produced 2*x. This PR modifies getObjective to include the constant offset in the returned expression.

Before this change, evaluating getVal(getObjective()) yielded an objective value that omitted the offset.

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer checklist

To be checked by the reviewer.

Code

  • The code change is correct.
  • New methods are named after their SCIP function (e.g. SCIPgetVars() becomes getVars()) and are placed next to related methods, or no new methods were added.
  • The added/modified behavior is identical to SCIP's, or deviations were justified.
  • If methods were added to BaseModel, they work in exact mode.
  • If methods were added to Model, the exact counterpart was added to ExactModel with Fraction i/o, or the method has no meaning in exact mode or SCIP has no exact equivalent. <- I'm mostly ignoring this one until we merge the exact stuff.

Documentation

  • The code is documented (numpydoc docstrings with parameter and return types).
  • CHANGELOG.md is updated, including API changes.
  • The type stubs (scip.pyi) are updated for new or changed methods.
  • Docs and examples are updated, or a new docs section was added for new features (e.g. plugin types), or no user-facing behavior changed.

Testing

  • New code is covered by tests, including error paths.
  • If this touches expressions, model building or callbacks, /benchmark was run and shows no regression.
    /benchmark [filter] [timelimit=seconds], e.g. /benchmark expr or plugin. Locally: pytest benchmarks.

Does this PR introduce an API change? ⚠️

  • No, or it is backwards compatible, or the old behavior goes through a deprecation warning first. <- Yes, but it's a plain bugfix.

@adamj34
adamj34 marked this pull request as ready for review November 29, 2026 12:38
Comment thread src/pyscipopt/model.pxi Resolved
Co-authored-by: João Dionísio <57299939+Joao-Dionisio@users.noreply.github.com>
Comment thread tests/test_model.py Resolved
@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.48%. Comparing base (3653fbf) to head (e57baf5).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1300      +/-   ##
==========================================
- Coverage   58.15%   57.48%   -0.67%     
==========================================
  Files          27       30       +3     
  Lines        6012     6125     +113     
==========================================
+ Hits         3496     3521      +25     
- Misses       2516     2604      +88     

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

adamj34 and others added 2 commits November 29, 2026 15:27
Co-authored-by: João Dionísio <57299939+Joao-Dionisio@users.noreply.github.com>

@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 @adamj34 😁

@Joao-Dionisio
Joao-Dionisio added this pull request to the merge queue Nov 29, 2026
Merged via the queue into scipopt:master with commit 0fe3212 Nov 29, 2026
7 checks passed
@adamj34
adamj34 deleted the offset-bug branch November 29, 2026 19:29
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