From 8311e89ac2af7dda3ffde0512db025cd1b86b305 Mon Sep 17 00:00:00 2001 From: Dario Panici Date: Mon, 11 Nov 2024 14:45:08 -0600 Subject: [PATCH] fix logic so that self consistency will be applied to non-Equilibrium objects when Proximal Projection is used --- desc/optimize/optimizer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/desc/optimize/optimizer.py b/desc/optimize/optimizer.py index 48e016b67c..99a57c926d 100644 --- a/desc/optimize/optimizer.py +++ b/desc/optimize/optimizer.py @@ -209,9 +209,11 @@ def optimize( # noqa: C901 - FIXME: simplify this objective, nonlinear_constraints = _maybe_wrap_nonlinear_constraints( eq, objective, nonlinear_constraints, self.method, options ) - if not isinstance(objective, ProximalProjection): - for t in things: - linear_constraints = maybe_add_self_consistency(t, linear_constraints) + is_prox = isinstance(objective, ProximalProjection) + for t in things: + if isinstance(t, Equilibrium) and is_prox: + continue # don't add Equilibrium self-consistency if proximal is used + linear_constraints = maybe_add_self_consistency(t, linear_constraints) linear_constraint = _combine_constraints(linear_constraints) nonlinear_constraint = _combine_constraints(nonlinear_constraints)