Example models
The package comes with ready-made problems to try things on. They live in a submodule, ODEParameterEstimation.Examples. Each is a function that returns a ParameterEstimationProblem with true values and no data, so the usual pattern is:
using ODEParameterEstimation
using ODEParameterEstimation.Examples
problem = sample_problem_data(lotka_volterra(); datasize = 101)
results = estimate(problem)Every model carries a time interval that suits it, and sample_problem_data uses it unless you pass time_interval yourself.
using ODEParameterEstimation
using ODEParameterEstimation.Examples
function describe(group)
println(rpad("model", 32), "states parameters measured interval")
for name in example_models(group)
problem = example_problem(name)
println(rpad(name, 32), rpad(length(problem.ic), 8), rpad(length(problem.p_true), 12),
rpad(length(problem.measured_quantities), 10), problem.recommended_time_interval)
end
endLooking inside one
A problem carries its ModelingToolkit system, its measured quantities and its true values:
using ModelingToolkit
problem = lotka_volterra()
equations(problem.model.system)2-element Vector{Symbolics.Equation}:
Differential(t, 1)(r(t)) ~ k1*r(t) - k2*r(t)*w(t)
Differential(t, 1)(w(t)) ~ -k3*w(t) + k2*r(t)*w(t)problem.measured_quantities1-element Vector{Symbolics.Equation}:
y1(t) ~ r(t)problem.p_trueOrderedCollections.OrderedDict{Symbolics.Num, Float64} with 3 entries:
k1 => 1.0
k2 => 0.5
k3 => 0.3First steps
Small models that are solved quickly and accurately.
describe(:first_steps)model states parameters measured interval
harmonic_oscillator 2 2 2 [0.0, 10.0]
oscillator_mixed_outputs 2 2 2 [0.0, 10.0]
exponential_decay 1 1 1 [0.0, 10.0]
decay_cubed_output 1 1 1 [0.0, 10.0]
forced_decay 1 2 1 [0.0, 10.0]
lotka_volterra 2 3 1 [0.0, 20.0]
vanderpol 2 2 2 [0.0, 10.0]
brusselator 2 2 2 [0.0, 20.0]
daisy_mamil3 3 5 2 [0.0, 10.0]
repressilator 6 3 3 [0.0, 24.0]ODEParameterEstimation.Examples.brusselator — Method
brusselator()The Brusselator, a two-species chemical oscillator with a cubic term, with both concentrations measured.
ODEParameterEstimation.Examples.daisy_mamil3 — Method
daisy_mamil3()A linear three-compartment model with five exchange rates, a standard identifiability benchmark. Two of the three compartments are measured.
All five rates and the unmeasured initial amount are recovered.
ODEParameterEstimation.Examples.decay_cubed_output — Method
decay_cubed_output()The decay of exponential_decay, measured through its cube: the measured quantity is x1^3. A measured quantity may be any rational function of the states and parameters.
ODEParameterEstimation.Examples.exponential_decay — Method
exponential_decay()One state that decays, x1' = -a x1, measured directly. The simplest model there is: one parameter and one initial condition.
ODEParameterEstimation.Examples.forced_decay — Method
forced_decay()A decaying state pushed by a known sinusoid, x' = -a x + b sin(0.5 t), measured directly. The smallest model with an input that depends on time. See Inputs that depend on time.
ODEParameterEstimation.Examples.harmonic_oscillator — Method
harmonic_oscillator()Two states that drive each other, x1' = -a x2 and x2' = b x1, both measured. The smallest model with two parameters.
Both parameters and both initial conditions are recovered.
ODEParameterEstimation.Examples.lotka_volterra — Method
lotka_volterra()The Lotka–Volterra predator-prey model with three rates. Only the prey r is measured.
The three rates and the unmeasured initial number of predators are recovered.
ODEParameterEstimation.Examples.oscillator_mixed_outputs — Method
oscillator_mixed_outputs()The equations of harmonic_oscillator, with neither state measured on its own: the two measured quantities are 2 x1 + 0.5 x2 and 3 x1 - 0.25 x2.
Everything is still recovered.
ODEParameterEstimation.Examples.repressilator — Method
repressilator()A ring of three genes, each repressing the next, with saturating repression terms of the form beta / (1 + n p). The three proteins are measured and the three mRNA levels are not.
A model with parameters in denominators. It takes several minutes with the default options.
ODEParameterEstimation.Examples.vanderpol — Method
vanderpol()The van der Pol oscillator, x1' = a x2 and x2' = -x1 - b (x1^2 - 1) x2, with both states measured.
Something cannot be determined
In each of these the measured quantities leave at least one parameter or initial condition open. See More than one answer.
describe(:cannot_be_determined)model states parameters measured interval
sum_of_rates 1 2 1 [0.0, 10.0]
partly_observed_chain 3 4 2 [0.0, 10.0]
hidden_scale 3 3 1 [0.0, 10.0]
treatment 4 5 2 [0.0, 40.0]
two_compartment_pk 2 5 1 [0.0, 48.0]
mass_spring_damper 2 4 1 [0.0, 10.0]hidden_scale()Two unmeasured states feed a third, x3' = c (x1 + x2), and only x3 is measured. Scaling x1 and x2 up and c down by the same factor changes nothing that is measured.
The rates a and b and x3(0) are determined. c, x1(0) and x2(0) are reported as undetermined. Two results are returned, one for each way of assigning the two rates to the two hidden states.
ODEParameterEstimation.Examples.mass_spring_damper — Method
mass_spring_damper()A mass on a spring with a damper, pushed by a constant unknown force: m x'' + c x' + k x = F. The position is measured.
Dividing the equation by m shows that only the ratios c/m, k/m and F/m matter. All four parameters are reported as undetermined, and the initial position and velocity are recovered.
ODEParameterEstimation.Examples.partly_observed_chain — Method
partly_observed_chain()Three states, two of them measured. x2 grows at the rate b + c, so only that sum is determined, and x3 is neither measured nor felt by anything that is, so d and its initial value are open.
a and the two measured initial conditions are recovered. b, c, d and x3(0) are reported as undetermined.
ODEParameterEstimation.Examples.sum_of_rates — Method
sum_of_rates()Growth at the rate a + b: x1' = (a + b) x1, with x1 measured. Only the sum can be determined, so a and b are both reported as undetermined. The smallest example of that.
ODEParameterEstimation.Examples.treatment — Method
treatment()An epidemic model with treatment: susceptible S, infected In, treated Tr and the constant population N. Only the treated and the population size are measured.
Most of the model is left open by those two measurements: a, b, d, g, In(0) and S(0) are reported as undetermined, and nu is recovered. It takes a long time with the default options.
ODEParameterEstimation.Examples.two_compartment_pk — Method
two_compartment_pk()A drug that moves between a central and a peripheral compartment and is eliminated from the central one. Only the central concentration is measured.
One concentration curve cannot separate the five parameters: all of them and the peripheral initial concentration are reported as undetermined. Only the central initial concentration is recovered.
Several answers
Two models in which several sets of values fit the data equally well, each beside a version that is measured fully enough to have one answer.
describe(:several_answers)model states parameters measured interval
hidden_subpopulations 5 6 3 [0.0, 12.0]
hidden_subpopulations_measured 5 6 5 [0.0, 12.0]
receptor_subtypes 3 6 2 [0.0, 8.0]
receptor_subtypes_measured 3 6 3 [0.0, 8.0]hidden_subpopulations()An epidemic in which the infected fall into three groups, each with its own infection rate b and recovery rate a. The susceptible, the recovered and the total number infected are measured, so the three groups are never seen apart.
Nothing in the data says which group is which. There are six answers, one for each ordering of the three groups, and all six fit equally well. Compare hidden_subpopulations_measured. It takes a long time with the default options.
hidden_subpopulations_measured()The model of hidden_subpopulations with each of the three infected groups measured on its own. There is one answer.
ODEParameterEstimation.Examples.receptor_subtypes — Method
receptor_subtypes()A ligand L that binds two receptor subtypes, each with its own amount and its own binding and release rates. The free ligand and the total amount bound are measured.
The two subtypes can be exchanged, so there are two answers. Compare receptor_subtypes_measured.
ODEParameterEstimation.Examples.receptor_subtypes_measured — Method
receptor_subtypes_measured()The model of receptor_subtypes with the amount bound to each subtype measured on its own. There is one answer, and it is found quickly.
Larger models
Most of these are benchmarks from the identifiability literature. They take longer, some of them minutes, and two are beyond what the package solves in reasonable time at present. Their descriptions say which.
describe(:larger_models)model states parameters measured interval
crauste 5 13 4 [0.0, 25.0]
daisy_ex3 4 5 2 [0.0, 10.0]
daisy_mamil4 4 7 3 [0.0, 10.0]
fitzhugh_nagumo 2 3 1 [0.0, 10.0]
hiv 5 10 4 [0.0, 25.0]
biohydrogenation 4 6 2 [0.0, 36.0]
seir 4 3 2 [0.0, 60.0]
sirsforced 5 6 2 [0.0, 30.0]
slowfast 6 2 4 [0.0, 10.0]
allee_competition 2 8 2 [0.0, 10.0]ODEParameterEstimation.Examples.allee_competition — Method
allee_competition()Two competing species, each with logistic growth and an Allee threshold below which it declines. Both populations are measured. Eight parameters, with the carrying capacities in denominators.
There are four answers that fit the data equally well.
ODEParameterEstimation.Examples.biohydrogenation — Method
biohydrogenation()A chain of three reactions with saturating rates of the form k x / (K + x). The first two of the four concentrations are measured.
The final product x7 affects nothing that is measured, so x7(0) is reported as undetermined. There are two answers for the rest. It takes several minutes with the default options.
ODEParameterEstimation.Examples.crauste — Method
crauste()The Crauste model of the CD8 T-cell response to infection: naive cells N, early and late effector cells E and L, memory cells M and the pathogen P, with thirteen rates. N, E, P and the sum L + M are measured.
ODEParameterEstimation.Examples.daisy_ex3 — Method
daisy_ex3()A linear three-state model driven by a ramp input u0, from the examples of the DAISY identifiability software. x1 and the input are measured.
There are two answers. It takes several minutes with the default options.
ODEParameterEstimation.Examples.daisy_mamil4 — Method
daisy_mamil4()A linear four-compartment model with seven exchange rates. x1, x2 and the sum x3 + x4 are measured.
Compartments 3 and 4 are seen only together and can be exchanged, so there are two answers.
ODEParameterEstimation.Examples.fitzhugh_nagumo — Method
fitzhugh_nagumo()The FitzHugh–Nagumo model of a nerve cell: a fast voltage V with a cubic term and a slow recovery variable R. Only the voltage is measured.
The three parameters and the unmeasured R(0) are recovered.
ODEParameterEstimation.Examples.hiv — Method
hiv()A model of HIV infection and the immune response to it: uninfected cells x, infected cells y, virus v, and immune cells w and z, with ten rates. Four quantities are measured, one of them the sum y + v.
The values span eight orders of magnitude, from 2e-5 to 1000. The package rescales the problem internally (auto_rescale). It takes several minutes with the default options.
ODEParameterEstimation.Examples.seir — Method
seir()The SEIR epidemic model: susceptible S, exposed E, infected In and the constant population N. The infected and the population size are measured.
There are two answers: the data cannot tell the recovery rate a from the rate nu at which the exposed become infected. It takes several minutes with the default options.
ODEParameterEstimation.Examples.sirsforced — Method
sirsforced()An SIRS epidemic model whose infection rate varies with the seasons. The seasonal factor is produced by two extra states, x1 and x2, that form an oscillator of unknown frequency M. The infected and the recovered are measured.
ODEParameterEstimation.Examples.slowfast — Method
slowfast()A chain of two reactions, A to B to C, watched through an absorbance signal eA xA + eB xB + eC xC. The concentration of C, the signal and two of the three coefficients are measured. The coefficients are constants, written as states that do not change.
There are two answers.
Control systems
Systems driven by a known sinusoidal input. See Inputs that depend on time.
describe(:control_systems)model states parameters measured interval
dc_motor 2 2 1 [0.0, 5.0]
quadrotor_altitude 2 2 1 [0.0, 10.0]
forced_lotka_volterra 2 4 2 [0.0, 5.0]
magnetic_levitation 3 3 1 [0.0, 5.0]
aircraft_pitch 3 4 1 [0.0, 10.0]
bicycle_model 2 4 2 [0.0, 20.0]
boost_converter 2 3 2 [0.0, 0.5]
bilinear_system 2 8 2 [0.0, 15.0]ODEParameterEstimation.Examples.aircraft_pitch — Method
aircraft_pitch()The short-period pitch dynamics of an aircraft: pitch angle theta, pitch rate q and angle of attack alpha. The elevator moves as 0.05 sin(2 t) and the pitch rate is measured.
The four aerodynamic coefficients are recovered. The pitch angle itself affects nothing that is measured, so theta(0) is reported as undetermined.
ODEParameterEstimation.Examples.bicycle_model — Method
bicycle_model()The lateral dynamics of a car as a single-track ("bicycle") model: lateral velocity vy and yaw rate r, with the steering angle 0.05 sin(0.5 t). Both states are measured. The geometry and the speed are taken as known.
The tyre stiffnesses Cf and Cr enter only divided by the mass or by the yaw inertia, so only those ratios are determined. All four parameters are reported as undetermined.
ODEParameterEstimation.Examples.bilinear_system — Method
bilinear_system()A two-state system in which the input u = 1 + 0.5 sin(2 t) both adds to the states and multiplies them. Both states are measured.
All eight coefficients are recovered.
ODEParameterEstimation.Examples.boost_converter — Method
boost_converter()The averaged model of a boost converter: inductor current iL and capacitor voltage vC, with the duty cycle varying as 0.5 + 0.1 sin(100 t). Both states are measured and the input voltage is taken as known.
The inductance, capacitance and load resistance are recovered.
ODEParameterEstimation.Examples.dc_motor — Method
dc_motor()A DC motor: the armature current i produces a torque that turns the rotor at speed omega_m. The supply voltage is 12 + 2 sin(5 t) and the speed is measured. The electrical constants and the torque constant are taken as known.
The rotor inertia J and the friction coefficient b are recovered. With the torque constant unknown as well, only the ratios Kt/J and b/J could be determined.
ODEParameterEstimation.Examples.forced_lotka_volterra — Method
forced_lotka_volterra()A predator-prey model whose prey is harvested and restocked through the seasons, at the rate 0.3 sin(2 t). Both populations are measured.
All four rates are recovered.
ODEParameterEstimation.Examples.magnetic_levitation — Method
magnetic_levitation()A ball held by an electromagnet, linearised about its resting point: position x, velocity v and coil current i. The coil voltage is 5 + sin(5 t) and only the position is measured. The electrical constants are taken as known.
The effective mass, stiffness and damping are recovered.
ODEParameterEstimation.Examples.quadrotor_altitude — Method
quadrotor_altitude()The altitude z of a quadrotor with linear drag, driven by a net vertical force 2 sin(t). The altitude is measured.
The mass m and the drag coefficient d are recovered.
A model that has to be rewritten
One tank, written as it comes and written so that the package accepts it. See Rewriting a model so that it is accepted.
describe(:rewriting)model states parameters measured interval
tank_level 1 2 1 [0.0, 30.0]
tank_level_rewritten 1 2 1 [0.0, 30.0]ODEParameterEstimation.Examples.tank_level — Method
tank_level()A tank that drains through a hole in its floor. The level h falls at a rate proportional to sqrt(h), and the inflow 0.4 + 0.15 sin(0.5 t) is known. The level is measured.
sqrt(h) is not a rational function of the state, so estimate refuses this model with an UnsupportedModelClassError. tank_level_rewritten is the same tank in a form that is accepted.
ODEParameterEstimation.Examples.tank_level_rewritten — Method
tank_level_rewritten()The tank of tank_level with the state z = sqrt(h) in place of the level. Then z' = (Qin - k z) / (2 A z), which is rational, and the measured level is z^2. The data are the same.
The area A and the outflow coefficient k are recovered. A second result has z and k both negated: it gives the same level, and is the price of measuring z only through its square.
Listing them
ODEParameterEstimation.Examples — Module
ODEParameterEstimation.ExamplesReady-made problems to try the package on. Each model is a function that returns a ParameterEstimationProblem with true values and no data:
using ODEParameterEstimation
using ODEParameterEstimation.Examples
problem = sample_problem_data(lotka_volterra(); datasize = 101)
results = estimate(problem)example_models lists them and example_groups lists the groups they are sorted into.
ODEParameterEstimation.Examples.example_models — Function
example_models() -> Vector{Symbol}
example_models(group::Symbol) -> Vector{Symbol}The names of the example models, all of them or those of one group.
Example
example_models(:first_steps)ODEParameterEstimation.Examples.example_groups — Function
example_groups() -> Vector{Symbol}The groups the example models are sorted into: :first_steps, :cannot_be_determined, :several_answers, :larger_models, :control_systems and :rewriting.
ODEParameterEstimation.Examples.example_problem — Function
example_problem(name::Symbol) -> ParameterEstimationProblemThe example model called name: example_problem(:lotka_volterra) is lotka_volterra().