Skip to content

Commit 94a8de5

Browse files
committed
change code
1 parent 2510dda commit 94a8de5

File tree

1 file changed

+65
-51
lines changed

1 file changed

+65
-51
lines changed

docs/src/tutorials/parameter_identifiability.md

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ y_2 = x_5\end{cases}$$
2929
This model describes the biohydrogenation[^1] process[^2] with unknown initial conditions.
3030

3131
### Using the `ODESystem` object
32-
To define the system in Julia, we use `ModelingToolkit.jl`.
32+
To define the ode system in Julia, we use `ModelingToolkit.jl`.
3333

34-
We first define the parameters, variables, differential equations and the output equations. Notice that the system does not have any input functions, so inputs will be an empty array.
35-
36-
```@example
34+
We first define the parameters, variables, differential equations and the output equations.
35+
```julia
3736
using StructuralIdentifiability, ModelingToolkit
3837

3938
# define parameters and variables
40-
@variables t x4(t) x5(t) x6(t) x7(t) y1(t) y2(t)
39+
@variables t x4(t) x5(t) x6(t) x7(t) y1(t) [output=true] y2(t) [output=true]
4140
@parameters k5 k6 k7 k8 k9 k10
4241
D = Differential(t)
4342

@@ -46,32 +45,45 @@ eqs = [
4645
D(x4) ~ - k5 * x4 / (k6 + x4),
4746
D(x5) ~ k5 * x4 / (k6 + x4) - k7 * x5/(k8 + x5 + x6),
4847
D(x6) ~ k7 * x5 / (k8 + x5 + x6) - k9 * x6 * (k10 - x6) / k10,
49-
D(x7) ~ k9 * x6 * (k10 - x6) / k10
50-
]
51-
52-
# define observed functions
53-
observed = [
48+
D(x7) ~ k9 * x6 * (k10 - x6) / k10,
5449
y1 ~ x4,
5550
y2 ~ x5
5651
]
5752

5853
# define the system
59-
de = ODESystem(eqs, t, [x4, x5, x6, x7], [k5, k6, k7, k8, k9, k10], observed=observed, name=:Biohydrogenation)
60-
61-
# no input functions:
62-
inputs = []
54+
de = ODESystem(eqs, t, name=:Biohydrogenation)
6355

64-
# we want to check everything
65-
to_check = []
56+
```
6657

58+
After that we are ready to check the system for local identifiability:
59+
```julia
6760
# query local identifiability
6861
# we pass the ode-system
69-
local_id_all = assess_local_identifiability(de, inputs, to_check, 0.99)
62+
local_id_all = assess_local_identifiability(de, 0.99)
63+
# [ Info: Preproccessing `ModelingToolkit.ODESystem` object
64+
# Dict{Nemo.fmpq_mpoly, Bool} with 10 entries:
65+
# x5 => 1
66+
# k7 => 1
67+
# k10 => 1
68+
# x6 => 1
69+
# k8 => 1
70+
# k9 => 1
71+
# k6 => 1
72+
# k5 => 1
73+
# x4 => 1
74+
# x7 => 0
75+
```
76+
We can see that all states (except $x_7$) and all parameters are locally identifiable with probability 0.99.
7077

71-
# let's try to check specific parameters and their combinations
78+
Let's try to check specific parameters and their combinations
79+
```julia
7280
to_check = [k5, k7, k10/k9, k5+k6]
73-
local_id_some = assess_local_identifiability(de, inputs, to_check, 0.99)
74-
81+
local_id_some = assess_local_identifiability(de, to_check, 0.99)
82+
# 4-element Vector{Bool}:
83+
# 1
84+
# 1
85+
# 1
86+
# 1
7587
```
7688

7789
Notice that in this case, everything (except the state variable $x_7$) is locally identifiable, including combinations such as $k_{10}/k_9, k_5+k_6$
@@ -94,66 +106,68 @@ $$\begin{cases}
94106

95107
This model describes enzyme dynamics[^3]. Let us run a global identifiability check on this model. We will use the default settings: the probability of correctness will be `p=0.99` and we are interested in identifiability of all possible parameters
96108

97-
Global identifiability needs information about local identifiability first, hence the function we chose here will take care of that extra step for us.
109+
Global identifiability needs information about local identifiability first, but the function we chose here will take care of that extra step for us.
98110

99-
```@repl
111+
__Note__: as of writing this tutorial, UTF-symbols such as Greek characters are not supported by one of the project's dependencies, see (this issue)[https://github.com/SciML/StructuralIdentifiability.jl/issues/43].
112+
113+
```julia
100114
using StructuralIdentifiability, ModelingToolkit
101-
@parameters b c α β γ δ σ
102-
@variables t x1(t) x2(t) x3(t) x4(t) y(t)
115+
@parameters b c a beta g delta sigma
116+
@variables t x1(t) x2(t) x3(t) x4(t) y(t) [output=true]
103117
D = Differential(t)
104118

105119
eqs = [
106120
D(x1) ~ -b * x1 + 1/(c + x4),
107-
D(x2) ~ α * x1 - β * x2,
108-
D(x3) ~ γ * x2 - δ * x3,
109-
D(x4) ~ σ * x4 * (γ * x2 - δ * x3)/x3
110-
]
111-
112-
observed = [
121+
D(x2) ~ a * x1 - beta * x2,
122+
D(x3) ~ g * x2 - delta * x3,
123+
D(x4) ~ sigma * x4 * (g * x2 - delta * x3)/x3,
113124
y~x1
114125
]
115126

116-
# no inputs
117-
inputs = []
118-
119-
# check all parameters
120-
to_check = []
121127

122-
ode = ODESystem(eqs, t, [x1, x2, x3, x4], [b, c, α, β, γ, δ, σ], observed=observed, name=:GoodwinOsc)
128+
ode = ODESystem(eqs, t, name=:GoodwinOsc)
123129

124-
@time global_id = assess_identifiability(ode, inputs, to_check, 0.99)
130+
@time global_id = assess_identifiability(ode)
131+
# 28.961573 seconds (88.92 M allocations: 5.541 GiB, 4.01% gc time)
132+
# Dict{Nemo.fmpq_mpoly, Symbol} with 7 entries:
133+
# c => :globally
134+
# a => :nonidentifiable
135+
# g => :nonidentifiable
136+
# delta => :locally
137+
# sigma => :globally
138+
# beta => :locally
139+
# b => :globally
125140
```
141+
We can see that
126142

