Skip to content

Commit

Permalink
Removing a lot of unnecessary calls to value
Browse files Browse the repository at this point in the history
  • Loading branch information
emma58 committed Nov 3, 2023
1 parent 3f06e19 commit 6dfe191
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions pyomo/contrib/fbbt/expression_bounds_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions pyomo/contrib/fbbt/fbbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6dfe191

Please sign in to comment.