Skip to content

Commit e487023

Browse files
authored
Merge pull request #493 from bknueven/fix_subgradient_main
Bugfix: subgradient_main incorrectly runs PH
2 parents 9413a74 + 0c8c59c commit e487023

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Diff for: mpisppy/cylinders/hub.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import abc
1111
import logging
1212
import mpisppy.log
13-
from mpisppy.opt.subgradient import Subgradient
1413
from mpisppy.opt.aph import APH
1514

1615
from mpisppy import MPI
@@ -27,6 +26,9 @@
2726
logger = logging.getLogger("mpisppy.cylinders.Hub")
2827

2928
class Hub(SPCommunicator):
29+
30+
_hub_algo_best_bound_provider = False
31+
3032
def __init__(self, spbase_object, fullcomm, strata_comm, cylinder_comm, spokes, options=None):
3133
super().__init__(spbase_object, fullcomm, strata_comm, cylinder_comm, options=options)
3234
assert len(spokes) == self.n_spokes
@@ -548,7 +550,7 @@ def is_converged(self):
548550
return False
549551

550552
if not self.has_outerbound_spokes:
551-
if self.opt._PHIter == 1 and not isinstance(self.opt, Subgradient):
553+
if self.opt._PHIter == 1 and not self._hub_algo_best_bound_provider:
552554
global_toc(
553555
"Without outer bound spokes, no progress "
554556
"will be made on the Best Bound")
@@ -704,6 +706,16 @@ def send_nonants(self):
704706
for idx in self.nonant_spoke_indices:
705707
self.hub_to_spoke(nonant_send_buffer, idx)
706708

709+
710+
class SubgradientHub(PHHub):
711+
712+
_hub_algo_best_bound_provider = True
713+
714+
def main(self):
715+
""" SPComm gets attached in self.__init__ """
716+
self.opt.subgradient_main(finalize=False)
717+
718+
707719
class APHHub(PHHub):
708720

709721
def main(self):

Diff for: mpisppy/opt/subgradient.py

-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ def subgradient_main(self, finalize=True):
3737
The "trivial bound", computed by solving the model with no
3838
nonanticipativity constraints (immediately after iter 0).
3939
"""
40-
return self.ph_main(finalize=finalize)
41-
42-
def ph_main(self, finalize=True):
4340
# for use with the PH hub
4441
if self.options["smoothed"] != 0:
4542
raise RuntimeError("Cannnot use smoothing with Subgradient algorithm")

Diff for: mpisppy/utils/cfg_vanilla.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
from mpisppy.cylinders.slam_heuristic import SlamMaxHeuristic, SlamMinHeuristic
3636
from mpisppy.cylinders.cross_scen_spoke import CrossScenarioCutSpoke
3737
from mpisppy.cylinders.reduced_costs_spoke import ReducedCostsSpoke
38-
from mpisppy.cylinders.hub import PHHub
39-
from mpisppy.cylinders.hub import APHHub
38+
from mpisppy.cylinders.hub import PHHub, SubgradientHub, APHHub
4039
from mpisppy.extensions.extension import MultiExtension
4140
from mpisppy.extensions.fixer import Fixer
4241
from mpisppy.extensions.integer_relax_then_enforce import IntegerRelaxThenEnforce
@@ -195,7 +194,7 @@ def subgradient_hub(cfg,
195194
options["smoothed"] = 0
196195

197196
hub_dict = {
198-
"hub_class": PHHub,
197+
"hub_class": SubgradientHub,
199198
"hub_kwargs": {"options": {"rel_gap": cfg.rel_gap,
200199
"abs_gap": cfg.abs_gap,
201200
"max_stalled_iters": cfg.max_stalled_iters}},

0 commit comments

Comments
 (0)