Skip to content

Commit

Permalink
Allow for subsets of parameters to be fit (#97)
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Day <[email protected]>
  • Loading branch information
ChrisRackauckas and joshday authored Jul 18, 2023
1 parent 11b1277 commit 972f1e7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ function amr_get(amr::JSON3.Object, ::Type{ODESystem})
push!(eqs, ofunc ~ expr)
end

structural_simplify(ODESystem(eqs, t, allfuncs, paramvars; defaults = [statefuncs .=> initial_vals; sym_defs], name=Symbol(amr.name)))
sys = structural_simplify(ODESystem(eqs, t, allfuncs, paramvars; defaults = [statefuncs .=> initial_vals; sym_defs], name=Symbol(amr.name)))
@info "amr_get(amr, ODESystem) --> $sys"

sys
end

# priors
Expand All @@ -62,9 +65,15 @@ function amr_get(amr::JSON3.Object, sys::ODESystem, ::Val{:priors})
namelist = nameof.(paramlist)

map(amr.semantics.ode.parameters) do p
@assert p.distribution.type === "StandardUniform1"
dist = EasyModelAnalysis.Distributions.Uniform(p.distribution.parameters.minimum, p.distribution.parameters.maximum)
paramlist[findfirst(x->x==Symbol(p.id),namelist)] => dist
if haskey(p, :distribution)
# Assumption: only fit parameters which have a distribution / bounds
if p.distribution.type !== "StandardUniform1"
@info "Invalid distribution type! Distribution type was $(p.distribution.type)"
end

dist = EasyModelAnalysis.Distributions.Uniform(p.distribution.parameters.minimum, p.distribution.parameters.maximum)
paramlist[findfirst(x->x==Symbol(p.id),namelist)] => dist
end
end
end

Expand Down

0 comments on commit 972f1e7

Please sign in to comment.