You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# [Fitting Parameters for an Oscillatory System](@id parameter_estimation)
2
-
In this example we will use [Optimization.jl](https://github.com/SciML/Optimization.jl) to fit the parameters of an oscillatory system (the Brusselator) to data. Here, special consideration is taken to avoid reaching a local minimum. Instead of fitting the entire time series directly, we will start with fitting parameter values for the first period, and then use those as an initial guess for fitting the next (and then these to find the next one, and so on). Using this procedure is advantageous for oscillatory systems, and enables us to reach the global optimum.
2
+
In this example we will use [Optimization.jl](https://github.com/SciML/Optimization.jl) to fit the parameters of an oscillatory system (the [Brusselator](@ref basic_CRN_library_brusselator)) to data. Here, special consideration is taken to avoid reaching a local minimum. Instead of fitting the entire time series directly, we will start with fitting parameter values for the first period, and then use those as an initial guess for fitting the next (and then these to find the next one, and so on). Using this procedure is advantageous for oscillatory systems, and enables us to reach the global optimum. For more information on fitting ODE parameters to data, please see [the main documentation page](@ref optimization_parameter_fitting) on this topic.
3
3
4
4
First, we fetch the required packages.
5
5
```@example pe_osc_example
@@ -18,18 +18,18 @@ brusselator = @reaction_network begin
18
18
B, X --> Y
19
19
1, X --> ∅
20
20
end
21
-
p_real = [:A => 1., :B => 2.]
21
+
p_real = [:A => 1.0, :B => 2.0]
22
22
nothing # hide
23
23
```
24
24
25
25
We simulate our model, and from the simulation generate sampled data points
26
26
(to which we add noise). We will use this data to fit the parameters of our model.
Copy file name to clipboardExpand all lines: docs/src/model_creation/reactionsystem_content_accessing.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -225,12 +225,12 @@ Similarly, `parameters` retrieves five different parameters. Here, we note that
225
225
parameters(rs)
226
226
```
227
227
228
-
If we wish to retrieve the species (or parameters) that are specifically contained in the top-level system (and not only indirectly through its subsystems), we can use the `Catalyst.get_species` (or `Catalyst.get_ps`) functions:
228
+
If we wish to retrieve the species (or parameters) that are specifically contained in the top-level system (and not only indirectly through its subsystems), we can use the `Catalyst.get_species` (or `ModelingToolkit.getps`) functions:
229
229
```@example model_accessing_hierarchical
230
230
Catalyst.get_species(rs)
231
231
```
232
232
```@example model_accessing_hierarchical
233
-
Catalyst.get_ps(rs)
233
+
ModelingToolkit.get_ps(rs)
234
234
```
235
235
Here, our top-level model contains a single parameter (`kₜ`), and two the two versions of the `Xᵢ` species. These are all the symbolic variables that occur in the transportation reaction (`@kₜ, $(nucleus_sys.Xᵢ) --> $(cytoplasm_sys.Xᵢ)`), which is the only reaction of the top-level system. We can apply these functions to the systems as well. However, when we do so, the systems' names are not prepended:
Copy file name to clipboardExpand all lines: docs/src/steady_state_functionality/nonlinear_solve.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,21 +67,24 @@ end
67
67
```
68
68
It has an infinite number of steady states. To make steady state finding possible, information of the system's conserved quantities (here $C = X1 + X2$) must be provided. Since these can be computed from system initial conditions (`u0`, i.e. those provided when performing ODE simulations), designating an `u0` is often the best way. There are two ways to do this. First, one can perform [forward ODE simulation-based steady state finding](@ref steady_state_solving_simulation), using the initial condition as the initial `u` guess. Alternatively, any conserved quantities can be eliminated when the `NonlinearProblem` is created. This feature is supported by [Catalyst's conservation law finding and elimination feature](@ref conservation_laws).
69
69
70
+
!!! warn
71
+
For Catalyst versions >14.4.1, handling of conservation laws in `NonlinearProblem`s through the `remove_conserved = true` argument has been temporarily disabled. This is due to an upstream update in ModelingToolkit.jl. We aim to re-enable this as soon as possible. Currently, to find steady states of these systems, either use [homotopy continuation](@ref homotopy_continuation), the [simulation based approach](@ref steady_state_solving_simulation), or temporarily downgrade Catalyst to version 14.4.1. The remaining code of this section is left on display (and the text with it), but is not run dynamically, and cannot be run without generating an error.
72
+
70
73
To eliminate conservation laws we simply provide the `remove_conserved = true` argument to `NonlinearProblem`:
here it is important that the quantities used in `u_guess` correspond to the conserved quantities we wish to use. E.g. here the conserved quantity $X1 + X2 = 3.0 + 1.0 = 4$ holds for the initial condition, and will hence also hold in the computed steady state as well. We can now find the steady states using `solve` like before:
78
-
<!--```@example steady_state_solving_claws
81
+
```julia
79
82
sol =solve(nl_prob)
80
-
```-->
83
+
```
81
84
We note that the output only provides a single value. The reason is that the actual system solved only contains a single equation (the other being eliminated with the conserved quantity). To find the values of $X1$ and $X2$ we can [directly query the solution object for these species' values, using the species themselves as inputs](@ref simulation_structure_interfacing_solutions):
82
-
<!--```@example steady_state_solving_claws
85
+
```julia
83
86
sol[[:X1, :X2]]
84
-
```-->
87
+
```
85
88
86
89
## [Finding steady states through ODE simulations](@id steady_state_solving_simulation)
87
90
The `NonlinearProblem`s generated by Catalyst corresponds to ODEs. A common method of solving these is to simulate the ODE from an initial condition until a steady state is reached. Here we do so for the dimerisation system considered in the previous section. First, we declare our model, initial condition, and parameter values.
0 commit comments