Skip to content

Commit

Permalink
Add option to only update fixings on bound improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
bknueven committed Dec 2, 2024
1 parent 8170c1b commit a925ebe
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion mpisppy/extensions/reduced_costs_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, spobj):
# will be considered 0
self.zero_rc_tol = rc_options['zero_rc_tol']
self._use_rc_fixer = rc_options['use_rc_fixer']
self._rc_fixer_require_improving_lagrangian = rc_options.get('rc_fixer_require_improving_lagrangian', True)
# Percentage of variables which are at the bound we will target
# to fix. We never fix varibles with reduced costs less than
# the `zero_rc_tol` in absolute value
Expand All @@ -51,10 +52,22 @@ def __init__(self, spobj):

self._last_serial_number = -1
self._heuristic_fixed_vars = 0
if spobj.is_minimizing:
self._best_outer_bound = -float("inf")
self._outer_bound_update = lambda new, old : (new > old)
else:
self._best_outer_bound = float("inf")
self._outer_bound_update = lambda new, old : (new < old)

def _get_serial_number(self):
return int(round(self.opt.spcomm.outerbound_receive_buffers[self.reduced_costs_spoke_index][-1]))

def _update_best_outer_bound(self, new_outer_bound):
if self._outer_bound_update(new_outer_bound, self._best_outer_bound):
self._best_outer_bound = new_outer_bound
return True
return False

def pre_iter0(self):
self._modeler_fixed_nonants = set()
self._integer_nonants = set()
Expand Down Expand Up @@ -96,10 +109,12 @@ def sync_with_spokes(self, pre_iter0 = False):
self._last_serial_number = serial_number
reduced_costs = spcomm.outerbound_receive_buffers[idx][1:1+self.nonant_length]
this_outer_bound = spcomm.outerbound_receive_buffers[idx][0]
new_outer_bound = self._update_best_outer_bound(this_outer_bound)
if not pre_iter0 and self._use_rc_bt:
self.reduced_costs_bounds_tightening(reduced_costs, this_outer_bound)
if self._use_rc_fixer and self.fix_fraction_target > 0.0:
self.reduced_costs_fixing(reduced_costs)
if new_outer_bound or not self._rc_fixer_require_improving_lagrangian:
self.reduced_costs_fixing(reduced_costs)
else:
if self.opt.cylinder_rank == 0 and self.verbose:
print("No new reduced costs!")
Expand Down

0 comments on commit a925ebe

Please sign in to comment.