Skip to content

Commit 73dac41

Browse files
committed
Merge branch 'master' of github.com:ctdunc/pyscipopt
2 parents 80a97c2 + cb7e441 commit 73dac41

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44
### Added
5+
- Add SCIP function SCIPgetTreesizeEstimation and wrapper getTreesizeEstimation
56
### Fixed
67
### Changed
78
### Removed

src/pyscipopt/scip.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,7 @@ cdef extern from "scip/scip.h":
12701270
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
12711271
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
12721272
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
1273+
SCIP_Real SCIPgetTreesizeEstimation(SCIP *scip)
12731274

12741275
# Statistic Methods
12751276
SCIP_RETCODE SCIPprintStatistics(SCIP* scip, FILE* outfile)

src/pyscipopt/scip.pxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5295,6 +5295,10 @@ cdef class Model:
52955295
assert isinstance(var, Variable), "The given variable is not a pyvar, but %s" % var.__class__.__name__
52965296
PY_SCIP_CALL(SCIPchgVarBranchPriority(self._scip, var.scip_var, priority))
52975297

5298+
def getTreesizeEstimation(self):
5299+
"""Get an estimation of the final tree size """
5300+
return SCIPgetTreesizeEstimation(self._scip)
5301+
52985302
# debugging memory management
52995303
def is_memory_freed():
53005304
return BMSgetMemoryUsed() == 0

tests/test_model.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,17 @@ def test_getStage():
286286
print(m.getStage())
287287
assert m.getStage() == SCIP_STAGE.SOLVED
288288
assert m.getStageName() == "SOLVED"
289+
290+
def test_getTreesizeEstimation():
291+
m = Model()
292+
293+
assert m.getTreesizeEstimation() == -1
294+
295+
x = m.addVar("x", vtype='B', obj=1.0)
296+
y = m.addVar("y", vtype='B', obj=2.0)
297+
c = m.addCons(x + y <= 10.0)
298+
m.setMaximize()
299+
300+
m.optimize()
301+
302+
assert m.getTreesizeEstimation() > 0

0 commit comments

Comments
 (0)