I try to otimize function with DifferentialEquations.jl + Optim.jl like in documetation, but I have:
ERROR: UndefVarError: CostVData not defined
using DifferentialEquations, Plots, Optim, LossFunctions, Random, DiffEqParamEstim, Distributions
function pkf1!(du,u,p,t)
du[1] = - p[1] * u[1]
du[2] = p[1] * u[1] - p[2] * u[2]
end
u0 = [3.0, 0.0]
p = [0.2, 0.15]
tspan = (0.0, 50.0)
prob = ODEProblem(pkf1!,u0,tspan, p)
sol = solve(prob)
plot(sol,vars=(1))
plot!(sol,vars=(2))
x = float.(collect(0:1:50))
y = hcat(sol.(x)...)'[:,2] .* exp.(rand(Normal(), length(x)) ./ 8)
plot!(x,y)
#lossfcn = L2Loss(x,y; weight=nothing)
lossfcn = CostVData(t,data;loss_func = L2Loss, weight=nothing)
cost_function = build_loss_objective(prob, Tsit5(), lossfcn)
result = optimize(cost_function, [0.4, 0.01])
when i use:
lossfcn = L2Loss(x,y; weight=nothing)
ERROR: MethodError: no method matching L2Loss(::Array{Float64,1}, ::Array{Float64,1}; weight=nothing)
it’s not working too, but works for:
lossfcn = L2Loss(x,y)
what package including CostVData?