GSA with the Sobol method for steady-state solution error

I perform GSA with the Sobol method for a system of ODEs for steady-state but I get the following error:

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}, ::VectorizationBase.AbstractSIMD) where T<:Union{Bool, Float16, Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8, SIMDTypes.Bit}

Here is the function I use for the Sobol method:

# GSA using chunks
ensemble_chunked = function (p)
    global parameterset = p
  
    Np::Int64 = size(p,2)
  
    println("Running ", Np, " cases.")
  
    chunksize::Int64 = Np/chunks
  
    println("Using ", chunks, " chunk(s) of size ", chunksize, ".")
  
  
    out = zeros(10,Np)
  
    for k in 1:chunks
        offset = Int((k - 1) * Np/chunks)
        startindx = Int(offset + 1)
        endindx = Int(k * Np/chunks)
  
        println("Starting chunk ", k, ", from ", startindx, " to ", endindx, " with offset ", offset, ".")
  
        pchunk = p[:,startindx:endindx]
  

        function prob_func(prob,i,repeat)
            # p[:,i] is the ith set of parameters

            p_pop = deepcopy(param);
            p_pop[param_names] = pchunk[:,i];
            remake(prob_ss;p=collect(p_pop))
        end
        
  
        ensemble_prob = EnsembleProblem(prob_ss,prob_func=prob_func)
  
        @time "    ODE Ensemble solved in " sol_ss = solve(ensemble_prob, alg=DynamicSS(AutoTsit5(Rosenbrock23(autodiff=false))), EnsembleThreads();trajectories=chunksize)
  
        @time "    Results processed in " Threads.@threads for i in 1:chunksize
            out[1,i+offset] =   sol_ss[63] + sol_ss[68] + sol_ss[69];   
            out[2,i+offset] =   sol_ss[65] + sol_ss[66] + sol_ss[69];   
            out[3,i+offset] =   sol_ss[67] + sol_ss[68];   
            out[4,i+offset] =   sol_ss[42];   
            out[5,i+offset] =   sol_ss[14] + sol_ss[18];  
            out[6,i+offset] =   sol_ss[30] + sol_ss[60];  
            out[7,i+offset] =   sol_ss[25];  
            out[8,i+offset] =   sol_ss[72];  
            out[9,i+offset] =   sol_ss[3];  
            out[10,i+offset] =  sol_ss[31];  

        end
    end
    out
end

What line is it pointing to? You dropped the stack trace.

My bad. Here is the stack track

Closest candidates are:
convert(::Type{T}, ::VectorizationBase.AbstractSIMD) where T<:Union{Bool, Float16, Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8, SIMDTypes.Bit}
@ VectorizationBase C:\Users\memmo.julia\packages\VectorizationBase\LqJbS\src\base_defs.jl:201
convert(::Type{T}, ::VectorizationBase.LazyMulAdd{M, O, I}) where {M, O, I, T<:Number}
@ VectorizationBase C:\Users\memmo.julia\packages\VectorizationBase\LqJbS\src\lazymul.jl:25
convert(::Type{T}, ::Union{Static.StaticBool{N}, Static.StaticFloat64{N}, Static.StaticInt{N}} where N) where T<:Number
@ Static C:\Users\memmo.julia\packages\Static\1Mvph\src\Static.jl:427

Stacktrace:
 [1] setindex!
   @ .\array.jl:1024 [inlined]
 [2] macro expansion
   @ c:\Users\memmo\Desktop\papers \parameter estimation\msi\steady state\sobol_experimental.jl:199 [inlined]
 [3] (::var"#23#threadsfor_fun#15"{var"#23#threadsfor_fun#12#16"{…}})(tid::Int64; onethread::Bool)
   @ Main .\threadingconstructs.jl:215
 [4] #23#threadsfor_fun
   @ .\threadingconstructs.jl:182 [inlined]
 [5] (::Base.Threads.var"#1#2"{var"#23#threadsfor_fun#15"{var"#23#threadsfor_fun#12#16"{…}}, Int64})()
   @ Base.Threads .\threadingconstructs.jl:154

Stacktrace:
[1] threading_run(fun::var"#23#threadsfor_fun#15"{var"#23#threadsfor_fun#12#16"{…}}, static::Bool)
@ Base.Threads .\threadingconstructs.jl:172
[2] macro expansion
@ .\threadingconstructs.jl:220 [inlined]
[3] macro expansion
@ .\timing.jl:279 [inlined]
[4] (::var"#11#13")(p::Matrix{Float64})
@ Main c:\Users\memmo\Desktop\papers \parameter estimation\msi\steady state\sobol_experimental.jl:198
[5] gsa(f::var"#11#13", method::Sobol, A::Matrix{…}, B::Matrix{…}; batch::Bool, Ei_estimator::Symbol, distributed::Val{…}, kwargs::@Kwargs{})
@ GlobalSensitivity C:\Users\memmo.julia\packages\GlobalSensitivity\fxoe7\src\sobol_sensitivity.jl:138
[6] top-level scope
@ c:\Users\memmo\Desktop\papers\parameter estimation\msi\steady state\sobol_experimental.jl:216

I think it points to this line:

out[1,i+offset] =   sol_ss[63] + sol_ss[68] + sol_ss[69];

Is it possibly related to the form of the output when I use a steady-state solver?

If you’re using an ensemble problem, then sol_ss is an EnsembleSolution. This means that sol_ss[63] (which should be updated to the form sol_ss.u[63], you should be seeing a deprecation warning) is the 63rd solution. If you have a vector-valued nonlinear problem (system of equations), then sol_ss.u[63] is a vector. out[1,i+offset] is presumably looking for a float, so that is your issue then.

I think what you really mean then is:

out[1,i+offset] =   sol_ss.u[i][63] + sol_ss.u[i][68] + sol_ss.u[i][69]; 

You are right! Thanks!