File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -3148,6 +3148,52 @@ cdef class Model:
31483148 """
31493149 return SCIPisGT(self ._scip, val1, val2)
31503150
3151+ def isHugeValue (self , val ):
3152+ """
3153+ Checks if value is huge and should be
3154+ handled separately (e.g., in activity computation).
3155+
3156+ Parameters
3157+ ----------
3158+ val : float
3159+
3160+ Returns
3161+ -------
3162+ bool
3163+
3164+ """
3165+ return SCIPisHugeValue(self ._scip, val)
3166+
3167+ def isPositive (self , val ):
3168+ """
3169+ Returns whether val > eps.
3170+
3171+ Parameters
3172+ ----------
3173+ val : float
3174+
3175+ Returns
3176+ -------
3177+ bool
3178+
3179+ """
3180+ return SCIPisPositive(self ._scip, val)
3181+
3182+ def isNegative (self , val ):
3183+ """
3184+ Returns whether val < -eps.
3185+
3186+ Parameters
3187+ ----------
3188+ val : float
3189+
3190+ Returns
3191+ -------
3192+ bool
3193+
3194+ """
3195+ return SCIPisNegative(self ._scip, val)
3196+
31513197 def getCondition (self , exact = False ):
31523198 """
31533199 Get the current LP's condition number.
Original file line number Diff line number Diff line change @@ -518,3 +518,15 @@ def test_redirection():
518518
519519 # compare objective values
520520 assert original .isEQ (redirect .getObjVal (), original .getObjVal ())
521+
522+ def test_comparisons ():
523+ from math import inf
524+ model = Model ()
525+
526+ assert model .isPositive (1. )
527+ assert model .isNegative (- 1. )
528+
529+ assert not model .isPositive (0. )
530+ assert not model .isNegative (0. )
531+
532+ assert model .isHugeValue (inf )
You can’t perform that action at this time.
0 commit comments