From 5c01e348114e6207786b3d9b03e02278511ddde9 Mon Sep 17 00:00:00 2001 From: Christoph Hansknecht Date: Fri, 16 May 2025 17:05:54 +0200 Subject: [PATCH 1/2] Add missing numerical access functions --- src/pyscipopt/scip.pxi | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/pyscipopt/scip.pxi b/src/pyscipopt/scip.pxi index 970e6f039..900a8c1fb 100644 --- a/src/pyscipopt/scip.pxi +++ b/src/pyscipopt/scip.pxi @@ -3148,6 +3148,52 @@ cdef class Model: """ return SCIPisGT(self._scip, val1, val2) + def isHugeValue(self, val): + """ + Checks if value is huge and should be + handled separately (e.g., in activity computation). + + Parameters + ---------- + val : float + + Returns + ------- + bool + + """ + return SCIPisHugeValue(self._scip, val) + + def isPositive(self, val): + """ + Returns whether val > eps. + + Parameters + ---------- + val : float + + Returns + ------- + bool + + """ + return SCIPisPositive(self._scip, val) + + def isNegative(self, val): + """ + Returns whether val < -eps. + + Parameters + ---------- + val : float + + Returns + ------- + bool + + """ + return SCIPisNegative(self._scip, val) + def getCondition(self, exact=False): """ Get the current LP's condition number. From ee30c13eed7e46b232c928fec6f293eb7b5e6acb Mon Sep 17 00:00:00 2001 From: Christoph Hansknecht Date: Fri, 16 May 2025 18:57:19 +0200 Subject: [PATCH 2/2] Add test cases for numerical access functions --- tests/test_model.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_model.py b/tests/test_model.py index 516c73253..85f7f069d 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -518,3 +518,15 @@ def test_redirection(): # compare objective values assert original.isEQ(redirect.getObjVal(), original.getObjVal()) + +def test_comparisons(): + from math import inf + model = Model() + + assert model.isPositive(1.) + assert model.isNegative(-1.) + + assert not model.isPositive(0.) + assert not model.isNegative(0.) + + assert model.isHugeValue(inf)