Skip to content

Commit

Permalink
robust use of find_component and better handling of bounds for quadra…
Browse files Browse the repository at this point in the history
…tics
  • Loading branch information
michaelbynum authored and fracek committed Jun 9, 2021
1 parent 114026f commit 56a80fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions galini/branch_and_cut/node_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,19 @@ def recompute_model_relaxation_bounds(self):
if isinstance(relaxation, PWXSquaredRelaxationData):
# w >= x^2: add an oa point in the midpoint
relaxation.clean_oa_points()
var_values = pe.ComponentMap()
x_var = relaxation.get_rhs_vars()[0]
midpoint = x_var.lb + 0.5*(x_var.ub - x_var.lb)
var_values[x_var] = midpoint
relaxation.add_oa_point(var_values)
if x_var.has_lb() and x_var.has_ub():
midpoint = x_var.lb + 0.5*(x_var.ub - x_var.lb)
relaxation.add_oa_point(pe.ComponentMap([(x_var, midpoint)]))
elif x_var.has_lb():
if x_var.lb <= 0:
relaxation.add_oa_point(pe.ComponentMap([(x_var, 1)]))
elif x_var.has_ub():
if x_var.ub >= 0:
relaxation.add_oa_point(pe.ComponentMap([(x_var, -1)]))
else:
relaxation.add_oa_point(pe.ComponentMap([(x_var, -1)]))
relaxation.add_oa_point(pe.ComponentMap([(x_var, 1)]))

relaxation.rebuild()

Expand Down
2 changes: 1 addition & 1 deletion galini/relaxations/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def relax(model, data, use_linear_relaxation=True):
for var in model.component_data_objects(pe.Var,
active=True,
descend_into=True):
new_var = new_model.find_component(var.getname(fully_qualified=True))
new_var = new_model.find_component(var)
data.original_to_new_var_map[var] = new_var

model = new_model
Expand Down

0 comments on commit 56a80fb

Please sign in to comment.