DifferentialEquations.jl ERROR: UndefVarError: CostVData not defined

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?

1 Like

Are you looking at very old documentation? I don’t think this is mentioned at all in the last 3 years.

1 Like

I just followed by google to this: https://docs.juliadiffeq.org/v1.9/analysis/parameter_estimation.html

so, ok, it’s not supported anymore…

The current version of the docs can be found here.

1 Like

It says version 1.9. DifferentialEquations is on version 6.11, so yeah, it is about 3 years old documentation :slight_smile:. I would recommend double checking version numbers if something odd is occurring: I am not sure why Google serves the old versions sometimes.

2 Likes

Yep :slight_smile: when you said, I looked at version in link. But when I followed the google and version is not metioned at page, and I didn’t pay attantion to link. I resolved all my questons in actual documentation. Thank you! It was wery suprpriset to try use old documentation with actual package :slight_smile: