Skip to content

Commit

Permalink
add correct parsing of priors (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas authored Jul 14, 2023
1 parent 38bd2ff commit 6532fab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions src/SimulationService.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ end
# Things that extract info from AMR JSON
# joshday: should all of these be moved into OperationRequest?

# priors
function amr_get(obj::Config, ::Val{:priors})
error("TODO: amr_get for :priors")
end

# Get `ModelingToolkit.ODESystem` from AMR
function amr_get(obj::Config, ::Type{ODESystem})
model = obj.model
Expand Down Expand Up @@ -177,6 +172,23 @@ function amr_get(obj::Config, ::Type{ODESystem})
structural_simplify(ODESystem(eqs, t, allfuncs, paramvars; defaults = [statefuncs .=> initial_vals; sym_defs], name=Symbol(obj.name)))
end

# priors
function amr_get(obj::Config, sys::ODESystem, ::Val{:priors})
paramlist = parameters(sys)
namelist = nameof.(paramlist)

map(amr.semantics.ode.parameters) do p
@assert p.distribution.type === "StandardUniform1"
dist = Uniform(p.distribution.parameters.minimum, p.distribution.parameters.maximum)
paramlist[findfirst(x->x==Symbol(p.id),namelist)] => dist
end
end

# data
function amr_get(obj::Config, ::Val{:data})
error("TODO: amr_get for :data")
end

#-----------------------------------------------------------------------------# job endpoints
get_job(id::String) = JobSchedulers.job_query(jobhash(id))

Expand Down
2 changes: 1 addition & 1 deletion src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ end

function Calibrate(o::OperationRequest)
sys = amr_get(o.model, ODESystem)
priors = amr_get(o.model, Val(:priors))
priors = amr_get(o.model, sys, Val(:priors))
data = o.df
Calibrate(sys, o.timespan, priors, data)
end
Expand Down

0 comments on commit 6532fab

Please sign in to comment.