-
Notifications
You must be signed in to change notification settings - Fork 46
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
Ctrl-C exception in REPL #68
Comments
|
somewhat confused, so I was ideally looking for a MWE (of something that works in REPL/terminal/for multiple processes) |
Just throw the exception from your objective function. |
In this dummy example (that will just run for 10 sec)
would |
When I run it, I get
|
I read the README and also found this thread, but I never seem to get exceptions back when I call |
Closing because this seems to work fine. julia> count = 0
0
julia> using NLopt
julia> function myfunc(x::Vector, grad::Vector)
global count
count::Int += 1
res = sqrt(x[2])
return res
end
myfunc (generic function with 1 method)
julia> function run_opt()
opt = Opt(:GN_ISRES, 2)
upper_bounds!(opt, [100.0, 100.0])
lower_bounds!(opt, [0.0, 0.0])
min_objective!(opt, myfunc)
maxtime!(opt, 10.0)
(minf,minx,ret) = optimize(opt, [1.234, 5.678])
return (minf,minx,ret)
end
run_opt (generic function with 1 method)
julia> run_opt()
^C(0.0, [6.676949509795536, 0.0], :FORCED_STOP) The forced stop issue is covered by #156. |
Is there a snippet of code / example of throwing a CTRL-C exception that would gracefully halt an NLopt optimization in julia REPL?
The text was updated successfully, but these errors were encountered: