build_run
Stable function · Building and running
Tier: stable · Kind: function · Topic: Building and running
| Julia | Rust |
|---|---|
build_run | not exported |
Julia
build_run(config::AbstractDict; tspan, saveat, prob, p, u0)
build_run(config; tspan, saveat=nothing, prob=toy_problem(config["model"]), p=prob.p, u0=prob.u0) -> Run
Build a run from a run config (a parsed JSON object). tspan and saveat
come from the conformance case (spec/toy-problems.md §2). Raises
UnsupportedError
for constructs not implemented in this stage, and
ConfigError
for invalid ones.
Example (forward)
run = build_run(config; tspan = (0.0, 2.0))
forward!(run)
u_final = run.outputs[end][2]
# Exact solution of u' = -k u + sin(ωt), u(0) = 1.
k, ω = prob.p
A(t) = (k * sin(ω * t) - ω * cos(ω * t)) / (k^2 + ω^2)
u_exact = (1 - A(0)) * exp(-k * 2) + A(2)
@test isapprox(only(u_final), u_exact; rtol = 1e-4)
From docs/api/examples/julia/forward_and_gradient.jl
Example (refusal)
bad = deepcopy(config)
bad["schedule"]["alg"] = "Bogus"
@test_throws ConfigError build_run(bad; tspan = (0.0, 2.0))
Rust
Rust does not export this function.