# Nlopt forced stop

**URL:** https://discourse.julialang.org/t/nlopt-forced-stop/114727
**Category:** Optimization (Mathematical)
**Tags:** nlopt, gradient
**Created:** [May 25, 2024, 4:47pm UTC](https://discourse.julialang.org/t/nlopt-forced-stop/114727 "2024-05-25T16:47:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![mary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mary/32/53139_2.png) [@mary](https://discourse.julialang.org/u/mary)
#### Post date: [May 25, 2024, 4:47pm UTC](https://discourse.julialang.org/t/nlopt-forced-stop/114727/1 "2024-05-25T16:47:17Z")

</div>

Hi, I am using Nlopt for a gradient based optimization. It stopes after 4 iterations and returns forced stop and the output is not converged. Could you please tell me how can I find the problem which makes optimizer to forced stop?

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [May 25, 2024, 8:28pm UTC](https://discourse.julialang.org/t/nlopt-forced-stop/114727/2 "2024-05-25T20:28:42Z")

</div>

Can you share a reproducible example?

You should also try updating to the most recent version of NLopt, we made some improvements in how errors are reported.

---

<div class="post-metadata">

### Author: ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)
#### Post date: [May 26, 2024, 1:05am UTC](https://discourse.julialang.org/t/nlopt-forced-stop/114727/3 "2024-05-26T01:05:00Z")

</div>

Try wrapping the optimized function in `try ... catch` to see the error message that NLOpt swallowed:

```julia
function fmin(x)	
	dev = try
		_fmin(x);
	catch e
    	bt = catch_backtrace()
    	showerror(stdout, e, bt)
    	rethrow(e)
	end

	return dev
end

```
