Hi @ChrisRackauckas,
If I want to add a delay function (DDE) using SDDEProblem. Can it work on same algorithm just adding the h value?
I try to do it, and got this error
TaskFailedException:
MethodError: no method matching make_function(::SDDEProblem{Array{Float64,1},Tuple{Float64,Float64},Tuple{},Tuple{},true,var"#11#12"{NamedTuple{(:θ, :Ω),Tuple{Array{Float64,1},Array{Float64,2}}},NamedTuple{(:η,),Tuple{Array{Float64,1}}}},Nothing,SDDEFunction{true,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},Nothing}, ::Pumas.DiffEqWrapper{typeof(f),Array{Float64,1}})
Closest candidates are:
make_function(!Matched::ODEProblem, ::Any) at /Users/mjaber/.juliapro/JuliaPro_v1.4.2-1/packages/Pumas/Kxgzs/src/simulate_methods/diffeqs.jl:58
make_function(!Matched::DDEProblem, ::Any) at /Users/mjaber/.juliapro/JuliaPro_v1.4.2-1/packages/Pumas/Kxgzs/src/simulate_methods/diffeqs.jl:59
make_function(!Matched::DiscreteProblem, ::Any) at /Users/mjaber/.juliapro/JuliaPro_v1.4.2-1/packages/Pumas/Kxgzs/src/simulate_methods/diffeqs.jl:60
...
Stacktrace:
[1] _build_diffeq_problem(::PumasModel{ParamSet{NamedTuple{(:θ, :Ω),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PSDDomain{Array{Float64,2}}}}},typeof(randomfx),typeof(pre_f),var"#13#14",SDDEProblem{Array{Float64,1},Tuple{Float64,Float64},Tuple{},Tuple{},true,var"#11#12"{NamedTuple{(:θ, :Ω),Tuple{Array{Float64,1},Array{Float64,2}}},NamedTuple{(:η,),Tuple{Array{Float64,1}}}},Nothing,SDDEFunction{true,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},Nothing},typeof(derived_f),Pumas.var"#114#115"}, ::Subject{Nothing,Nothing,Array{Pumas.Event,1},Nothing,Pumas.var"#10#11",StaticArrays.SArray{Tuple{1},Float64,1,1}}; saveat::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, save_discont::Bool, continuity::Symbol, callback::Nothing, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}}) at /Users/mjaber/.juliapro/JuliaPro_v1.4.2-1/packages/Pumas/Kxgzs/src/simulate_methods/diffeqs.jl:32
[2] _problem(::PumasModel{ParamSet{NamedTuple{(:θ, :Ω),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PSDDomain{Array{Float64,2}}}}},typeof(randomfx),typeof(pre_f),var"#13#14",SDDEProblem{Nothing,Tuple{Nothing,Nothing},Tuple{},Tuple{},true,DiffEqBase.NullParameters,Nothing,SDDEFunction{true,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},Nothing},typeof(derived_f),Pumas.var"#114#115"}, ::Subject{Nothing,Nothing,Array{Pumas.Event,1},Nothing,Pumas.var"#10#11",StaticArrays.SArray{Tuple{1},Float64,1,1}}, ::var"#11#12"{NamedTuple{(:θ, :Ω),Tuple{Array{Float64,1},Array{Float64,2}}},NamedTuple{(:η,),Tuple{Array{Float64,1}}}}; tspan::Nothing, saveat::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, kwargs::Base.Iterators.Pairs{Symbol,Nothing,Tuple{Symbol},NamedTuple{(:callback,),Tuple{Nothing}}}) at /Users/mjaber/.juliapro/JuliaPro_v1.4.2-1/packages/Pumas/Kxgzs/src/models/model_api.jl:146
[3] (::Pumas.var"#simobs_prob_func#131"{Nothing,Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},PumasModel{ParamSet{NamedTuple{(:θ, :Ω),Tuple{VectorDomain{Array{Float64,1},Array{TransformVariables.Infinity{true},1},Array{Float64,1}},PSDDomain{Array{Float64,2}}}}},typeof(randomfx),typeof(pre_f),var"#13#14",SDDEProblem{Nothing,Tuple{Nothing,Nothing},Tuple{},Tuple{},true,DiffEqBase.NullParameters,Nothing,SDDEFunction{true,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},Nothing},typeof(derived_f),Pumas.var"#114#115"},Array{Subject{Nothing,Nothing,Array{Pumas.Event,1},Nothing,Pumas.var"#10#11",StaticArrays.SArray{Tuple{1},Float64,1,1}},1},NamedTuple{(:θ, :Ω),Tuple{Array{Float64,1},Array{Float64,2}}},Nothing,Tuple{}})(::SDDEProblem{Nothing,Tuple{Nothing,Nothing},Tuple{},Tuple{},true,DiffEqBase.NullParameters,Nothing,SDDEFunction{true,typeof(f),typeof(g),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(g),typeof(h),Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},Nothing}, ::Int64, ::Int64) at /Users/mjaber/.juliapro/JuliaPro_v1.4.2-1/packages/Pumas/Kxgzs/src/models/model_api.jl:261
[4] macro expansion at /Users/mjaber/.juliapro/JuliaPro_v1.4.2-1/packages/DiffEqBase/XoVg5/src/ensemble/basic_ensemble_solve.jl:162 [inlined]
[5]..
My model is
using Pumas, DifferentialEquations
p = ParamSet((θ = VectorDomain(5, lower = zeros(4)),
Ω = PSDDomain(3)))
function randomfx(p)
ParamSet((η=MvNormal(p.Ω),))
end
function pre_f(params, randoms, subj)
function (t)
θ = params.θ
η = randoms.η
(
Ka = θ[1],
K2 = θ[2],
CL = θ[3]*exp(η[1]),
Vd = θ[4]*exp(η[2]),
τ = θ[5]*exp(η[3])
)
end
end
# define the stochastic equations here
function f(du, u, p,h, t)
depot1, depot2, central = u
hist = h(u, t-p.τ)[1]
du[1] = p.Ka * hist
du[2] = p.K2 * depot2
du[3] = (p.Ka*depot1 + p.K2*depot2) - (p.CL/p.Vd)*central
end
function g(du, u, p, t)
du[1] = 0.4*u[1]
du[2] = 0.0
du[3] = 0.5*u[3]
end
h(p, t) = [1.0, 0.0, 0.0]
prob = SDDEProblem(f, g, nothing, h, nothing)
init_f = (t, c) -> [0.0, 0.0, 0.0]
function derived_f(c, sol, obstimes, subj,param, randeffs)
Vs = getfield.(c.(obstimes),:Vd)
central = sol(obstimes; idxs=3)
conc = @. central/Vs
(conc=conc, )
end
stoch_model = Pumas.PumasModel(p, randomfx, pre_f, init_f, prob, derived_f)
pop = Population([Subject(evs= DosageRegimen(10, time = 0)) for i in 1:5])
param = (θ = [
0.3,
0.2,
1.3,
64.7,
0.9,
],
Ω = [1.0 0.0 0.0 ; 0.0 1.0 0.0; 0.0 0.0 1.0])
###
obs = simobs(stoch_model, pop, param, alg=SOSRI())