Skip to content

Commit 4e970cd

Browse files
committed
getting new bounds in hub; doesn't exactly match extension
1 parent 7a7dbca commit 4e970cd

5 files changed

+37
-25
lines changed

mpisppy/cylinders/reduced_costs_spoke.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ def initialize_bound_fields(self):
7777
dtype=float,
7878
count=len(s._mpisppy_data.nonant_indices),
7979
)
80-
self._nonant_lower_bounds = np.maximum(self._nonant_lower_bounds, scenario_lower_bounds)
80+
np.maximum(self._nonant_lower_bounds, scenario_lower_bounds, out=self._nonant_lower_bounds)
8181

8282
scenario_upper_bounds = np.fromiter(
8383
_ub_generator(s._mpisppy_data.nonant_indices.values()),
8484
dtype=float,
8585
count=len(s._mpisppy_data.nonant_indices),
8686
)
87-
self._nonant_upper_bounds = np.minimum(self._nonant_upper_bounds, scenario_upper_bounds)
87+
np.minimum(self._nonant_upper_bounds, scenario_upper_bounds, out=self._nonant_upper_bounds)
8888

8989
def create_integer_variable_where(self):
9090
self._integer_variable_where = np.full(len(self._nonant_lower_bounds), False)
@@ -221,8 +221,8 @@ def extract_and_store_updated_nonant_bounds(self, lr_outer_bound):
221221
nonzero_rc = np.where(self.rc_global==0, np.nan, self.rc_global)
222222
bound_tightening = np.divide(self.BestInnerBound - lr_outer_bound, nonzero_rc)
223223

224-
tighten_upper = np.where(bound_tightening>0, np.nan, bound_tightening)
225-
tighten_lower = np.where(bound_tightening<0, np.nan, bound_tightening)
224+
tighten_upper = np.where(bound_tightening>0, bound_tightening, np.nan)
225+
tighten_lower = np.where(bound_tightening<0, bound_tightening, np.nan)
226226

227227
tighten_upper += self._nonant_lower_bounds
228228
tighten_lower += self._nonant_upper_bounds
@@ -237,7 +237,15 @@ def extract_and_store_updated_nonant_bounds(self, lr_outer_bound):
237237
np.ceil(self._nonant_lower_bounds, out=self._nonant_lower_bounds, where=self._integer_variable_where)
238238
# floor of upper bounds for integer variables
239239
np.floor(self._nonant_upper_bounds, out=self._nonant_upper_bounds, where=self._integer_variable_where)
240-
240+
241+
self.put_send_buffer(
242+
self.send_buffers[Field.NONANT_LOWER_BOUNDS],
243+
Field.NONANT_LOWER_BOUNDS,
244+
)
245+
self.put_send_buffer(
246+
self.send_buffers[Field.NONANT_UPPER_BOUNDS],
247+
Field.NONANT_UPPER_BOUNDS,
248+
)
241249

242250
def main(self):
243251
# need the solution for ReducedCostsSpoke

mpisppy/cylinders/spcommunicator.py

+4
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ def update_nonant_bounds(self):
399399
"""
400400
bounds_modified = 0
401401
for _, _, recv_buf in self.receive_field_spcomms[Field.NONANT_LOWER_BOUNDS]:
402+
if not recv_buf.is_new():
403+
break
402404
for s in self.opt.local_scenarios.values():
403405
for ci, (ndn_i, xvar) in enumerate(s._mpisppy_data.nonant_indices.items()):
404406
xvarlb = xvar.lb
@@ -408,6 +410,8 @@ def update_nonant_bounds(self):
408410
xvar.lb = recv_buf[ci]
409411
bounds_modified += 1
410412
for _, _, recv_buf in self.receive_field_spcomms[Field.NONANT_UPPER_BOUNDS]:
413+
if not recv_buf.is_new():
414+
break
411415
for s in self.opt.local_scenarios.values():
412416
for ci, (ndn_i, xvar) in enumerate(s._mpisppy_data.nonant_indices.items()):
413417
xvarub = xvar.ub

mpisppy/extensions/cross_scen_extension.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ def _check_bound(self):
126126
cached_ph_obj[k].activate()
127127

128128
def get_from_cross_cuts(self):
129-
self.opt.spcomm.get_receive_buffer(
130-
self.cuts,
131-
Field.CROSS_SCENARIO_CUT,
132-
self.cross_scenario_index,
133-
)
129+
# self.opt.spcomm.get_receive_buffer(
130+
# self.cuts,
131+
# Field.CROSS_SCENARIO_CUT,
132+
# self.cross_scenario_index,
133+
# )
134134
if self.cuts.is_new():
135135
self.make_cuts(self.cuts.array())
136136

mpisppy/extensions/reduced_costs_fixer.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ def sync_with_spokes(self, pre_iter0 = False):
118118
# NOTE: If we do this, then the heuristic reduced cost fixing might fix
119119
# different variables in different subproblems. But this might be
120120
# fine.
121-
self.opt.spcomm.get_receive_buffer(
122-
self.reduced_cost_buf,
123-
Field.EXPECTED_REDUCED_COST,
124-
self.reduced_costs_spoke_index,
125-
)
126-
self.opt.spcomm.get_receive_buffer(
127-
self.outer_bound_buf,
128-
Field.OBJECTIVE_OUTER_BOUND,
129-
self.reduced_costs_spoke_index,
130-
)
121+
# self.opt.spcomm.get_receive_buffer(
122+
# self.reduced_cost_buf,
123+
# Field.EXPECTED_REDUCED_COST,
124+
# self.reduced_costs_spoke_index,
125+
# )
126+
# self.opt.spcomm.get_receive_buffer(
127+
# self.outer_bound_buf,
128+
# Field.OBJECTIVE_OUTER_BOUND,
129+
# self.reduced_costs_spoke_index,
130+
# )
131131
if self.reduced_cost_buf.is_new() and self.reduced_cost_buf.id() == self.outer_bound_buf.id():
132132
reduced_costs = self.reduced_cost_buf.value_array()
133133
this_outer_bound = self.outer_bound_buf.value_array()[0]

mpisppy/extensions/reduced_costs_rho.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ def register_receive_fields(self):
5454
)
5555

5656
def sync_with_spokes(self):
57-
self.opt.spcomm.get_receive_buffer(
58-
self.scenario_reduced_cost_buf,
59-
Field.SCENARIO_REDUCED_COST,
60-
self.reduced_costs_spoke_index,
61-
)
57+
# self.opt.spcomm.get_receive_buffer(
58+
# self.scenario_reduced_cost_buf,
59+
# Field.SCENARIO_REDUCED_COST,
60+
# self.reduced_costs_spoke_index,
61+
# )
6262
if self.scenario_reduced_cost_buf.is_new():
6363
self._scenario_rc_buffer[:] = self.scenario_reduced_cost_buf.value_array()
6464
# print(f"In ReducedCostsRho; {self._scenario_rc_buffer=}")

0 commit comments

Comments
 (0)