Skip to content

Commit c1b17dd

Browse files
committed
add try/except for failed Lagrangian walk
1 parent 58d34be commit c1b17dd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

burnman/optimize/nonlinear_solvers.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,16 @@ def _lagrangian_walk_along_constraints(
444444
x_j = sol.x + lmda * dx
445445

446446
# Check feasibility
447-
x_j_min = sol.x + lmda_bounds_new[0] * dx
448-
F_j_min = self.F(x_j_min)
449-
dxbar_j_min = lu_solve(luJ, -F_j_min)
450-
dxbar_j_min_norm = np.linalg.norm(dxbar_j_min, ord=2)
451-
452-
if dxbar_j_min_norm > dx_norm or np.linalg.norm(dx, ord=2) < self.eps:
447+
try:
448+
x_j_min = sol.x + lmda_bounds_new[0] * dx
449+
F_j_min = self.F(x_j_min)
450+
dxbar_j_min = lu_solve(luJ, -F_j_min)
451+
dxbar_j_min_norm = np.linalg.norm(dxbar_j_min, ord=2)
452+
453+
if dxbar_j_min_norm > dx_norm or np.linalg.norm(dx, ord=2) < self.eps:
454+
persistent_bound_violation = True
455+
except Exception:
456+
# For example, if self.F(x_j_min) fails
453457
persistent_bound_violation = True
454458

455459
# Check newly violated inactive constraints

0 commit comments

Comments
 (0)