|
12 | 12 | from mpisppy.cylinders.lagrangian_bounder import LagrangianOuterBound
|
13 | 13 | from mpisppy.cylinders.spwindow import Field
|
14 | 14 | from mpisppy.utils.sputils import is_persistent
|
15 |
| -from mpisppy import MPI |
| 15 | +from mpisppy import MPI, global_toc |
16 | 16 |
|
17 | 17 | class ReducedCostsSpoke(LagrangianOuterBound):
|
18 | 18 |
|
@@ -299,10 +299,37 @@ def extract_and_store_updated_nonant_bounds(self, new_dual=False):
|
299 | 299 | Field.NONANT_UPPER_BOUNDS,
|
300 | 300 | )
|
301 | 301 |
|
| 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 | + |
302 | 328 | def do_while_waiting_for_new_Ws(self, need_solution):
|
303 | 329 | super().do_while_waiting_for_new_Ws(need_solution=need_solution)
|
304 | 330 | # might as well see if a tighter upper bound has come along
|
305 | 331 | self.extract_and_store_updated_nonant_bounds(new_dual=False)
|
| 332 | + self.update_nonant_bounds() |
306 | 333 |
|
307 | 334 | def main(self):
|
308 | 335 | # need the solution for ReducedCostsSpoke
|
|
0 commit comments