Skip to content

Commit a1c640f

Browse files
committed
cleanup merge; add bound updater for RC spoke
1 parent 988a064 commit a1c640f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Diff for: mpisppy/cylinders/hub.py

+1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ def send_terminate(self):
219219
return
220220

221221
def sync_bounds(self):
222+
self.receive_nonant_bounds()
222223
self.receive_outerbounds()
223224
self.receive_innerbounds()
224225
self.send_boundsout()

Diff for: mpisppy/cylinders/reduced_costs_spoke.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from mpisppy.cylinders.lagrangian_bounder import LagrangianOuterBound
1313
from mpisppy.cylinders.spwindow import Field
1414
from mpisppy.utils.sputils import is_persistent
15-
from mpisppy import MPI
15+
from mpisppy import MPI, global_toc
1616

1717
class ReducedCostsSpoke(LagrangianOuterBound):
1818

@@ -299,10 +299,37 @@ def extract_and_store_updated_nonant_bounds(self, new_dual=False):
299299
Field.NONANT_UPPER_BOUNDS,
300300
)
301301

302+
def update_nonant_bounds(self):
303+
bounds_modified = 0
304+
send_buf = self.send_buffers[Field.NONANT_LOWER_BOUNDS]
305+
for s in self.opt.local_scenarios.values():
306+
for ci, (ndn_i, xvar) in enumerate(s._mpisppy_data.nonant_indices.items()):
307+
xvarlb = xvar.lb
308+
if xvarlb is None:
309+
xvarlb = -np.inf
310+
if send_buf[ci] > xvarlb:
311+
xvar.lb = send_buf[ci]
312+
bounds_modified += 1
313+
send_buf = self.send_buffers[Field.NONANT_UPPER_BOUNDS]
314+
for s in self.opt.local_scenarios.values():
315+
for ci, (ndn_i, xvar) in enumerate(s._mpisppy_data.nonant_indices.items()):
316+
xvarub = xvar.ub
317+
if xvarub is None:
318+
xvarub = np.inf
319+
if send_buf[ci] < xvarub:
320+
xvar.ub = send_buf[ci]
321+
bounds_modified += 1
322+
323+
bounds_modified /= len(self.opt.local_scenarios)
324+
325+
if bounds_modified > 0:
326+
global_toc(f"{self.__class__.__name__}: tightened {int(bounds_modified)} variable bounds", self.cylinder_rank == 0)
327+
302328
def do_while_waiting_for_new_Ws(self, need_solution):
303329
super().do_while_waiting_for_new_Ws(need_solution=need_solution)
304330
# might as well see if a tighter upper bound has come along
305331
self.extract_and_store_updated_nonant_bounds(new_dual=False)
332+
self.update_nonant_bounds()
306333

307334
def main(self):
308335
# need the solution for ReducedCostsSpoke

0 commit comments

Comments
 (0)