|
31 | 31 | from pyomo.core.expr.visitor import replace_expressions
|
32 | 32 | from pyomo.core.expr.numeric_expr import LinearExpression
|
33 | 33 |
|
34 |
| -from mpisppy.cylinders.spoke import Spoke |
35 |
| -from mpisppy.cylinders.hub import FWPHHub |
36 | 34 | from mpisppy.cylinders.xhatshufflelooper_bounder import ScenarioCycler
|
37 | 35 | from mpisppy.extensions.xhatbase import XhatBase
|
38 | 36 |
|
@@ -72,7 +70,6 @@ def __init__(
|
72 | 70 |
|
73 | 71 | def _init(self, FW_options):
|
74 | 72 | self.FW_options = FW_options
|
75 |
| - self.FW_options["save_file"] = "fwph_bench.out" |
76 | 73 | self._options_checks_fw()
|
77 | 74 | self.vb = True
|
78 | 75 | if ('FW_verbose' in self.FW_options):
|
@@ -146,7 +143,7 @@ def fwph_main(self, finalize=True):
|
146 | 143 | if (self.extensions):
|
147 | 144 | self.extobject.miditer()
|
148 | 145 |
|
149 |
| - if isinstance(self.spcomm, FWPHHub): |
| 146 | + if hasattr(self.spcomm, "sync_Ws"): |
150 | 147 | self.spcomm.sync_Ws()
|
151 | 148 | if (self._is_timed_out()):
|
152 | 149 | # TODO: replace the convergence messages with global_toc
|
@@ -212,20 +209,19 @@ def fwph_main(self, finalize=True):
|
212 | 209 | self._reenable_W()
|
213 | 210 |
|
214 | 211 | ## Hubs/spokes take precedence over convergers
|
215 |
| - if self.spcomm: |
216 |
| - if isinstance(self.spcomm, FWPHHub): |
217 |
| - self.spcomm.sync_nonants() |
218 |
| - self.spcomm.sync_bounds() |
219 |
| - self.spcomm.sync_extensions() |
| 212 | + if hasattr(self.spcomm, "sync_nonants"): |
| 213 | + self.spcomm.sync_nonants() |
| 214 | + self.spcomm.sync_bounds() |
| 215 | + self.spcomm.sync_extensions() |
220 | 216 | if self.spcomm.is_converged():
|
221 | 217 | secs = time.time() - self.t0
|
222 | 218 | self._output(self._local_bound,
|
223 | 219 | best_bound, np.nan, secs)
|
224 | 220 | if (self.cylinder_rank == 0 and self.vb):
|
225 | 221 | print('FWPH converged to user-specified criteria')
|
226 | 222 | break
|
227 |
| - if isinstance(self.spcomm, Spoke): |
228 |
| - self.spcomm.sync() |
| 223 | + elif hasattr(self.spcomm, "sync"): |
| 224 | + self.spcomm.sync() |
229 | 225 |
|
230 | 226 | if (self.extensions):
|
231 | 227 | self.extobject.enditer_after_sync()
|
@@ -509,9 +505,7 @@ def _attach_nonant_objective(self, mip, _print_warning=[True]):
|
509 | 505 | obj = find_active_objective(mip)
|
510 | 506 | repn = generate_standard_repn(obj.expr, compute_values=False, quadratic=False)
|
511 | 507 | nonant_var_ids = mip._mpisppy_data.varid_to_nonant_index
|
512 |
| - if len(repn.nonlinear_vars) > 0: |
513 |
| - # hopefull a small number |
514 |
| - nonlinear_vars = {id(v) for v in repn.nonlinear_vars} |
| 508 | + if repn.nonlinear_vars: |
515 | 509 | for v in repn.nonlinear_vars:
|
516 | 510 | if id(v) in nonant_var_ids:
|
517 | 511 | raise RuntimeError("FWPH does not support models where the nonants "
|
|
0 commit comments