-
Notifications
You must be signed in to change notification settings - Fork 221
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
MethodError when using ComponentArrays #924
Comments
It only happens with methods requiring a Hessian: |
The error seems to stem from here https://github.com/JuliaNLSolvers/NLSolversBase.jl/blob/62d2199f70cce78479658da08d346bbc060fc2f7/src/objective_types/twicedifferentiable.jl#L116 a fix wold be to relax that type annotation on NLSolversBase |
should those types be changed to |
I did a PR to NLSolversBase.jl once, so I had a rough idea 😅, I checked the FiniteDiff.jl Package and they accept AbstractVector{<:Number} and AbstractMatrix{<:Number}. (but the best course of action would be to eliminate that type parameter), I can make a PR tomorrow |
but |
That a little subtlety of the type system, a |
A similar thing happens with
|
That last problem is in Optim.jl, not in NLSolversBase.jl. The |
There is also an issue in line 36, where the kwords are by default empty vectors |
As far as I remember, one cannot make an instance of an abstract type, no? |
Nope, you can't, the main problem is how do |
Pardon my ignorance, I'm trying to learn.
That is to be able to initialize |
As far as I understand, yes, but maybe it's not nessesary. I was reading the code, and the ParticleSwarm struct initializes a state, maybe if the lower and upper variables are moved to that state, the problem could be avoided, but its a conjecture until I have some time to test it on my machine |
Unfortunately ParticleSwarm uses a different lower/upper interface than Fminbox for example. It should ideally be |
this should be fixed once a new version of NLSolversBase.jl gets registered |
Yeah, I don't know. JuliaRegistrator doesn't seem to be catching my registration for some reason. Worked for Optim the other day. |
should be up to date now JuliaRegistries/General#41797 |
I'm getting similar problems on the latest version, is there any update on this? using Optimization, OptimizationOptimJL, ForwardDiff, ComponentArrays
rosenbrock(x, p) = (p.p1 - x.x1)^2 + p.p2 * (x.x1 - x.x2^2)^2
cons(res, x, p) = (res .= [x.x1^2+x.x2^2, x.x1*x.x2])
x0 = ComponentArray{Float64}(x1=0;x2=0)
p = ComponentArray{Float64}(p1=1;p2=2)
optprob = OptimizationFunction(rosenbrock, Optimization.AutoForwardDiff(), cons = cons)
prob = OptimizationProblem(optprob, x0, p, lcons = [-Inf, -1.0], ucons = [0.8, 2.0])
sol = solve(prob, IPNewton()) |
This is a different problem. I will have to see if Matrix is needed or not here. |
see here: jonniedie/ComponentArrays.jl#91
errors with
this happens only with finite differentiation, with
autodiff=:forward
the error is avoided:The text was updated successfully, but these errors were encountered: