19
19
Mutating state function ``\m athbf{f̂}`` of the augmented model.
20
20
21
21
By introducing an augmented state vector ``\m athbf{x̂_0}`` like in [`augment_model`](@ref),
22
- the function returns the next state of the augmented model, defined as :
22
+ the function returns the next state of the augmented model, as deviation vectors :
23
23
```math
24
24
\b egin{aligned}
25
- \m athbf{x̂_0}(k+1) &= \m athbf{f̂}\B ig(\m athbf{x̂_0}(k), \m athbf{u_0}(k), \m athbf{d_0}(k)\B ig) \\
25
+ \m athbf{x̂_0}(k+1) &= \m athbf{f̂}\B ig(\m athbf{x̂_0}(k), \m athbf{u_0}(k), \m athbf{d_0}(k)\B ig)
26
26
\m athbf{ŷ_0}(k) &= \m athbf{ĥ}\B ig(\m athbf{x̂_0}(k), \m athbf{d_0}(k)\B ig)
27
27
\e nd{aligned}
28
28
```
29
29
where ``\m athbf{x̂_0}(k+1)`` is stored in `x̂0next` argument. The method mutates `x̂0next`,
30
30
`û0` and `k0` in place. The argument `û0` stores the disturbed input of the augmented model
31
31
``\m athbf{û_0}``, and `k0`, the intermediate stage values of `model.solver`, when applicable.
32
- The model parameter `model.p` is not included in the function signature for conciseness. See
33
- Extended Help for details on ``\m athbf{û_0, f̂}`` and ``\m athbf{ĥ}`` implementations.
32
+ The model parameter `model.p` is not included in the function signature for conciseness.
33
+ The operating points are handled inside ``\m athbf{f̂}``. See Extended Help for details on
34
+ ``\m athbf{û_0, f̂}`` and ``\m athbf{ĥ}`` implementations.
34
35
35
36
# Extended Help
36
37
!!! details "Extended Help"
@@ -41,7 +42,8 @@ Extended Help for details on ``\mathbf{û_0, f̂}`` and ``\mathbf{ĥ}`` implem
41
42
\b egin{aligned}
42
43
\m athbf{f̂}\B ig(\m athbf{x̂_0}(k), \m athbf{u_0}(k), \m athbf{d_0}(k)\B ig) &= \b egin{bmatrix}
43
44
\m athbf{f}\B ig(\m athbf{x_0}(k), \m athbf{û_0}(k), \m athbf{d_0}(k), \m athbf{p}\B ig) \\
44
- \m athbf{A_s} \m athbf{x_s}(k) \e nd{bmatrix} \\
45
+ \m athbf{A_s} \m athbf{x_s}(k) \e nd{bmatrix}
46
+ + \m athbf{f̂_{op}} - \m athbf{x̂_{op}} \\
45
47
\m athbf{ĥ}\B ig(\m athbf{x̂_0}(k), \m athbf{d_0}(k)\B ig) &=
46
48
\m athbf{h}\B ig(\m athbf{x_0}(k), \m athbf{d_0}(k), \m athbf{p}\B ig) + \m athbf{y_{s_y}}(k)
47
49
\e nd{aligned}
@@ -55,37 +57,41 @@ Extended Help for details on ``\mathbf{û_0, f̂}`` and ``\mathbf{ĥ}`` implem
55
57
\e nd{aligned}
56
58
```
57
59
The ``\m athbf{f}`` and ``\m athbf{h}`` functions above are in fact the [`f!`](@ref) and
58
- [`h!`](@ref) methods, respectively.
60
+ [`h!`](@ref) methods, respectively. The operating points ``\m athbf{x̂_{op}, f̂_{op}}``
61
+ are computed by [`augment_model`](@ref) (almost always zeros in practice for
62
+ [`NonLinModel`](@ref)).
59
63
"""
60
64
function f̂! (x̂0next, û0, k0, estim:: StateEstimator , model:: SimModel , x̂0, u0, d0)
61
- return f̂! (x̂0next, û0, k0, model, estim. As, estim. Cs_u, x̂0, u0, d0)
65
+ return f̂! (x̂0next, û0, k0, model, estim. As, estim. Cs_u, estim . f̂op, estim . x̂op, x̂0, u0, d0)
62
66
end
63
67
64
68
"""
65
69
f̂!(x̂0next, _ , _ , estim::StateEstimator, model::LinModel, x̂0, u0, d0) -> nothing
66
70
67
- Use the augmented model matrices if `model` is a [`LinModel`](@ref).
71
+ Use the augmented model matrices and operating points if `model` is a [`LinModel`](@ref).
68
72
"""
69
73
function f̂! (x̂0next, _ , _ , estim:: StateEstimator , :: LinModel , x̂0, u0, d0)
70
74
mul! (x̂0next, estim. Â, x̂0)
71
75
mul! (x̂0next, estim. B̂u, u0, 1 , 1 )
72
76
mul! (x̂0next, estim. B̂d, d0, 1 , 1 )
77
+ x̂0next .+ = estim. f̂op .- estim. x̂op
73
78
return nothing
74
79
end
75
80
76
81
"""
77
- f̂!(x̂0next, û0, k0, model::SimModel, As, Cs_u, x̂0, u0, d0)
82
+ f̂!(x̂0next, û0, k0, model::SimModel, As, Cs_u, f̂op, x̂op, x̂0, u0, d0)
78
83
79
84
Same than [`f̂!`](@ref) for [`SimModel`](@ref) but without the `estim` argument.
80
85
"""
81
- function f̂! (x̂0next, û0, k0, model:: SimModel , As, Cs_u, x̂0, u0, d0)
86
+ function f̂! (x̂0next, û0, k0, model:: SimModel , As, Cs_u, f̂op, x̂op, x̂0, u0, d0)
82
87
# `@views` macro avoid copies with matrix slice operator e.g. [a:b]
83
88
@views xd, xs = x̂0[1 : model. nx], x̂0[model. nx+ 1 : end ]
84
89
@views xdnext, xsnext = x̂0next[1 : model. nx], x̂0next[model. nx+ 1 : end ]
85
90
mul! (û0, Cs_u, xs) # ys_u = Cs_u*xs
86
91
û0 .+ = u0 # û0 = u0 + ys_u
87
92
f! (xdnext, k0, model, xd, û0, d0, model. p)
88
93
mul! (xsnext, As, xs)
94
+ x̂0next .+ = f̂op .- x̂op
89
95
return nothing
90
96
end
91
97
0 commit comments