You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using GlobalSensitivity, Statistics, OrdinaryDiffEq, QuasiMonteCarlo
functionf(du,u,p,t)
du[1] = p[1]*u[1] - p[2]*u[1]*u[2] #prey
du[2] =-p[3]*u[2] + p[4]*u[1]*u[2] #predatorend
u0 = [1.0;1.0]
tspan = (0.0,10.0)
p = [1.5,1.0,3.0,1.0]
prob =ODEProblem(f,u0,tspan,p)
t =collect(range(0, stop=10, length=200))
f1 =function(p)
prob1 =remake(prob;p=p)
sol =solve(prob1,Tsit5();saveat=t)
[mean(sol[1,:])]
end
m =gsa(f1,Morris(total_num_trajectory=1000,num_trajectory=150),[[1,5],[1,5],[1,5],[1,5]]
The example works fine if we change the range of some parameters to consist of a single point (e.g. [[1,5],[1,1],[1,1],[1,5]] for the second and third parameters), but raises an error if we do that for the first parameter:
julia> m =gsa(f1,Morris(total_num_trajectory=1000,num_trajectory=150),[[1,1],[1,5],[1,5],[1,5]])
ERROR: BoundsError: attempt to access 0-element Vector{Vector{Float64}} at index [1]
Stacktrace:
[1] getindex(A::Vector{Vector{Float64}}, i1::Int64)
@ Base ./essentials.jl:13
[2] gsa(f::var"#9#10", method::Morris, p_range::Vector{Vector{…}}; batch::Bool, rng::Random.TaskLocalRNG, kwargs::@Kwargs{})
@ GlobalSensitivity ~/.julia/packages/GlobalSensitivity/SJGNh/src/morris_sensitivity.jl:213
[3] gsa(f::Function, method::Morris, p_range::Vector{Vector{Int64}})
@ GlobalSensitivity ~/.julia/packages/GlobalSensitivity/SJGNh/src/morris_sensitivity.jl:135
[4] top-level scope
@ REPL[2]:1
Some type information was truncated. Use `show(err)` to see complete types.
The text was updated successfully, but these errors were encountered:
Let's consider the example for using Morris method in the tutorial :
The example works fine if we change the range of some parameters to consist of a single point (e.g.
[[1,5],[1,1],[1,1],[1,5]]
for the second and third parameters), but raises an error if we do that for the first parameter:The text was updated successfully, but these errors were encountered: