It gives me the error
MethodError: no method matching abs2(::ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing,
Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, ODEProblem{Vector{Float64},
Tuple{Float64, Float64}, false, SciMLBase.NullParameters, ODEFunction{false,
SciMLBase.AutoSpecialize, var"#11#12", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing,
Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing,
typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem},
Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False},
OrdinaryDiffEq.InterpolationData{ODEFunction{false, SciMLBase.AutoSpecialize, var"#11#12",
UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing,
Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing,
Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}},
OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}}, DiffEqBase.DEStats})
Closest candidates are:
I solved instead using the help of output_func
:
prob = ODEProblem((u,p,t)->1.01*u, [0.5,0.5], (0.0,1.0))
function prob_func(prob,i,repeat)
remake(prob,u0=rand().*prob.u0)
end
function output_func(sol, i)
(hcat(map(x->abs2.(x), sol.u)...), false)
end
function reduction(u,batch,I)
tmp = sum(cat(batch..., dims = 3), dims = 3)
length(u) == 0 && return tmp, false
cat(u, tmp, dims = 3), false
end
ensemble_prob = EnsembleProblem(prob, prob_func=prob_func, output_func=output_func, reduction=reduction)
sim = solve(ensemble_prob,Tsit5(),EnsembleSerial(),trajectories=100,batch_size = 20);
solution = sum(sim.u, dims = 3) ./ 100