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
GSA assumes the output of f is a floating point number. See if changing the last line of your f to Float64[sol[1,3000], sol[2,3000], sol[3,3000], sol[4,3000]] fixes it. If that does it, we can put some automated conversions in the package to make that simpler.
GSA assumes the output of f is a floating point number. See if changing the last line of your f to Float64[sol[1,3000], sol[2,3000], sol[3,3000], sol[4,3000]] fixes it. If that does it, we can put some automated conversions in the package to make that simpler.
Yes that solved the problem. Thanks !! :)
ChrisRackauckas
changed the title
Got InexactError when running gsa on my data model
Floating point valued outputs are required: potential for automatic conversion
Sep 19, 2022
Here is my code:
using Distributions, Distances, Random, Plots
using Catalyst
using DifferentialEquations, GlobalSensitivity, QuasiMonteCarlo
stem_model = @reaction_network begin
(k0O(c0 + c1N^2 + k0O + c250))/(1 + (k0O*(c1N^2 + k0O + c250 + c3F^2)) + c4OG^2), ∅ --> N
(e0 + e1O)/(1 + e1O + e2G^2), ∅ --> O
(a0 + a1O)/(1 + a1O), ∅ --> F
(b0 + b1G^2 + b3O)/(1 + b1G^2 + b2N^2 + b3O), ∅ --> G
γ, N -->∅
γ, O -->∅
γ, F -->∅
γ, G -->∅
end k0 c0 c1 c2 c3 c4 e0 e1 e2 a0 a1 b0 b1 b2 b3 γ
p = [0.005, 0.01, 0.4, 1, 0.1, 0.00135, 0.01, 1, 1, 0.01, 1.0, 0.005, 0.005, 1.0, 1, 0.01]
T = 3000.0
u₀ = [105,110,100,5]
tspan = (0.0,T)
dprob = DiscreteProblem(stem_model, u₀, tspan, p)
jprob = JumpProblem(stem_model, dprob, Direct(),save_positions=(false,false))
function f(param)
prob1 = remake(jprob;p=param)
sol = solve(prob1, SSAStepper(), saveat=1)
[sol[1,3000], sol[2,3000], sol[3,3000], sol[4,3000]]
end
samples = 1000
lb = [0.00050, 0.00100, 0.04000, 0.10000, 0.10000, 0.00035, 0.00100, 0.10000, 0.10000, 0.00100, 0.10000, 0.00050, 0.00050, 0.10000, 0.10000, 0.00100]
ub = [0.05000, 0.02500, 1.0000, 2.0000, 0.5000, 0.00200, 0.02500, 2.00000, 2.00000, 0.02500, 2.00000, 0.05000, 0.05000, 2.00000, 2.00000, 0.02500]
sampler = SobolSample()
A,B = QuasiMonteCarlo.generate_design_matrices(samples,lb,ub,sampler)
sobol_result = gsa(f,Sobol(),A,B)
and got the error
InexactError: Int64(17.849)
Stacktrace:
[1] Int64
@ ./float.jl:812 [inlined]
[2] convert
@ ./number.jl:7 [inlined]
[3] setindex!
@ ./array.jl:903 [inlined]
[4] _unsafe_copyto!(dest::Matrix{Int64}, doffs::Int64, src::Matrix{Float64}, soffs::Int64, n::Int64)
@ Base ./array.jl:253
[5] unsafe_copyto!
@ ./array.jl:307 [inlined]
[6] _copyto_impl!
@ ./array.jl:331 [inlined]
[7] copyto!
@ ./array.jl:317 [inlined]
[8] copyto!
@ ./array.jl:343 [inlined]
[9] copyto_axcheck!(dest::Matrix{Int64}, src::Matrix{Float64})
@ Base ./abstractarray.jl:1104
[10] Array
@ ./array.jl:563 [inlined]
[11] convert
@ ./array.jl:554 [inlined]
[12] push!
@ ./array.jl:994 [inlined]
[13] gsa_sobol_all_y_analysis(method::Sobol, all_y::Matrix{Int64}, d::Int64, n::Int64, Ei_estimator::Symbol, y_size::Nothing, #unused#::Val{true})
@ GlobalSensitivity ~/.julia/packages/GlobalSensitivity/t3hIm/src/sobol_sensitivity.jl:99
[14] gsa(f::typeof(f), method::Sobol, A::Matrix{Float64}, B::Matrix{Float64}; batch::Bool, Ei_estimator::Symbol, distributed::Val{false}, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ GlobalSensitivity ~/.julia/packages/GlobalSensitivity/t3hIm/src/sobol_sensitivity.jl:63
[15] gsa(f::Function, method::Sobol, A::Matrix{Float64}, B::Matrix{Float64})
@ GlobalSensitivity ~/.julia/packages/GlobalSensitivity/t3hIm/src/sobol_sensitivity.jl:28
[16] top-level scope
@ In[44]:29
[17] eval
@ ./boot.jl:373 [inlined]
[18] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
The text was updated successfully, but these errors were encountered: