Skip to content

Commit 4be9600

Browse files
committed
doc: add the parameter p in f and h function signature
forgot to add it in some docstrings
1 parent c0c6ae3 commit 4be9600

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

docs/src/manual/nonlinmpc.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ model = setname!(NonLinModel(f, h, Ts, nu, nx, ny; p=p_model); u=vu, x=vx, y=vy)
6464

6565
The output function ``\mathbf{h}`` converts the ``θ`` angle to degrees. Note that special
6666
characters like ``θ`` can be typed in the Julia REPL or VS Code by typing `\theta` and
67-
pressing the `<TAB>` key. Note that the parameter `p` can be of any type but use a mutable
68-
type like a vector of you want to modify it later. A 4th order [`RungeKutta`](@ref) method
69-
solves the differential equations by default. It is good practice to first simulate `model`
70-
using [`sim!`](@ref) as a quick sanity check:
67+
pressing the `<TAB>` key. The parameter `p` can be of any type but use a mutable type like a
68+
vector of you want to modify it later. A 4th order [`RungeKutta`](@ref) method solves the
69+
differential equations by default. It is good practice to first simulate `model` using
70+
[`sim!`](@ref) as a quick sanity check:
7171

7272
```@example 1
7373
using Plots

src/model/linearization.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,34 @@ julia> linmodel.A
3535
With the nonlinear state-space model:
3636
```math
3737
\begin{aligned}
38-
\mathbf{x}(k+1) &= \mathbf{f}\Big(\mathbf{x}(k), \mathbf{u}(k), \mathbf{d}(k)\Big) \\
39-
\mathbf{y}(k) &= \mathbf{h}\Big(\mathbf{x}(k), \mathbf{d}(k)\Big)
38+
\mathbf{x}(k+1) &= \mathbf{f}\Big(\mathbf{x}(k), \mathbf{u}(k), \mathbf{d}(k), \mathbf{p}\Big) \\
39+
\mathbf{y}(k) &= \mathbf{h}\Big(\mathbf{x}(k), \mathbf{d}(k), \mathbf{p}\Big)
4040
\end{aligned}
4141
```
4242
its linearization at the operating point ``\mathbf{x_{op}, u_{op}, d_{op}}`` is:
4343
```math
4444
\begin{aligned}
4545
\mathbf{x_0}(k+1) &≈ \mathbf{A x_0}(k) + \mathbf{B_u u_0}(k) + \mathbf{B_d d_0}(k)
46-
+ \mathbf{f(x_{op}, u_{op}, d_{op})} - \mathbf{x_{op}} \\
46+
+ \mathbf{f(x_{op}, u_{op}, d_{op}, p)} - \mathbf{x_{op}} \\
4747
\mathbf{y_0}(k) &≈ \mathbf{C x_0}(k) + \mathbf{D_d d_0}(k)
4848
\end{aligned}
4949
```
5050
based on the deviation vectors ``\mathbf{x_0, u_0, d_0, y_0}`` introduced in [`setop!`](@ref)
5151
documentation, and the Jacobian matrices:
5252
```math
5353
\begin{aligned}
54-
\mathbf{A} &= \left. \frac{∂\mathbf{f(x, u, d)}}{∂\mathbf{x}} \right|_{\mathbf{x=x_{op},\, u=u_{op},\, d=d_{op}}} \\
55-
\mathbf{B_u} &= \left. \frac{∂\mathbf{f(x, u, d)}}{∂\mathbf{u}} \right|_{\mathbf{x=x_{op},\, u=u_{op},\, d=d_{op}}} \\
56-
\mathbf{B_d} &= \left. \frac{∂\mathbf{f(x, u, d)}}{∂\mathbf{d}} \right|_{\mathbf{x=x_{op},\, u=u_{op},\, d=d_{op}}} \\
57-
\mathbf{C} &= \left. \frac{∂\mathbf{h(x, d)}}{∂\mathbf{x}} \right|_{\mathbf{x=x_{op},\, d=d_{op}}} \\
58-
\mathbf{D_d} &= \left. \frac{∂\mathbf{h(x, d)}}{∂\mathbf{d}} \right|_{\mathbf{x=x_{op},\, d=d_{op}}}
54+
\mathbf{A} &= \left. \frac{∂\mathbf{f(x, u, d, p)}}{∂\mathbf{x}} \right|_{\mathbf{x=x_{op},\, u=u_{op},\, d=d_{op}}} \\
55+
\mathbf{B_u} &= \left. \frac{∂\mathbf{f(x, u, d, p)}}{∂\mathbf{u}} \right|_{\mathbf{x=x_{op},\, u=u_{op},\, d=d_{op}}} \\
56+
\mathbf{B_d} &= \left. \frac{∂\mathbf{f(x, u, d, p)}}{∂\mathbf{d}} \right|_{\mathbf{x=x_{op},\, u=u_{op},\, d=d_{op}}} \\
57+
\mathbf{C} &= \left. \frac{∂\mathbf{h(x, d, p)}}{∂\mathbf{x}} \right|_{\mathbf{x=x_{op},\, d=d_{op}}} \\
58+
\mathbf{D_d} &= \left. \frac{∂\mathbf{h(x, d, p)}}{∂\mathbf{d}} \right|_{\mathbf{x=x_{op},\, d=d_{op}}}
5959
\end{aligned}
6060
```
6161
Following [`setop!`](@ref) notation, we find:
6262
```math
6363
\begin{aligned}
64-
\mathbf{f_{op}} &= \mathbf{f(x_{op}, u_{op}, d_{op})} \\
65-
\mathbf{y_{op}} &= \mathbf{h(x_{op}, d_{op})}
64+
\mathbf{f_{op}} &= \mathbf{f(x_{op}, u_{op}, d_{op}, p)} \\
65+
\mathbf{y_{op}} &= \mathbf{h(x_{op}, d_{op}, p)}
6666
\end{aligned}
6767
```
6868
Notice that ``\mathbf{f_{op} - x_{op} = 0}`` if the point is an equilibrium. The

src/sim_model.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ The state-space description of [`LinModel`](@ref) around the operating points is
6464
```math
6565
\begin{aligned}
6666
\mathbf{x_0}(k+1) &= \mathbf{A x_0}(k) + \mathbf{B_u u_0}(k) + \mathbf{B_d d_0}(k)
67-
+ \mathbf{f_{op}} - \mathbf{x_{op}} \\
67+
+ \mathbf{f_{op}} - \mathbf{x_{op}} \\
6868
\mathbf{y_0}(k) &= \mathbf{C x_0}(k) + \mathbf{D_d d_0}(k)
6969
\end{aligned}
7070
```
7171
and, for [`NonLinModel`](@ref):
7272
```math
7373
\begin{aligned}
74-
\mathbf{x_0}(k+1) &= \mathbf{f}\Big(\mathbf{x_0}(k), \mathbf{u_0}(k), \mathbf{d_0}(k)\Big)
75-
+ \mathbf{f_{op}} - \mathbf{x_{op}} \\
76-
\mathbf{y_0}(k) &= \mathbf{h}\Big(\mathbf{x_0}(k), \mathbf{d_0}(k)\Big)
74+
\mathbf{x_0}(k+1) &= \mathbf{f}\Big(\mathbf{x_0}(k), \mathbf{u_0}(k), \mathbf{d_0}(k), \mathbf{p}\Big)
75+
+ \mathbf{f_{op}} - \mathbf{x_{op}} \\
76+
\mathbf{y_0}(k) &= \mathbf{h}\Big(\mathbf{x_0}(k), \mathbf{d_0}(k), \mathbf{p}\Big)
7777
\end{aligned}
7878
```
7979
The state `xop` and the additional `fop` operating points are frequently zero e.g.: when

0 commit comments

Comments
 (0)