diff --git a/ipet/parsing/Solver.py b/ipet/parsing/Solver.py index 1d029cd..524b807 100644 --- a/ipet/parsing/Solver.py +++ b/ipet/parsing/Solver.py @@ -192,6 +192,13 @@ def extractByExpression(self, line : str, expr, key : str, datatype : type = flo break assert(d is not None) + # restrict floating point value to infinity threshold range + if datatype is float: + if d < -misc.FLOAT_INFINITY: + d = -misc.FLOAT_INFINITY + elif d > misc.FLOAT_INFINITY: + d = misc.FLOAT_INFINITY + self.addData(key, d) except: pass @@ -251,6 +258,13 @@ def addHistoryData(self, key, timestr : str, boundstr : str): bound = float(boundstr) except: return + + # restrict floating point value to infinity threshold range + if bound < -misc.FLOAT_INFINITY: + bound = -misc.FLOAT_INFINITY + elif bound > misc.FLOAT_INFINITY: + bound = misc.FLOAT_INFINITY + history = self.data.setdefault(key, []) # only append newly found bounds diff --git a/test/SolverTest.py b/test/SolverTest.py index 561e321..433f6f9 100644 --- a/test/SolverTest.py +++ b/test/SolverTest.py @@ -285,8 +285,8 @@ class SolverTest(unittest.TestCase): Key.Nodes: 0, Key.ObjectiveSense: Key.ObjectiveSenseCode.MINIMIZE, Key.SolverStatus: Key.SolverStatusCodes.Infeasible }, { - Key.PrimalBound: 1e+40, - Key.DualBound: 1e+40} ], + Key.PrimalBound: 1e+20, + Key.DualBound: 1e+20} ], "xpress300103-satellites1-25" : [ { Key.Solver: "XPRESS", Key.Version: "30.01.03", @@ -633,8 +633,8 @@ class SolverTest(unittest.TestCase): "OriginalProblem_InitialNCons": 1, "PresolvedProblem_Vars": 1, "PresolvedProblem_InitialNCons": 1 }, { - Key.PrimalBound: 1e+100, - Key.DualBound: 1e+100} ], + Key.PrimalBound: 1e+20, + Key.DualBound: 1e+20} ], "soplex800-unbounded" : [ { Key.Solver: "SoPlex", Key.Version: "8.0.0", @@ -648,8 +648,8 @@ class SolverTest(unittest.TestCase): "OriginalProblem_InitialNCons": 1, "PresolvedProblem_Vars": 1, "PresolvedProblem_InitialNCons": 1 }, { - Key.PrimalBound: -1e+100, - Key.DualBound: -1e+100} ], + Key.PrimalBound: -1e+20, + Key.DualBound: -1e+20} ], "soplex800-primalfeasible" : [ { Key.Solver: "SoPlex", Key.Version: "8.0.0",