stevengj / nlopt

library for nonlinear optimization, wrapping many algorithms for global and local, constrained or unconstrained, optimization
Other
1.88k stars 584 forks source link

Simplex methods violate constraints? #429

Closed aitungthien closed 2 years ago

aitungthien commented 2 years ago

I am new to NLopt, and I'm running the test program in Fortran (t_fortran.90). I compile the program with gfortran on an iMac Pro running macOS Monterey. I got the results as expected, but when changing the algorithm to simplex (either by replacing NLOPT_LD_MMA with NLOPT_LN_NELDERMEAD or with NLOPT_LN_SBPLX and nothing else) I got x that violates a constraint. For Nelder-Mead, my results are: found min at -0.61699056911493244 0.0000000000000000
min val = 0.0000000000000000.

For Tom Rowan's "Subplex" algorithm, I got: found min at -0.51416665330003042 0.0000000000000000
min val = 0.0000000000000000.

With these methods, it seems that constraints were ignored. The values above are the same with their corresponding simplex algorithm when inequality constraints are not set.

Am I missing something obvious?

stevengj commented 2 years ago

Those methods don't support nonlinear inequality constraints. Probably they should throw an error if constraints are specified.

Or do you mean that they are ignoring bound constraints?