Help debugging `nlopt failure: -1` errors

Any tips on debugging nlopt failure: -1 errors? There is no information in the error message to understand what happened. Sometimes I have found that this occurs because I am computing something wrong in the gradient. But in other occasions I just can’t tell what happened. Is there a list of possible issues that can lead to this error?

It looks like that string is defined here and the function chk is called on setting parameters. I don’t think the C library is more specific than that.

I do have the same problem from time to time, for instance trying to set constraints on algorithms that do not take any and I would also benefit from finer error messages.

1 Like

In my particular scenario, I don’t have any constrains, and I am using :LD_LBFGS.

What is the cause of your errors?

I don’t know, that’s the problem. I already checked that the gradient is being computed correctly, and that it does not go to infinity. I’m not sure what else could be the cause of this.

Can you post the code?

I fear it is a very complicated optimization problem. That’s why I framed the question a bit more generally. I am interested in all the possible issues that could give raise to the nlopt failure: -1 error, or at least the most common causes, if such a list is possible.

I’m experiencing the same issue. I also have a pretty complicated optimization problem with 5 constraint functions. I’m using the LD_SLSQP algorithm.

Do similar problems arise with a different solver (e.g. Ipopt)?

The most common cause is that your gradient is wrong, and so the algorithm gives up.

So if I use autodiff I should never get this error. I will try that and see.