Skip to content

SCIP 11: Split Model into BaseModel and Model - #1292

Merged
Joao-Dionisio merged 27 commits into
masterfrom
base-model
Nov 25, 2026
Merged

Joao-Dionisio merged 27 commits into
masterfrom
base-model

Conversation

@Joao-Dionisio

@Joao-Dionisio Joao-Dionisio commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

We want to introduce proper exact solving capabilities with the next major release. For this, we decided it would be best to have 3 distinct classes. A BaseModel class that holds the methods that are common to both types of solving. A Model class that has the non-exact methods. An ExactModel class that has the exact methods. This way, we have the best of both worlds, as most users will not experience any difference at all, they will just from pyscipopt import Model, and users of exact-SCIP can instead do from pyscipopt import ExactModel, and work with an exact model as they would a non-exact model. We decided to do things like this because we are able to not leak dangerous methods into the exact model.

This PR does the most difficult part of the work, the splitting of Model and BaseModel. I'm creating model.pxi, basemodel.pxi, exactmodel.pxi. scip.pxi would just have SCIP's base classes, but this can still be changed, of course.

@Joao-Dionisio Joao-Dionisio mentioned this pull request Nov 12, 2026
5 tasks
@Joao-Dionisio

Copy link
Copy Markdown
Member Author

This should be the first to be merged for two reasons. One, it would make the diff in exact-solving much nicer. And two, we already have enough content for a minor release, and if we manage to merge this in there in time, then we can make use of eventual bug reports that come up.

@Joao-Dionisio Joao-Dionisio changed the title Split Model into BaseModel and Model SCIP 11: Split Model into BaseModel and Model Nov 12, 2026
Comment thread tests/test_base_model.py Resolved
Comment thread src/pyscipopt/model.pxi Resolved
Comment thread src/pyscipopt/model.pxi Resolved
Comment thread src/pyscipopt/model.pxi Resolved
Comment thread src/pyscipopt/model.pxi Resolved
Comment thread src/pyscipopt/exact.pxi Resolved
Comment thread src/pyscipopt/exact.pxi Resolved
Comment thread src/pyscipopt/exact.pxi Outdated
raise ValueError("SCIP was built without exact solving support, ExactModel needs a SCIP build with exact solving enabled")
super().__init__(problemName, defaultPlugins, createscip=createscip, threadsafe=threadsafe)

cdef _configureScip(self):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Has to be like this because SCIPenableExactSolving() must be called in the INIT stage, and the way we're creating the model above puts us directly in the problem stage.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And we're creating the model this way to avoid duplication only?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, but indeed the duplication was not that bad. Added it back.

Co-authored-by: João Dionísio <57299939+Joao-Dionisio@users.noreply.github.com>
@Joao-Dionisio

Copy link
Copy Markdown
Member Author

I'm moving the BaseModel into its own file as well. Both to make the diff cleaner, but also to organize the codebase a bit. I'm not a huge fan of the C-style 20k LOC files.

@Joao-Dionisio

Copy link
Copy Markdown
Member Author

@DominikKamp @mmghannam I'm in the middle of reviewing this. Would you mind just letting me know if you have any high-level observations?

@Joao-Dionisio Joao-Dionisio added this to the v6.4.0 milestone Nov 15, 2026
Comment thread tests/test_base_model.py Resolved
Comment thread src/pyscipopt/__init__.py Resolved
@Joao-Dionisio

Joao-Dionisio commented Nov 15, 2026 •

Copy link
Copy Markdown
Member Author

@Opt-Mucca if you don't mind, can you also give your high-level opinion on this, please? 🙏

@Opt-Mucca

Copy link
Copy Markdown
Collaborator

@Joao-Dionisio The changes look good! The naming scheme makes sense. I've got no high-level critiques (or even low-level ones). It also starts the move away from one mega file.

Is there a plan to package exact solving capabilities into the standard PyPI distribution?

@Joao-Dionisio

Copy link
Copy Markdown
Member Author

Thank you @Opt-Mucca !

Is there a plan to package exact solving capabilities into the standard PyPI distribution?

Yep, it's a WIP in scipoptsuite-deploy#46, along with SCIP in debug mode. Still not finished though!

# Conflicts:
#	src/pyscipopt/scip.pxi
#	src/pyscipopt/scip.pyi
@Joao-Dionisio

Copy link
Copy Markdown
Member Author

@DominikKamp is there something else you're concerned with or do you think that this can be merged?

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 16.07143% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.43%. Comparing base (3653fbf) to head (8f7130a).
⚠️ Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
src/pyscipopt/exact.pxi 16.07% 47 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1292      +/-   ##
==========================================
- Coverage   58.15%   57.43%   -0.72%     
==========================================
  Files          27       30       +3     
  Lines        6012     6120     +108     
==========================================
+ Hits         3496     3515      +19     
- Misses       2516     2605      +89     

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

@DominikKamp

Copy link
Copy Markdown
Contributor

The main concerns lie in exact handling, which is separated for some reason. We will only see what is missing after adding ExactModel. If it works technically, it should be okay for now.

@Joao-Dionisio

Copy link
Copy Markdown
Member Author

It is separated because I prefer to make one humungous change at a time. This is a big rewrite also for normal models, where a little slip could spell doom, in theory. But it seems that nothing pops up, so I will merge in some time.

Comment thread CHANGELOG.md Resolved
Comment thread CHANGELOG.md Resolved
Comment thread CHANGELOG.md Resolved
Co-authored-by: João Dionísio <57299939+Joao-Dionisio@users.noreply.github.com>
@Joao-Dionisio

Copy link
Copy Markdown
Member Author

Alright everyone, thank you for taking a look! Let's see how much stuff we end up breaking by merging this 😄

@Joao-Dionisio
Joao-Dionisio merged commit d9fca9b into master Nov 25, 2026
7 checks passed
@Joao-Dionisio

Copy link
Copy Markdown
Member Author

@jonathanberthias @Zeroto521 @adamj34 tagging you guys because this is a pretty big change and you regularly contribute. If you're able, please update your PySCIPOpt's to include this change and let me know if something unexpected is happening.

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.

3 participants