JuliaDiff / JuliaDiff/DifferentiationInterface.jl
AutoFastDifferentiation not working with NamedTuple context
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 313
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
Issue
AutoFastDifferentiation is not able to deal with a NamedTuple context which could happen when the parameters of an optimization is a NamedTuple.
The error message:
ERROR: MethodError: no method matching variablize(::@NamedTuple{v1::Float64, v2::Float64}, ::Symbol)
Closest candidates are:
variablize(::AbstractArray, ::Symbol)
variablize(::Number, ::Symbol)
MWE
Example taken from Optimization.jl, and modified to have a NamedTuple as p and use AutoFastDifferentiation
using Optimization
import FastDifferentiation
rosenbrock(u, p) = (p.v1 - u[1])^2 + p.v2 * (u[2] - u[1]^2)^2
u0 = zeros(2)
p = (v1=1.0, v2=100.0)
optf = OptimizationFunction(rosenbrock, AutoFastDifferentiation())
prob = OptimizationProblem(optf, u0, p)
sol = solve(prob, Optimization.LBFGS())
AutoForwardDiff works fine.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the AutoFastDifferentiation path and the variablize methods shown in the error, then reproduce the provided Optimization.jl MWE with a NamedTuple parameter context. Done means the MWE runs successfully with AutoFastDifferentiation, without the missing-method error; compare its behavior with AutoForwardDiff.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100