127143
Let us consider the same system but with two inputs and we will try to find out identifiability with probability `0.9` for parameters `c` and `b`:
128144

129-
```@repl
145+
```julia
130146
using StructuralIdentifiability, ModelingToolkit
131-
@parameters b c α β γ δ σ
132-
@variables t x1(t) x2(t) x3(t) x4(t) y(t) u1(t) u2(t)
147+
@parameters b c a beta g delta sigma
148+
@variables t x1(t) x2(t) x3(t) x4(t) y(t) [output=true] u1(t) [input=true] u2(t) [input=true]
133149
D = Differential(t)
134150

135151
eqs = [
136152
D(x1) ~ -b * x1 + 1/(c + x4),
137-
D(x2) ~ α * x1 - β * x2 - u1,
138-
D(x3) ~ γ * x2 - δ * x3 + u2,
139-
D(x4) ~ σ * x4 * (γ * x2 - δ * x3)/x3
140-
]
141-
142-
observed = [
153+
D(x2) ~ a * x1 - beta * x2 - u1,
154+
D(x3) ~ g * x2 - delta * x3 + u2,
155+
D(x4) ~ sigma * x4 * (g * x2 - delta * x3)/x3,
143156
y~x1
144157
]
145158

146-
# indicate inputs
147-
inputs = [u1, u2]
148-
149159
# check only 2 parameters
150160
to_check = [b, c]
151161

152-
ode = ODESystem(eqs, t, [x1, x2, x3, x4], [b, c, α, β, γ, δ, σ], observed=observed, name=:GoodwinOsc)
162+
ode = ODESystem(eqs, t, name=:GoodwinOsc)
153163

154-
@time global_id = assess_identifiability(ode, inputs, to_check, 0.9)
164+
global_id = assess_identifiability(ode, to_check, 0.9)
165+
# Dict{Nemo.fmpq_mpoly, Symbol} with 2 entries:
166+
# b => :globally
167+
# c => :globally
155168
```
156169

170+
Both parameters $b, c$ are globally identifiable with probability 0.9.
157171

158172
[^1]:
159173
> R. Munoz-Tamayo, L. Puillet, J.B. Daniel, D. Sauvant, O. Martin, M. Taghipoor, P. Blavy [*Review: To be or not to be an identifiable model. Is this a relevant question in animal science modelling?*](https://doi.org/10.1017/S1751731117002774), Animal, Vol 12 (4), 701-712, 2018. The model is the ODE system (3) in Supplementary Material 2, initial conditions are assumed to be unknown.

0 commit comments

Comments
 (0)