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
Copy file name to clipboardExpand all lines: docs/src/quickstart.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,9 +191,9 @@ Looking at the eigenvalues of the system, we see that the estimated eigenvalues
191
191
192
192
## Nonlinear Systems - Sparse Identification of Nonlinear Dynamics
193
193
194
-
Okay, so far we can fit linear models via DMD and nonlinear models via EDMD. But what if we want to find a model of a nonlinear system *without moving to Koopman space*? Simple, we use [Sparse Identification of Nonlinear Dynamics](https://www.pnas.org/content/113/15/3932) or `SInDy`.
194
+
Okay, so far we can fit linear models via DMD and nonlinear models via EDMD. But what if we want to find a model of a nonlinear system *without moving to Koopman space*? Simple, we use [Sparse Identification of Nonlinear Dynamics](https://www.pnas.org/content/113/15/3932) or `SINDy`.
195
195
196
-
As the name suggests, `SInDy` finds the sparsest basis of functions which build the observed trajectory. Again, we will start with a nonlinear system
196
+
As the name suggests, `SINDy` finds the sparsest basis of functions which build the observed trajectory. Again, we will start with a nonlinear system
Copy file name to clipboardExpand all lines: docs/src/sparse_identification/isindy.md
+26-26Lines changed: 26 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Implicit Sparse Identification of Nonlinear Dynamics
2
2
3
-
While `SInDy` works well for ODEs, some systems take the form of [DAE](https://diffeq.sciml.ai/stable/types/dae_types/)s. A common form is `f(x, p, t) - g(x, p, t)*dx = 0`. These can be inferred via `ISInDy`, which extends `SInDy`[for Implicit problems](https://ieeexplore.ieee.org/abstract/document/7809160). In particular, it solves
3
+
While `SINDy` works well for ODEs, some systems take the form of [DAE](https://diffeq.sciml.ai/stable/types/dae_types/)s. A common form is `f(x, p, t) - g(x, p, t)*dx = 0`. These can be inferred via `ISINDy`, which extends `SINDy`[for Implicit problems](https://ieeexplore.ieee.org/abstract/document/7809160). In particular, it solves
@@ -13,7 +13,7 @@ where ``\Xi`` lies in the nullspace of ``\Theta``.
13
13
Let's try to infer the [Michaelis-Menten Kinetics](https://en.wikipedia.org/wiki/Michaelis%E2%80%93Menten_kinetics), like in the corresponding paper. We start by generating the
14
14
corresponding data.
15
15
16
-
```@exampleisindy_1
16
+
```@exampleiSINDy_1
17
17
using DataDrivenDiffEq
18
18
using ModelingToolkit
19
19
using OrdinaryDiffEq
@@ -32,11 +32,11 @@ problem = ODEProblem(michaelis_menten, u0, tspan)
The signature of `ISInDy` is equal to `SInDy`, but requires an `AbstractSubspaceOptimizer`. Currently, `DataDrivenDiffEq` just implements `ADM()` based on [alternating directions](https://arxiv.org/pdf/1412.4659.pdf). `rtol` gets passed into the derivation of the `nullspace` via `LinearAlgebra`.
50
+
The signature of `ISINDy` is equal to `SINDy`, but requires an `AbstractSubspaceOptimizer`. Currently, `DataDrivenDiffEq` just implements `ADM()` based on [alternating directions](https://arxiv.org/pdf/1412.4659.pdf). `rtol` gets passed into the derivation of the `nullspace` via `LinearAlgebra`.
51
51
52
52
53
-
```@exampleisindy_1
53
+
```@exampleiSINDy_1
54
54
opt = ADM(1.1e-1)
55
55
```
56
56
57
-
Since `ADM()` returns sparsified columns of the nullspace we need to find a pareto optimal solution. To achieve this, we provide a sufficient cost function `g` to `ISInDy`. This allows us to evaluate each individual column of the sparse matrix on its 0-norm (sparsity) and the 2-norm of the matrix vector product of ``\Theta^T \xi`` (nullspace). This is a default setting which can be changed by providing a function `f` which maps the coefficients and the library onto a feature space. Here, we want to set the focus on the the magnitude of the deviation from the nullspace.
57
+
Since `ADM()` returns sparsified columns of the nullspace we need to find a pareto optimal solution. To achieve this, we provide a sufficient cost function `g` to `ISINDy`. This allows us to evaluate each individual column of the sparse matrix on its 0-norm (sparsity) and the 2-norm of the matrix vector product of ``\Theta^T \xi`` (nullspace). This is a default setting which can be changed by providing a function `f` which maps the coefficients and the library onto a feature space. Here, we want to set the focus on the the magnitude of the deviation from the nullspace.
plot(solution, color = :red, label = "True") # hide
77
77
plot!(estimation, color = :green, label = "Estimation") # hide
78
-
savefig("isindy_example_final.png") # hide
78
+
savefig("iSINDy_example_final.png") # hide
79
79
```
80
-

80
+

81
81
82
-
The model recovered by `ISInDy` is correct
82
+
The model recovered by `ISINDy` is correct
83
83
84
-
```@exampleisindy_1
84
+
```@exampleiSINDy_1
85
85
print_equations(Ψ)
86
86
```
87
87
@@ -92,7 +92,7 @@ The parameters are off a little, but, as before, we can use `DiffEqFlux` to tune
92
92
93
93
Implicit dynamics can also be reformulated as an explicit problem as stated in [this paper](https://arxiv.org/pdf/2004.02322.pdf). The algorithm searches the correct equations by trying out all candidate functions as a right hand side and performing a sparse regression onto the remaining set of candidates. Let's start by defining the problem and generate the data:
94
94
95
-
```@exampleisindy_2
95
+
```@exampleiSINDy_2
96
96
97
97
using DataDrivenDiffEq
98
98
using ModelingToolkit
@@ -125,15 +125,15 @@ for (i, xi) in enumerate(eachcol(X))
125
125
end
126
126
127
127
plot(solution) # hide
128
-
savefig("isindy_cartpole_data.png") # hide
128
+
savefig("iSINDy_cartpole_data.png") # hide
129
129
130
130
```
131
-

131
+

132
132
133
133
We see that we include a forcing term `F` inside the model which is depending on `t`.
134
134
As before, we will also need a `Basis` to derive our equations from:
135
135
136
-
```@exampleisindy_2
136
+
```@exampleiSINDy_2
137
137
@variables u[1:4] t
138
138
polys = Operation[]
139
139
for i ∈ 0:4
@@ -164,12 +164,12 @@ We added the time dependent input directly into the basis to account for its inf
164
164
165
165
*NOTE : Including input signals may change in future releases!*
166
166
167
-
Like for a `SInDy`, we can use any `AbstractOptimizer` with a pareto front optimization over different thresholds.
167
+
Like for a `SINDy`, we can use any `AbstractOptimizer` with a pareto front optimization over different thresholds.
168
168
169
-
```@exampleisindy_2
169
+
```@exampleiSINDy_2
170
170
λ = exp10.(-4:0.1:-1)
171
171
g(x) = norm([1e-3; 10.0] .* x, 2)
172
-
Ψ = ISInDy(X[:,:], DX[:, :], basis, λ, STRRidge(), maxiter = 100, normalize = false, t = solution.t, g = g)
172
+
Ψ = ISINDy(X[:,:], DX[:, :], basis, λ, STRRidge(), maxiter = 100, normalize = false, t = solution.t, g = g)
Copy file name to clipboardExpand all lines: docs/src/sparse_identification/sindy.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ where, in most cases, ``Y``is the data matrix containing the derivatives of the
15
15
As in the original paper, we will estimate the [Lorenz System](https://en.wikipedia.org/wiki/Lorenz_system).
16
16
First, let's create the necessary data and have a look at the trajectory.
17
17
18
-
```@examplesindy_1
18
+
```@exampleSINDy_1
19
19
using DataDrivenDiffEq
20
20
using ModelingToolkit
21
21
using OrdinaryDiffEq
@@ -47,7 +47,7 @@ savefig("lorenz.png") #hide
47
47
48
48
Additionally, we generate the *ideal* derivative data.
49
49
50
-
```@examplesindy_1
50
+
```@exampleSINDy_1
51
51
X = Array(solution)
52
52
DX = similar(X)
53
53
for (i, xi) in enumerate(eachcol(X))
@@ -57,7 +57,7 @@ end
57
57
58
58
To generate the symbolic equations, we need to define a ` Basis` over the variables `x y z`. In this example, we will use all monomials up to degree of 4 and their products:
59
59
60
-
```@examplesindy_1
60
+
```@exampleSINDy_1
61
61
@variables x y z
62
62
u = Operation[x; y; z]
63
63
polys = Operation[]
@@ -79,25 +79,25 @@ nothing #hide
79
79
80
80
To perform the sparse identification on our data, we need to define an `Optimizer`. Here, we will use `STRRidge`, which is described in the original paper. The threshold of the optimizer is set to `0.1`. An overview of the different optimizers can be found below.
`Ψ` is a `SInDyResult`, which stores some about the regression. As we can see, we have 7 active terms inside the model.
87
+
`Ψ` is a `SINDyResult`, which stores some about the regression. As we can see, we have 7 active terms inside the model.
88
88
To look at the equations, simply type
89
89
90
-
```@examplesindy_1
90
+
```@exampleSINDy_1
91
91
print_equations(Ψ)
92
92
```
93
93
94
94
First, let's have a look at the ``L2``-Error and Akaikes Information Criterion of the result
95
95
96
-
```@examplesindy_1
96
+
```@exampleSINDy_1
97
97
get_error(Ψ)
98
98
```
99
99
100
-
```@examplesindy_1
100
+
```@exampleSINDy_1
101
101
get_aicc(Ψ)
102
102
```
103
103
@@ -106,7 +106,7 @@ We can also access the coefficient matrix ``\Xi`` directly via `get_coefficients
106
106
To generate a numerical model usable in `DifferentialEquations`, we simply use the `ODESystem` function from `ModelingToolkit`.
107
107
The resulting parameters used for the identification can be accessed via `parameters(Ψ)`. The returned vector also includes the parameters of the original `Basis` used to generate the result.
108
108
109
-
```@examplesindy_1
109
+
```@exampleSINDy_1
110
110
ps = parameters(Ψ)
111
111
sys = ODESystem(Ψ)
112
112
dudt = ODEFunction(sys)
@@ -137,7 +137,7 @@ which resembles the papers results. Next, we could use [classical parameter esti
0 commit comments