From 6dfe1917772df0a51cd060ff486d770ad1b9e298 Mon Sep 17 00:00:00 2001 From: Emma Johnson Date: Fri, 3 Nov 2023 16:47:42 -0600 Subject: [PATCH] Removing a lot of unnecessary calls to value --- pyomo/contrib/fbbt/expression_bounds_walker.py | 7 ++++--- pyomo/contrib/fbbt/fbbt.py | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pyomo/contrib/fbbt/expression_bounds_walker.py b/pyomo/contrib/fbbt/expression_bounds_walker.py index 35cc33522ba..426d30f0ee6 100644 --- a/pyomo/contrib/fbbt/expression_bounds_walker.py +++ b/pyomo/contrib/fbbt/expression_bounds_walker.py @@ -74,8 +74,8 @@ def _before_var(visitor, child): ) leaf_bounds[child] = (child.value, child.value) else: - lb = value(child.lb) - ub = value(child.ub) + lb = child.lb + ub = child.ub if lb is None: lb = -inf if ub is None: @@ -122,7 +122,8 @@ def _before_complex(visitor, child): @staticmethod def _before_npv(visitor, child): - return False, (value(child), value(child)) + val = value(child) + return False, (val, val) _before_child_handlers = ExpressionBoundsBeforeChildDispatcher() diff --git a/pyomo/contrib/fbbt/fbbt.py b/pyomo/contrib/fbbt/fbbt.py index dbdd992b9c8..db33c27dd96 100644 --- a/pyomo/contrib/fbbt/fbbt.py +++ b/pyomo/contrib/fbbt/fbbt.py @@ -957,8 +957,8 @@ def _check_and_reset_bounds(var, lb, ub): """ This function ensures that lb is not less than var.lb and that ub is not greater than var.ub. """ - orig_lb = value(var.lb) - orig_ub = value(var.ub) + orig_lb = var.lb + orig_ub = var.ub if orig_lb is None: orig_lb = -interval.inf if orig_ub is None: @@ -985,8 +985,8 @@ def _before_var(visitor, child): lb = value(child.value) ub = lb else: - lb = value(child.lb) - ub = value(child.ub) + lb = child.lb + ub = child.ub if lb is None: lb = -interval.inf if ub is None: @@ -1339,11 +1339,11 @@ def _fbbt_block(m, config): if v.lb is None: var_lbs[v] = -interval.inf else: - var_lbs[v] = value(v.lb) + var_lbs[v] = v.lb if v.ub is None: var_ubs[v] = interval.inf else: - var_ubs[v] = value(v.ub) + var_ubs[v] = v.ub var_to_con_map[v].append(c) n_cons += 1