Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
97f5ccd
Split Model into BaseModel and Model, moving fp-only methods and Colu…
Joao-Dionisio Nov 5, 2026
a2fda0e
Pin the BaseModel surface and lint it for fp markers and Model-only c…
Joao-Dionisio Nov 5, 2026
7e2bf79
Split the Model stub into BaseModel and Model
Joao-Dionisio Nov 5, 2026
e7e42d2
Move getBipartiteGraphRepresentation, copyLargeNeighborhoodSearch and…
Joao-Dionisio Nov 5, 2026
69d1207
Merge origin/master into base-model
Joao-Dionisio Nov 12, 2026
e9b3e1a
Add ExactModel skeleton and move the exact LP classes to exact.pxi
Joao-Dionisio Nov 12, 2026
92b5d6a
Apply batched suggestions from code review
Joao-Dionisio Nov 12, 2026
508ac8d
Move BaseModel to basemodel.pxi
Joao-Dionisio Nov 12, 2026
0316de4
Move getConsVars to BaseModel
Joao-Dionisio Nov 13, 2026
39c094f
Export ExactModel with the exact LP operations and deprecate the Mode…
Joao-Dionisio Nov 13, 2026
b322c8e
Add exact wrapper subclasses chosen by the factories, with value gett…
Joao-Dionisio Nov 13, 2026
a644918
Spell out the floating-point markers and source paths in the base-mod…
Joao-Dionisio Nov 15, 2026
df410c5
Move the Benders methods to Model
Joao-Dionisio Nov 15, 2026
10e9029
Move the fp LP, probing LP and IIS methods to Model and add raising c…
Joao-Dionisio Nov 15, 2026
b1d99bb
Move isLPSolBasic to Model and format the stub file
Joao-Dionisio Nov 15, 2026
194be26
Move the methods SCIP cannot serve in exact mode to Model
Joao-Dionisio Nov 15, 2026
80c2844
Drop the pinned BaseModel method list
Joao-Dionisio Nov 15, 2026
a9d91c3
Merge remote-tracking branch 'origin/master' into base-model
Joao-Dionisio Nov 20, 2026
794dc9e
Return SCIP_RESULT from ExactModel.branchLP, document inherited Model…
Joao-Dionisio Nov 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
### Added
- Added `ExactModel`, which enables SCIP's exact solving mode on construction, and the wrapper types `ExactVariable`, `ExactSolution`, `ExactEvent` and `ExactBoundChange` that SCIP objects of an exact model are returned as; for now it can only read problems and solve them exactly, and it is unavailable when SCIP was built without exact solving support
- Added the following methods with tests: `nodesSharePath()`, `nodesGetCommonAncestor()`, `getFocusDepth()`, `getRootNode()`, `wasNodeLastBranchParent()`
- Added `getCountedSols()` to retrieve the solutions collected by `count()` (#906)
- Added docstrings to the bundled stubs in release wheels for Python 3.10 and later.
Expand All @@ -19,6 +20,8 @@
### Changed
- Replaced SCIP constant classes with `IntEnum` and `IntFlag`, including enum return values and type annotations (#1286).
- Speed up enum-returning getters and plugin callbacks with precomputed lookup tables
- Deprecated `Model.enableExactSolving()`, `Model.isExact()`, `Model.allowNegSlackExact()`, `Model.branchLPExact()` and `Model.addRowExact()` in favour of `ExactModel`; they will be removed in 7.0.0
- Split `Model` into `BaseModel` (methods shared with exact solving) and `Model(BaseModel)` (floating-point methods); the public surface of `Model` is unchanged and `BaseModel` is exported from `pyscipopt`
- Replaced `format()` with f-strings in examples
- Refactor general expression conversion into per-class `to_scip_expr` recursion
- Made expression fields read-only to prevent accidental runtime modification
Expand Down
3 changes: 2 additions & 1 deletion docs/api/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Model API
#########

.. autoclass:: pyscipopt.Model
:members:
:members:
:inherited-members:
4 changes: 2 additions & 2 deletions scripts/generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ class StubGenerator:
# Classes that should have @disjoint_base decorator
# These are user-facing classes that should not be structurally compatible
DISJOINT_BASE_CLASSES = {
'Benders', 'Benderscut', 'BoundChange', 'Branchrule', 'Column', 'ColumnExact',
'BaseModel', 'Benders', 'Benderscut', 'BoundChange', 'Branchrule', 'Column', 'ColumnExact',
'Conshdlr', 'Constant', 'Constraint', 'Cutsel', 'DomainChanges', 'Event',
'Eventhdlr', 'Expr', 'ExprCons', 'GenExpr', 'Heur', 'IIS', 'IISfinder',
'LP', 'Model', 'NLRow', 'Node', 'Nodesel', 'PowExpr', 'Presol', 'Pricer',
'LP', 'NLRow', 'Node', 'Nodesel', 'PowExpr', 'Presol', 'Pricer',
'ProdExpr', 'Prop', 'Reader', 'Relax', 'Row', 'RowExact', 'Sepa', 'Solution',
'SumExpr', 'Term', 'UnaryExpr', 'Variable', '_VarArray',
}
Expand Down
6 changes: 6 additions & 0 deletions src/pyscipopt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@

# export user-relevant objects:
from pyscipopt.Multidict import multidict as multidict
from pyscipopt.scip import BaseModel as BaseModel

@Joao-Dionisio Joao-Dionisio Nov 15, 2026 •

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.

I gave it more than one pass already, but can you check whether I missed something @DominikKamp ? Either a method in BaseModel that relies on floating-point, or a method in Model that can also be used by exact SCIP. There are many methods that could, in theory, be used in exact SCIP, but haven't been implemented in SCIP yet, like methods related to AND constraints, for example. For these, I just put them in Model, rather than BaseModel and raising NotImplementedError in ExactModel.

Methods in BaseModel:

addConss, addMatrixCons, addNNodes, addSol, addVarLocks, addVarLocksType, allColsInLP, attachEventHandlerCallback, backtrackProbing, branchVar, catchEvent, catchVarEvent, checkSol, chgVarBranchPriority, chgVarType, constructLP, create, createChild, createProbBasic, cutoffNode, deactivatePricer, delCons, delConsLocal, delVar, disableDebugSol, disablePropagation, dropEvent, dropVarEvent, enableDebugSol, endProbing, free, freeProb, freeSol, freeTransform, from_ptr, getBestChild, getBestLeaf, getBestNode, getBestSibling, getBestSol, getBestboundNode, getBranchScoreMultiple, getChildren, getConsNVars, getConsVars, getConss, getCurrentNode, getDepth, getDeterministicTime, getFocusDepth, getFocusNode, getHeurTiming, getLeaves, getMajorVersion, getMaxDepth, getMaxTotalDepth, getMemExternEstim, getMemTotal, getMemUsed, getMinorVersion, getNBacktracks, getNBestSolsFound, getNBinVars, getNChildren, getNConss, getNContVars, getNCuts, getNCutsApplied, getNFeasibleLeaves, getNImplVars, getNInfeasibleLeaves, getNIntVars, getNLPBranchCands, getNLPCols, getNLPIterations, getNLPRows, getNLPs, getNLeaves, getNLimSolsFound, getNNodeLPIterations, getNNodes, getNNodesLeft, getNObjlimLeaves, getNReaders, getNRuns, getNSepaRounds, getNSiblings, getNSols, getNSolsFound, getNStrongbranchLPIterations, getNTotalNodes, getNVars, getObjVal, getObjectiveSense, getOpenNodes, getParam, getParams, getPlungeDepth, getPresolvingTime, getPrimalDualIntegral, getPrioChild, getPrioSibling, getProbName, getProbingDepth, getPseudoBranchCands, getReadingTime, getRootNode, getSiblings, getSolTime, getSols, getSolvingTime, getStage, getStageName, getStatus, getTechVersion, getTotalTime, getTransformedCons, getTransformedVar, getTreesizeEstimation, getVarPseudocost, getVarPseudocostScore, getVarStrongbranchNode, getVars, hideOutput, inProbing, inRepropagation, includeBranchrule, includeConshdlr, includeCutsel, includeDefaultPlugins, includeEventhdlr, includeHeur, includeNodesel, includePresol, includePricer, includeProp, includeReader, includeRelax, includeSepa, interruptSolve, isObjChangedProbing, isObjIntegral, markDoNotAggrVar, markDoNotMultaggrVar, newProbingNode, nodesGetCommonAncestor, nodesSharePath, optimize, optimizeNogil, presolve, printCons, printExternalCodeVersions, printProblem, printStatistics, printStatisticsJson, printVersion, readParams, readProblem, redirectOutput, relax, repropagateNode, resetParam, resetParams, restartSolve, separateSol, setBoolParam, setCharParam, setCheck, setEmphasis, setEnforced, setHeurTiming, setHeuristics, setInitial, setIntParam, setLogfile, setLongintParam, setMaximize, setMinimize, setModifiable, setObjIntegral, setParam, setParams, setPresolve, setProbName, setRealParam, setRemovable, setSeparating, setStringParam, startProbing, to_ptr, updateVarPseudocost, version, wasNodeLastBranchParent, writeName, writeParams, writeProblem, writeStatistics, writeStatisticsJson

Methods in Model:

activateBenders, addBendersSubproblem, addCoefKnapsack, addCoefLinear, addCoefLogicor, addCons, addConsAnd, addConsCardinality, addConsCoeff, addConsCumulative, addConsDisjunction, addConsElemDisjunction, addConsIndicator, addConsKnapsack, addConsLinear, addConsLocal, addConsLogicor, addConsNode, addConsOr, addConsSOS1, addConsSOS2, addConsXor, addCut, addExprNonlinear, addMatrixConsDisjunction, addMatrixConsIndicator, addMatrixVar, addObjoffset, addPoolCut, addPyCons, addRowDive, addRowExact, addVar, addVarSOS1, addVarSOS2, addVarToRow, adjustedVarLb, adjustedVarUb, aggregateVars, allowNegSlackExact, appendVarSOS1, appendVarSOS2, applyCutsProbing, branchLPExact, branchVarVal, cacheRowExtensions, calcChildEstimate, calcNodeselPriority, catchRowEvent, checkBendersSubproblemOptimality, checkQuadraticNonlinear, chgCapacityKnapsack, chgCoefLinear, chgLhs, chgReoptObjective, chgRhs, chgRowLhsDive, chgRowRhsDive, chgVarLb, chgVarLbDive, chgVarLbGlobal, chgVarLbNode, chgVarLbProbing, chgVarObjDive, chgVarObjProbing, chgVarUb, chgVarUbDive, chgVarUbGlobal, chgVarUbNode, chgVarUbProbing, computeBestSolSubproblems, copyLargeNeighborhoodSearch, count, createCons, createConsFromExpr, createEmptyRowSepa, createEmptyRowUnspec, createOrigSol, createPartialSol, createSol, delCoefLinear, dropRowEvent, enableExactSolving, enableReoptimization, endDive, endStrongbranch, epsilon, feasCeil, feasFloor, feasFrac, feasRound, feastol, fixVar, fixVarProbing, flushRowExtensions, frac, freeBendersSubproblems, freeReoptSolve, generateIIS, getActivity, getAvgDualbound, getAvgLowerbound, getBendersAuxiliaryVar, getBendersSubproblem, getBendersVar, getBipartiteGraphRepresentation, getCapacityKnapsack, getColRedCost, getCondition, getConsVals, getCountedSols, getCutEfficacy, getCutLPSolCutoffDistance, getCutoffbound, getDualMultiplier, getDualSolVal, getDualbound, getDualboundRoot, getDualfarkasKnapsack, getDualfarkasLinear, getDualfarkasLogicor, getDualsolKnapsack, getDualsolLinear, getDualsolLogicor, getFirstPrimalBound, getGap, getIIS, getLPBInvARow, getLPBInvRow, getLPBasisInd, getLPBranchCands, getLPColsData, getLPObjVal, getLPRowsData, getLPSolstat, getLhs, getLinearConsIndicator, getLocalEstimate, getLowerbound, getLowerboundRoot, getNCountedSols, getNNlRows, getNReoptRuns, getNVarsAnd, getNVarsLogicor, getNlRowActivityBounds, getNlRowSolActivity, getNlRowSolFeasibility, getNlRows, getObjective, getObjlimit, getObjoffset, getPrimalRay, getPrimalRayVal, getPrimalbound, getResultantAnd, getRhs, getRowActivity, getRowDualSol, getRowLPActivity, getRowLinear, getRowNumIntCols, getRowObjParallelism, getRowParallelism, getSlack, getSlackVarIndicator, getSolObjVal, getSolVal, getTermsQuadratic, getUpperbound, getVal, getValsLinear, getVarDict, getVarLbDive, getVarRedcost, getVarStrongbranch, getVarStrongbranchLast, getVarUbDive, getVarsAnd, getVarsLogicor, getWeightsKnapsack, hasPrimalRay, includeBenders, includeBendersDefaultCuts, includeBenderscut, includeIISfinder, infinity, initBendersDefault, isAndConsSorted, isCutEfficacious, isEQ, isExact, isFeasEQ, isFeasGE, isFeasGT, isFeasIntegral, isFeasLE, isFeasLT, isFeasNegative, isFeasPositive, isFeasZero, isGE, isGT, isHugeValue, isInfinity, isIntegral, isLE, isLPSolBasic, isLT, isNLPConstructed, isNegative, isPositive, isReoptEnabled, isZero, lpiGetIterations, printBestSol, printNlRow, printRow, printSol, propagateProbing, readSol, readSolFile, releaseRow, setBendersSubproblemIsConvex, setObjective, setObjlimit, setParamsCountsols, setRelaxSolVal, setSolVal, setupBendersSubproblem, solveBendersSubproblem, solveConcurrent, solveDiveLP, solveProbingLP, solveProbingLPWithPricing, sortAndCons, startDive, startStrongbranch, tightenVarLb, tightenVarLbGlobal, tightenVarUb, tightenVarUbGlobal, translateSubSol, trySol, updateBendersLowerbounds, updateNodeLowerbound, writeBestSol, writeBestTransSol, writeLP, writeMIP, writeSol, writeTransSol

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.

I'm also going to move to Model the methods that do not yet have a getter in the exact model (like isLPSolBasic, for which there is no public getter).

@DominikKamp DominikKamp Nov 15, 2026 •

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.

Oh, do we also get a BaseVariable or is this distinction not required?

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.

I haven't implemented this distinction, since the number of methods would not justify it. BaseVariable would have 25 methods, ExactVariable 10, Variable 1.

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.

Would it not still be simpler than duplicating 25 methods?

@Joao-Dionisio Joao-Dionisio Nov 15, 2026 •

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.

There is no duplication. ExactVariable is a subclass of Variable and overwrites the methods that are not exact-compatible (raising an error with the one method that would be going into the non-exact Variable class, which is getAvgSol()).

@DominikKamp DominikKamp Nov 15, 2026 •

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.

It is the same issue as with subclassing Model. We do not need an ExactVariable class for this then.

from pyscipopt.scip import Model as Model
from pyscipopt.scip import ExactModel as ExactModel
from pyscipopt.scip import ExactVariable as ExactVariable
from pyscipopt.scip import ExactSolution as ExactSolution
from pyscipopt.scip import ExactEvent as ExactEvent
from pyscipopt.scip import ExactBoundChange as ExactBoundChange
from pyscipopt.scip import Variable as Variable
from pyscipopt.scip import MatrixVariable as MatrixVariable
from pyscipopt.scip import Constraint as Constraint
Expand Down
Loading
Loading