-
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
Can not run test example in Julia #149
Comments
Can you please post the code you tried? See also https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757 |
I just tried it, and the tutorial code works fine for me in Julia 1.5 with a fresh install of NLopt. |
I also tried the tutorial code. Only 2 gradient-using algorithms work: LD_MMA, and LD_SLSQP. The other 7 algorithms of the NLopt library (LD_LBFGS, LD_TNEWTON - all 4 variants, LD_VAR1, LD_VAR2) all give the error at the first call of inequality_constraint!(...) : The documentation does not tell, what the problem is, and how to get around it. Can anyone help? |
Hello
|
What happens if you execute the code right after starting Julia again? Stacktrace [5] mentions |
I did try a bunch of packages before this example, including Optim. Let me try to restart. Just to be clear. Does this mean that running NLopt is incompatible with using Optim? |
No error now but it performs only one iteration and exits with |
The variable "ax" does not exist. If you mean multiplication, use "a*x" |
Thanks, I just copied an pasted the example without checking. I am still learning. I started programming in Julia yesterday afternoon but it is really simple. I have already implemented a working DE. |
Closing as non-reproducible: julia> using NLopt
julia> function myfunc(x::Vector, grad::Vector)
if length(grad) > 0
grad[1] = 0
grad[2] = 0.5/sqrt(x[2])
end
return sqrt(x[2])
end
myfunc (generic function with 1 method)
julia> function myconstraint(x::Vector, grad::Vector, a, b)
if length(grad) > 0
grad[1] = 3a * (a * x[1] + b)^2
grad[2] = -1
end
(a * x[1] + b)^3 - x[2]
end
myconstraint (generic function with 1 method)
julia> opt = Opt(:LD_MMA, 2)
Opt(LD_MMA, 2)
julia> opt.lower_bounds = [-Inf, 0.]
2-element Vector{Float64}:
-Inf
0.0
julia> opt.xtol_rel = 1e-4
0.0001
julia> opt.min_objective = myfunc
myfunc (generic function with 1 method)
julia> inequality_constraint!(opt, (x,g) -> myconstraint(x,g,2,0), 1e-8)
julia> inequality_constraint!(opt, (x,g) -> myconstraint(x,g,-1,1), 1e-8)
julia> (minf,minx,ret) = optimize(opt, [1.234, 5.678])
(0.5443310477213124, [0.3333333342139688, 0.29629628951338166], :XTOL_REACHED) The If anyone has follow-up questions to this thread, please post on the community forum, https://discourse.julialang.org/c/domain/opt/13, and tag me |
I added NLopt to my Julia 1.5 installation. Pkg.add a well using finishing without error message. However the test examples dont run.
In both myfunc and myconstraint the ::Vector is not acceptedthe lines inequality.constraint are also not accepted by Julia.
My be you can help.
Thank you and best regards
Chris
The text was updated successfully, but these errors were encountered: