Hi all. For my ensemble problem, I would like to randomize the initial conditions for each trajectory. However, I would like the sum of certain species to remain a fixed number. For example, if u0 is my set of initial conditions, I would like u0[1] + u0[3] + u0[4] = 16 and u0[2] + u0[5] = 10 for every trajectory. Would anyone know how this is best achieved?
So, first about the math. Let’s say you want to ensure the conditions you mentioned, then you could use
u0 = rand(5)
u0[ [1,3,4] ] .*= 16.0 / ( u0[1] + u0[3] + u0[4] )
u0[ [2,5] ] .*= 10.0 / ( u0[2] + u0[5] )
This works since the conditions do not overlap.
Using the setup as in
Parallel Ensemble Simulations · DifferentialEquations.jl
the next step would be to adapt the prob_func
callback, e.g.
function prob_func(prob,i,repeat)
@. prob.u0 = rand( size(prob.u0) )
prob.u0[ [1,3,4] ] .*= 16.0 / ( prob.u0[1] + prob.u0[3] + prob.u0[4] )
prob.u0[ [2,5] ] .*= 10.0 / ( prob.u0[2] + prob.u0[5] )
return prob
end
Thank you so much for your response! I tried out your suggestion on a model that I’m currently working on, and I keep running into this error:
TaskFailedException
nested task error: ArgumentError: range must be non-empty
Stacktrace:
[1] SamplerRangeNDL
@ C:\Julia\Julia-1.7.3\share\julia\stdlib\v1.7\Random\src\generation.jl:321 [inlined]
[2] Random.Sampler(#unused#::Type{Random.TaskLocalRNG}, r::Base.OneTo{Int64}, #unused#::Val{1})
@ Random C:\Julia\Julia-1.7.3\share\julia\stdlib\v1.7\Random\src\generation.jl:189
[3] macro expansion
@ C:\Julia\Julia-1.7.3\share\julia\stdlib\v1.7\Random\src\generation.jl:522 [inlined]
[4] Random.Sampler(RNG::Type{Random.TaskLocalRNG}, t::Tuple{}, n::Val{1})
@ Random C:\Julia\Julia-1.7.3\share\julia\stdlib\v1.7\Random\src\generation.jl:522
[5] Random.Sampler(rng::Random.TaskLocalRNG, x::Tuple{}, r::Val{1})
@ Random C:\Julia\Julia-1.7.3\share\julia\stdlib\v1.7\Random\src\Random.jl:140
[6] rand(rng::Random.TaskLocalRNG, X::Tuple{})
@ Random C:\Julia\Julia-1.7.3\share\julia\stdlib\v1.7\Random\src\Random.jl:256
[7] rand(X::Tuple{})
@ Random C:\Julia\Julia-1.7.3\share\julia\stdlib\v1.7\Random\src\Random.jl:259
[8] _broadcast_getindex_evalf
@ .\broadcast.jl:670 [inlined]
[9] _broadcast_getindex
@ .\broadcast.jl:643 [inlined]
[10] getindex
@ .\broadcast.jl:597 [inlined]
[11] macro expansion
@ .\broadcast.jl:961 [inlined]
[12] macro expansion
@ .\simdloop.jl:77 [inlined]
[13] copyto!
@ .\broadcast.jl:960 [inlined]
[14] copyto!
@ .\broadcast.jl:913 [inlined]
[15] materialize!
@ .\broadcast.jl:871 [inlined]
[16] materialize!
@ .\broadcast.jl:868 [inlined]
[17] prob_func(prob::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, i::Int64, repeat::Int64)
@ Main.workspace#3 C:\Users\Dragolonth\Downloads\Pluto\Pluto\ensemble.jl#==#035d6a40-a7e5-4884-8409-8b11ebde32c4:2
[18] batch_func(i::Int64, prob::EnsembleProblem{ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, typeof(Main.workspace#3.prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, alg::Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ SciMLBase C:\Users\Dragolonth\.julia\packages\SciMLBase\QzHjf\src\ensemble\basic_ensemble_solve.jl:90
[19] batch_func
@ C:\Users\Dragolonth\.julia\packages\SciMLBase\QzHjf\src\ensemble\basic_ensemble_solve.jl:88 [inlined]
[20] #507
@ C:\Users\Dragolonth\.julia\packages\SciMLBase\QzHjf\src\ensemble\basic_ensemble_solve.jl:165 [inlined]
[21] macro expansion
@ C:\Users\Dragolonth\.julia\packages\SciMLBase\QzHjf\src\ensemble\basic_ensemble_solve.jl:174 [inlined]
[22] (::SciMLBase.var"#400#threadsfor_fun#510"{SciMLBase.var"#507#509"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, EnsembleProblem{ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, typeof(Main.workspace#3.prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, Tuple{UnitRange{Int64}}, Vector{ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.DEStats}}, UnitRange{Int64}})(onethread::Bool)
@ SciMLBase .\threadingconstructs.jl:85
[23] (::SciMLBase.var"#400#threadsfor_fun#510"{SciMLBase.var"#507#509"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, EnsembleProblem{ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, typeof(Main.workspace#3.prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, Tuple{UnitRange{Int64}}, Vector{ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.DEStats}}, UnitRange{Int64}})()
@ SciMLBase .\threadingconstructs.jl:52
wait@task.jl:334[inlined]
threading_run(::Function)@threadingconstructs.jl:38
macro expansion@threadingconstructs.jl:97[inlined]
tmap(::Function, ::UnitRange{Int64})@basic_ensemble_solve.jl:173
#solve_batch#505@basic_ensemble_solve.jl:164[inlined]
solve_batch@basic_ensemble_solve.jl:153[inlined]
macro expansion@timing.jl:299[inlined]
var"#__solve#497"(::Int64, ::Int64, ::Int64, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(SciMLBase.__solve), ::EnsembleProblem{ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, typeof(Main.workspace#3.prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, ::Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, ::EnsembleThreads)@basic_ensemble_solve.jl:56
#__solve#496@basic_ensemble_solve.jl:36[inlined]
#solve#35@solve.jl:799[inlined]
top-level scope@Local: 3[inlined]
For reference, this is my code:
begin
u0 = rand(19)
u0[[1,3,5,6,8,9,11,13,14,16]].*=23.0894161/(u0[1]+u0[3]+u0[5]+u0[6]+u0[8]+u0[9]+u0[11]+u0[13]+u0[14]+u0[16])
u0[[4,5,12,13,17]].*=11.7415975/(u0[4]+u0[5]+u0[12]+u0[13]+u0[17])
u0[[7,8]].*=1.65364899/(u0[7]+u0[8])
u0[[15,16]].*=1.600634/(u0[15]+u0[16])
u0[[18,19]].*=31.332181/(u0[18]+u0[19])
u0
end
begin
shuttle_p=[572.33325,0.86466471,497.36877,621.36128,1.0,1.3644395,0.15494754,0.15494754,3.3039764,0.95021215,0.95021215,44.841332,0.11958495,5.2791399,1.0,3.4134082,0.98168436,0.98168436,3.4134082,0.98168436,0.98168436,0.99326205,0.99326205,1.0,46.14552,0.68684769,1.7182818,0.44818131,0.68684769,5.0365E-2,8.7128E-2]
tspan = (0.0,250.0)
prob = ODEProblem(shuttle,u0,tspan,shuttle_p)
end
function prob_func(prob,i,repeat)
@. prob.u0 = rand(size(prob.u0))
prob.u0[[1,3,5,6,8,9,11,13,14,16]].*=23.0894161/(prob.u0[1]+prob.u0[3]+prob.u0[5]+prob.u0[6]+prob.u0[8]+prob.u0[9]+prob.u0[11]+prob.u0[13]+prob.u0[14]+prob.u0[16])
prob.u0[[4,5,12,13,17]].*=11.7415975/(prob.u0[4]+prob.u0[5]+prob.u0[12]+prob.u0[13]+prob.u0[17])
prob.u0[[7,8]].*=1.65364899/(prob.u0[7]+prob.u0[8])
prob.u0[[15,16]].*=1.600634/(prob.u0[15]+prob.u0[16])
prob.u0[[18,19]].*=31.332181/(prob.u0[18]+prob.u0[19])
return prob
end
The error occurs with this code block:
begin
ensemble_prob = EnsembleProblem(prob,prob_func=prob_func)
ensemble_sol = solve(ensemble_prob,Tsit5(),trajectories=5)
end
Oh, sorry, the example I wrote had a mistake. It should be rand(length(u0))
instead of size(u0)
.
Also, your conditions overlap, e.g. the index 16
appears twice. In that case, you need to do a proper projection onto the affine linear subspace of points which satisfy your conditions.
Ah I see. For the sake of simplicity and since I am still relatively new to Julia, I’ve gone ahead and removed the repeating conditions:
function prob_func(prob,i,repeat)
@. prob.u0 = rand(length(prob.u0))
prob.u0[[3,5,8,11,13,16,19]].*=0.0
prob.u0[[1,6,9,14]].*=23.0894161/(prob.u0[1]+prob.u0[6]+prob.u0[9]+prob.u0[14])
prob.u0[[4,12,17]].*=11.7415975/(prob.u0[4]+prob.u0[12]+prob.u0[17])
prob.u0[[7]].*=1.65364899/(prob.u0[7])
prob.u0[[15]].*=1.600634/(prob.u0[15])
prob.u0[[18]].*=31.332181/(prob.u0[18])
return prob
end
However, I am being met with this error:
TaskFailedException
nested task error: MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type Float64
Closest candidates are:
convert(::Type{T}, !Matched::Unitful.Gain) where T<:Real at C:\Users\Dragolonth\.julia\packages\Unitful\SUQzL\src\logarithm.jl:62
convert(::Type{T}, !Matched::Unitful.Level) where T<:Real at C:\Users\Dragolonth\.julia\packages\Unitful\SUQzL\src\logarithm.jl:22
convert(::Type{T}, !Matched::Unitful.Quantity) where T<:Real at C:\Users\Dragolonth\.julia\packages\Unitful\SUQzL\src\conversion.jl:145
...
Stacktrace:
[1] setindex!(A::Vector{Float64}, x::Vector{Float64}, i1::Int64)
@ Base .\array.jl:903
[2] macro expansion
@ .\broadcast.jl:961 [inlined]
[3] macro expansion
@ .\simdloop.jl:77 [inlined]
[4] copyto!
@ .\broadcast.jl:960 [inlined]
[5] copyto!
@ .\broadcast.jl:913 [inlined]
[6] materialize!
@ .\broadcast.jl:871 [inlined]
[7] materialize!
@ .\broadcast.jl:868 [inlined]
[8] prob_func(prob::ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, i::Int64, repeat::Int64)
@ Main.workspace#79 C:\Users\Dragolonth\Downloads\Pluto\Pluto\ensemble.jl#==#035d6a40-a7e5-4884-8409-8b11ebde32c4:3
[9] batch_func(i::Int64, prob::EnsembleProblem{ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, typeof(Main.workspace#79.prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, alg::Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ SciMLBase C:\Users\Dragolonth\.julia\packages\SciMLBase\QzHjf\src\ensemble\basic_ensemble_solve.jl:90
[10] batch_func
@ C:\Users\Dragolonth\.julia\packages\SciMLBase\QzHjf\src\ensemble\basic_ensemble_solve.jl:88 [inlined]
[11] #507
@ C:\Users\Dragolonth\.julia\packages\SciMLBase\QzHjf\src\ensemble\basic_ensemble_solve.jl:165 [inlined]
[12] macro expansion
@ C:\Users\Dragolonth\.julia\packages\SciMLBase\QzHjf\src\ensemble\basic_ensemble_solve.jl:174 [inlined]
[13] (::SciMLBase.var"#400#threadsfor_fun#510"{SciMLBase.var"#507#509"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, EnsembleProblem{ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, typeof(Main.workspace#79.prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, Tuple{UnitRange{Int64}}, Vector{ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.DEStats}}, UnitRange{Int64}})(onethread::Bool)
@ SciMLBase .\threadingconstructs.jl:85
[14] (::SciMLBase.var"#400#threadsfor_fun#510"{SciMLBase.var"#507#509"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, EnsembleProblem{ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, typeof(Main.workspace#79.prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, Tuple{UnitRange{Int64}}, Vector{ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, OrdinaryDiffEq.Tsit5ConstantCache{Float64, Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.DEStats}}, UnitRange{Int64}})()
@ SciMLBase .\threadingconstructs.jl:52
wait@task.jl:334[inlined]
threading_run(::Function)@threadingconstructs.jl:38
macro expansion@threadingconstructs.jl:97[inlined]
tmap(::Function, ::UnitRange{Int64})@basic_ensemble_solve.jl:173
#solve_batch#505@basic_ensemble_solve.jl:164[inlined]
solve_batch@basic_ensemble_solve.jl:153[inlined]
macro expansion@timing.jl:299[inlined]
var"#__solve#497"(::Int64, ::Int64, ::Int64, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(SciMLBase.__solve), ::EnsembleProblem{ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, ODEFunction{true, ModelingToolkit.var"#f#462"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xc8e5bd33, 0x169f5997, 0xb99f61bd, 0xbd8f45a8, 0x63492ad5)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xb1af606a, 0x8ae47fed, 0xa4e55d1e, 0xe655d836, 0x341fd9ac)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, ModelingToolkit.var"#487#generated_observed#469"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, typeof(Main.workspace#79.prob_func), typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, ::Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, ::EnsembleThreads)@basic_ensemble_solve.jl:56
#__solve#496@basic_ensemble_solve.jl:36[inlined]
#solve#35@solve.jl:799[inlined]
top-level scope@Local: 3[inlined]
Would you happen to know how to resolve this issue? Also, thank you so much for your help thus far!
Does prob.u0 .= rand(length(prob.u0))
fix it/ (Sorry I didn’t execute the full code on my computer yet.)
It seems that the issue persists even after the change