Skip to content

Commit

Permalink
slsqp: check p>n (#593)
Browse files Browse the repository at this point in the history
* slsqp: check p>n

Closes #592

* Update src/algs/slsqp/slsqp.c

---------

Co-authored-by: Steven G. Johnson <[email protected]>
  • Loading branch information
jschueller and stevengj authored Feb 18, 2025
1 parent 128b04c commit 1af6c51
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/algs/slsqp/slsqp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,11 @@ nlopt_result nlopt_slsqp(unsigned n, nlopt_func f, void *f_data,
unsigned max_cdim;
int want_grad = 1;

if (p > n) {
nlopt_stop_msg(stop, "slsqp: more equality constraints than variables");
return NLOPT_INVALID_ARGS;
}

max_cdim = MAX2(nlopt_max_constraint_dim(m, fc),
nlopt_max_constraint_dim(p, h));
length_work(&len_w, &len_jw, mpi, pi, ni);
Expand Down

0 comments on commit 1af6c51

Please sign in to comment.