Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions mpisppy/cylinders/ph_dual_spoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ def main(self):
attach_prox = True
self.opt.PH_Prep(attach_prox=attach_prox, attach_smooth = smoothed)
trivial_bound = self.opt.Iter0()
if self.opt._can_update_best_bound():
self.opt.best_bound_obj_val = trivial_bound

# update the rho
self.update_rho()
Expand Down
2 changes: 0 additions & 2 deletions mpisppy/cylinders/subgradient_bounder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def main(self):
attach_prox = False
self.opt.PH_Prep(attach_prox=attach_prox, attach_smooth = 0)
trivial_bound = self.opt.Iter0()
if self.opt._can_update_best_bound():
self.opt.best_bound_obj_val = trivial_bound

# update the rho
self.update_rho()
Expand Down
2 changes: 0 additions & 2 deletions mpisppy/opt/aph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,6 @@ def APH_main(self, spcomm=None, finalize=True):
# End APH-specific Prep

trivial_bound = self.Iter0()
if self._can_update_best_bound():
self.best_bound_obj_val = trivial_bound

self.setup_Lens()
self.setup_dispatchrecord()
Expand Down
2 changes: 0 additions & 2 deletions mpisppy/opt/ph.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ def ph_main(self, finalize=True, attach_prox=True):
if (verbose):
print(f'Calling {self.__class__.__name__} Iter0 on global rank {global_rank}')
trivial_bound = self.Iter0()
if self._can_update_best_bound():
self.best_bound_obj_val = trivial_bound
if (verbose):
print(f'Completed {self.__class__.__name__} Iter0 on global rank {global_rank}')
if ('asynchronousPH' in self.options) and (self.options['asynchronousPH']):
Expand Down
4 changes: 4 additions & 0 deletions mpisppy/phbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,10 @@ def options_check(self):
if "time_limit" not in self.options:
self.options["time_limit"] = None

def _can_update_best_bound(self):
if not self.prox_disabled:
return False
return super()._can_update_best_bound()

def Iter0(self):
""" Create solvers and perform the initial PH solve (with no dual
Expand Down
7 changes: 5 additions & 2 deletions mpisppy/tests/test_xbar_w_reader_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,23 @@ def test_xbarwriter(self):
os.remove(self.temp_xbar_file_name)

def test_wreader(self):
self.ph_object = self._create_ph_farmer(ph_extensions=wxbarreader.WXBarReader, max_iter=1)
self.ph_object = self._create_ph_farmer(ph_extensions=wxbarreader.WXBarReader, max_iter=0)
for sname, scenario in self.ph_object.local_scenarios.items():
if sname == 'scen0':
self.assertAlmostEqual(scenario._mpisppy_model.W[("ROOT", 1)]._value, 70.84705093609978)
if sname == 'scen1':
self.assertAlmostEqual(scenario._mpisppy_model.W[("ROOT", 0)]._value, -41.104251445950844)

def test_xbarreader(self):
self.ph_object = self._create_ph_farmer(ph_extensions=wxbarreader.WXBarReader, max_iter=1)
self.ph_object = self._create_ph_farmer(ph_extensions=wxbarreader.WXBarReader, max_iter=0)
for sname, scenario in self.ph_object.local_scenarios.items():
if sname == 'scen0':
self.assertAlmostEqual(scenario._mpisppy_model.xbars[("ROOT", 1)]._value, 274.2239371483933)
if sname == 'scen1':
self.assertAlmostEqual(scenario._mpisppy_model.xbars[("ROOT", 0)]._value, 96.88717449844287)




if __name__ == '__main__':
unittest.main()
26 changes: 12 additions & 14 deletions mpisppy/utils/wxbarreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,23 @@ def __init__(self, ph):
self.sep_files = sep_files

def pre_iter0(self):
pass

if self.not_active:
return # nothing to do.
if self.w_fname:
mpisppy.utils.wxbarutils.set_W_from_file(
self.w_fname, self.PHB, self.cylinder_rank,
sep_files=self.sep_files)
self.PHB._reenable_W() # This makes a big difference.
if self.x_fname:
mpisppy.utils.wxbarutils.set_xbar_from_file(self.x_fname, self.PHB)
self.PHB._reenable_prox()

def post_iter0(self):
pass

def miditer(self):
''' Called before the solveloop is called '''
if self.not_active:
return # nothing to do.
if self.PHB._PHIter == 1:
if self.w_fname:
mpisppy.utils.wxbarutils.set_W_from_file(
self.w_fname, self.PHB, self.cylinder_rank,
sep_files=self.sep_files)
self.PHB._reenable_W() # This makes a big difference.
if self.x_fname:
mpisppy.utils.wxbarutils.set_xbar_from_file(self.x_fname, self.PHB)
self.PHB._reenable_prox()
pass

def enditer(self):
''' Called after the solve loop '''
Expand Down
Loading