From 51bcf9d8cb5aaaf09876261b68628fc00681aea3 Mon Sep 17 00:00:00 2001 From: Bernard Knueven Date: Fri, 10 Jan 2025 12:37:58 -0700 Subject: [PATCH] make sure prox_approx does not loop forever; tee all --- mpisppy/spopt.py | 5 ++--- mpisppy/utils/prox_approx.py | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mpisppy/spopt.py b/mpisppy/spopt.py index d17c88244..c1e146ba9 100644 --- a/mpisppy/spopt.py +++ b/mpisppy/spopt.py @@ -176,9 +176,8 @@ def _vb(msg): s._solver_plugin.options[option_key] = option_value solve_keyword_args = dict() - if self.cylinder_rank == 0: - if tee is not None and tee is True: - solve_keyword_args["tee"] = True + if tee is not None and tee is True: + solve_keyword_args["tee"] = True if (sputils.is_persistent(s._solver_plugin)): solve_keyword_args["save_results"] = False elif disable_pyomo_signal_handling: diff --git a/mpisppy/utils/prox_approx.py b/mpisppy/utils/prox_approx.py index 03c213643..eaab7cdcf 100644 --- a/mpisppy/utils/prox_approx.py +++ b/mpisppy/utils/prox_approx.py @@ -160,7 +160,9 @@ def check_tol_add_cut(self, tolerance, persistent_solver=None): # print(f"initial distance: {_f(this_val, x_pnt, y_pnt)**(0.5)}") # print(f"this_val: {this_val}") next_val = _newton_step(this_val, x_pnt, y_pnt) - while not isclose(this_val, next_val, rel_tol=1e-6, abs_tol=1e-6): + for _ in range(10): + if isclose(this_val, next_val, rel_tol=1e-6, abs_tol=1e-6): + break # print(f"newton step distance: {_f(next_val, x_pnt, y_pnt)**(0.5)}") # print(f"next_val: {next_val}") this_val = next_val