NLopt.jl icon indicating copy to clipboard operation
NLopt.jl copied to clipboard

ERROR: nlopt failure

Open jeff-regier opened this issue 9 years ago • 14 comments

I often encounter "ERROR: nlopt failure" when I run NLopt with ftol_abs set to let less than 1e-6. Is that behavior to be expected? I'd like to set ftol_abs to about 1e-8. The derivatives I pass to NLopt are all analytic, and I've verified them in test cases by comparing them to results from numeric differentiation. Are these errors likely due to numerical instability, i.e. slight incompatibilities between the objective function's values the derivatives? Or are there other common causes of nlopt failures? Are there any standard ways to work around this type of error? Thanks.

jeff-regier avatar Feb 22 '15 21:02 jeff-regier

Which algorithm are you using?

At some point, you will run into roundoff-error limitations, although in that case NLopt should ideally throw a "roundoff-limited" exception.

stevengj avatar Feb 24 '15 17:02 stevengj

LD_LBFGS. I've never encountered a "roundoff-limited" exception, only "nlopt failure".

jeff-regier avatar Feb 24 '15 17:02 jeff-regier

Do you have a simple test case that illustrates this?

stevengj avatar Apr 17 '15 16:04 stevengj

I don't, unfortunately. I realize that makes it pretty difficult to diagnose the problem without one. The problem only appears for fairly complicated optimization problems. If I can recreate it without a lot of optimization variables, I'll post the code here.

jeff-regier avatar Apr 17 '15 17:04 jeff-regier

See also stevengj/nlopt#28 (a vaguely similar issue with SLSQP, which I'm also having difficulty reproducing).

stevengj avatar Apr 17 '15 17:04 stevengj

Using NLopt (LD_LBFGS solver in Julia), I am receiving nlopt failure error. I am suspicious that the options are not set properly. I am wondering how to check that option parameters passed is actually set correctly?

I ask because I am setting fairly large values as below

NLopt.ftol_abs!(opts, 0.1);
NLopt.xtol_abs!(opts, 0.1);    
NLopt.ftol_rel!(opts, 0.1);
NLopt.xtol_rel!(opts, 0.1);
NLopt.maxeval!(opts, 100);   
NLopt.min_objective!(opts, fun);
NLopt.lower_bounds!(opts, 0.0);
obj, X, ret = NLopt.optimize(opts, X0)

But what I see is that, while objective is fixed up to 6 digits, solution up to 9 digits, and gradient is small (order of 1e-7 to 1e-15) the optimization does not stop, until it sends an

nlopt failure Error

which there is no clue why the error happens.

danamm avatar May 07 '15 00:05 danamm

If the options are incorrect it would throw a different exception. The BFGS failures are a bit harder to diagnose (in part because the Fortran BFGS code I am calling is rather opaque), but usually stem from you gradient not being accurate enough. Do you have an analytical gradient? If so, have you checked it against a finite-difference approximation?

stevengj avatar May 12 '15 16:05 stevengj

Yes, analytical gradients are used, and I have checked correctness against Calculus.gradient.

danamm avatar May 16 '15 21:05 danamm

I'm getting this problem too in my complicated optimization. I'm using LBFGS and analytic gradients. I've never seen a roundoff error, only "nlopt failure -1". It goes away if I relax ftol_abs. Sorry I don't have a simple test case.

jotwin avatar May 18 '17 19:05 jotwin

I am using NLOPT on G1 CEC test problem, I use the lower bounds as start points which are all in the feasible region. However, The error

nlopt.RoundoffLimited: NLopt roundoff-limited

appears, but after running several times it may not appear but then appears again.

It doesn't make the code predictable, so I wonder if its due to a bug in the nlopt library, please advise me how to get over it. Thanks

reem21090 avatar Jun 08 '19 06:06 reem21090

@reem21090 Can you provide a minimal working example of your code?

mzaffalon avatar Jun 08 '19 06:06 mzaffalon

@reem21090 Can you provide a minimal working example of your code?

Thank you, it's working well now. But I am suspicious about this unpredictable behavior.

reem21090 avatar Jun 08 '19 07:06 reem21090

Hi, here is my minimal working example code which always gives a roundoff error i really don't know how to solve it. any suggestions? main.txt

liuliucen avatar Jun 22 '20 07:06 liuliucen

So for me, I've got this error a lot when the initial points are too close to the minimum. So I'll artificially set the somewhere else (e.g. by the sqrt(inv_hessian)

jonas-eschle avatar Feb 24 '21 20:02 jonas-eschle