Skip to content

Commit

Permalink
Only exit SLSQP successfully if solution is feasible
Browse files Browse the repository at this point in the history
Previously, it could stop on ftol or xtol termination criteria, even if some constraints are still blatantly violated. This fixes stevengj#368.
  • Loading branch information
jcmonnin committed Jul 27, 2022
1 parent 17826b8 commit b88c8f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/algs/slsqp/slsqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,7 @@ nlopt_result nlopt_slsqp(unsigned n, nlopt_func f, void *f_data,
/* note: mode == -1 corresponds to the completion of a line search,
and is the only time we should check convergence (as in original slsqp code) */
if (mode == -1) {
if (!nlopt_isinf(fprev)) {
if (!nlopt_isinf(fprev) && feasible) {
if (nlopt_stop_ftol(stop, fcur, fprev))
ret = NLOPT_FTOL_REACHED;
else if (nlopt_stop_x(stop, xcur, xprev))
Expand Down

0 comments on commit b88c8f2

Please sign in to comment.