I am getting a typeassert problem when I use the build_objective_function
in combination with forward AD. Optimization is via Optim
. It works if I use finite differencing or e.g. Tsit5()
instead of Rosenbrock23()
as the ode solver.
MWE:
using DiffEqParamEstim, DifferentialEquations, Optim
function ODE(dxdt,x,p,t)
C = 70000. + p[1]*t/500. + p[2]
D = 1.
dxdt[1] = - C - D
dxdt[2] = C
dxdt[3] = D
end
u0 = [0.25235; 0.; 0.]
tspan = (0.,200.)
p0 = [1.;1.]
prob = ODEProblem(ODE, u0, tspan,p0)
sol = solve(prob,Rosenbrock23())
t = collect(range(0,stop=1110.,length=200))
randomized = VectorOfArray([(sol(t[i]) + .01randn(3)) for i in 1:length(t)])
data = convert(Array,randomized)
cost_function = build_loss_objective(prob,Rosenbrock23(),L2Loss(t,data),maxiters=10000,verbose=false)
result = optimize(cost_function, zeros(2), 10.0*ones(2), [4.,5.],autodiff=:forward)