Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Added pre-commit hook for automatic stub regeneration (see .pre-commit-config.yaml)
- Wrapped isObjIntegral() and test
- Added structured_optimization_trace recipe for structured optimization progress tracking
- Added methods: getPrimalDualIntegral()
### Fixed
- getBestSol() now returns None for infeasible problems instead of a Solution with NULL pointer
- all fundamental callbacks now raise an error if not implemented
Expand Down
1 change: 1 addition & 0 deletions src/pyscipopt/scip.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,7 @@ cdef extern from "scip/scip.h":
int SCIPgetPlungeDepth(SCIP* scip)
SCIP_Longint SCIPgetNNodeLPIterations(SCIP* scip)
SCIP_Longint SCIPgetNStrongbranchLPIterations(SCIP* scip)
SCIP_Real SCIPgetPrimalDualIntegral(SCIP* scip)

# Parameter Functions
SCIP_RETCODE SCIPsetBoolParam(SCIP* scip, char* name, SCIP_Bool value)
Expand Down
10 changes: 10 additions & 0 deletions src/pyscipopt/scip.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
if rc == SCIP_OKAY:
pass
elif rc == SCIP_ERROR:
raise Exception('SCIP: unspecified error!')

Check failure on line 319 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / test-coverage (3.11)

SCIP: unspecified error!
elif rc == SCIP_NOMEMORY:
raise MemoryError('SCIP: insufficient memory error!')
elif rc == SCIP_READERROR:
Expand All @@ -335,7 +335,7 @@
raise Exception('SCIP: method cannot be called at this time'
+ ' in solution process!')
elif rc == SCIP_INVALIDDATA:
raise Exception('SCIP: error in input data!')

Check failure on line 338 in src/pyscipopt/scip.pxi

View workflow job for this annotation

GitHub Actions / test-coverage (3.11)

SCIP: error in input data!
elif rc == SCIP_INVALIDRESULT:
raise Exception('SCIP: method returned an invalid result code!')
elif rc == SCIP_PLUGINNOTFOUND:
Expand Down Expand Up @@ -3385,6 +3385,16 @@
"""
return SCIPgetNStrongbranchLPIterations(self._scip)

def getPrimalDualIntegral(self):
"""
Recomputes and returns the primal dual gap stored in the stats

Returns
------
float
"""
return SCIPgetPrimalDualIntegral(self._scip)

def cutoffNode(self, Node node):
"""
marks node and whole subtree to be cut off from the branch and bound tree.
Expand Down
1 change: 1 addition & 0 deletions src/pyscipopt/scip.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ class Model:
def getNSols(self) -> Incomplete: ...
def getNSolsFound(self) -> Incomplete: ...
def getNStrongbranchLPIterations(self) -> Incomplete: ...
def getPrimalDualIntegral(self) -> Incomplete: ...
def getNTotalNodes(self) -> Incomplete: ...
def getNVars(self, transformed: Incomplete = ...) -> Incomplete: ...
def getNVarsAnd(self, and_cons: Incomplete) -> Incomplete: ...
Expand Down
7 changes: 7 additions & 0 deletions tests/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ def test_statistics_json():
assert data["origprob"]["problem_name"] == "model"

os.remove("statistics.json")

def test_getPrimalDualIntegral():
model = random_mip_1(small=True)
model.optimize()
primal_dual_integral = model.getPrimalDualIntegral()

assert isinstance(primal_dual_integral, float)
Loading