Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nloptr SLSQP returning successful flag despite constraints being unmet #368

Closed
ssmil opened this issue Nov 22, 2020 · 1 comment · Fixed by #465
Closed

nloptr SLSQP returning successful flag despite constraints being unmet #368

ssmil opened this issue Nov 22, 2020 · 1 comment · Fixed by #465

Comments

@ssmil
Copy link

ssmil commented Nov 22, 2020

Hello,

I'm having an issue where nlopt is returning a successful exit flag, but only 1 of my 6 constraints are met. I am running many optimizations at once and using the exit flags as automatic checks, so this is causing me some significant issues. I've attached a file with the code I'm running.

I'm using nloptr version 1.2.2.2, algorithm "NLOPT_LD_SLSQP".

iteration: 16
x = ( 1.000000, 1.000000, 1.552908, 1.855128 )
f(x) = -1.907547
h(x) = ( 15.437643, 5.305731 )
g(x) = ( -2.609576, 0.328356, 0.500000, 3.871769 )

rest.CI.GI$status
[1] 3

nloptr flag issue.zip

jcmonnin added a commit to jcmonnin/nlopt that referenced this issue Jul 27, 2022
Previously, it could stop on ftol or xtol termination criteria, even if some constraints are still blatantly violated. This fixes stevengj#368.
@jcmonnin
Copy link
Contributor

I have also encountered this issue in the past, and it looks like others had that too:
https://www.mail-archive.com/nlopt-discuss@ab-initio.mit.edu/msg00708.html

Below are some links about this issue in the Python implementation (which is based on the same fortran code):
scipy/scipy#7282
scipy/scipy#7618
scipy/scipy#8986

I have not tried to understand the python fix, however I have been using a simple fix which seems to do the trick, altough it's probably far from optimal (pull request #465).

Alternatively to

       if (!nlopt_isinf(fprev) && feasible) {

I wonder if following is better

       if (!nlopt_isinf(fprev) && feasible_cur) {

In the latter, it waits until a new feasible solution that meets the contraint before deciding on the ftol/xtol termination criteria.

2f81804 from an old pull request is also vaguely related to this.

stevengj pushed a commit that referenced this issue Jul 28, 2022
Previously, it could stop on ftol or xtol termination criteria, even if some constraints are still blatantly violated. This fixes #368.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants