Skip to content

Commit f472910

Browse files
committed
added: handle xop and fop operating points in the MHE
1 parent de99b51 commit f472910

File tree

5 files changed

+329
-200
lines changed

5 files changed

+329
-200
lines changed

docs/src/public/sim_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The [`SimModel`](@ref) types represents discrete state-space models that can be
88
construct [`StateEstimator`](@ref)s and [`PredictiveController`](@ref)s, or as plant
99
simulators by calling [`evaloutput`](@ref) and [`updatestate!`](@ref) methods on
1010
[`SimModel`](@ref) instances (to test estimator/controller designs). For time simulations,
11-
the states `x` are stored inside [`SimModel`](@ref) instances. Use [`setstate!`](@ref)
11+
the states ``\mathbf{x}`` are stored inside [`SimModel`](@ref) instances. Use [`setstate!`](@ref)
1212
method to manually modify them.
1313

1414
## SimModel

src/controller/construct.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ The ``\mathbf{F}`` and ``\mathbf{f_x̂}`` vectors are recalculated at each contr
414414
# Extended Help
415415
!!! details "Extended Help"
416416
Using the augmented matrices ``\mathbf{Â, B̂_u, Ĉ, B̂_d, D̂_d}`` in `estim` (see
417-
[`augment_model`](@ref)) and the function ``\mathbf{W}(j) = ∑_{i=0}^j \mathbf{Â}^i``,
417+
[`augment_model`](@ref)), and the function ``\mathbf{W}(j) = ∑_{i=0}^j \mathbf{Â}^i``,
418418
the prediction matrices are computed by :
419419
```math
420420
\begin{aligned}
@@ -447,8 +447,7 @@ The ``\mathbf{F}`` and ``\mathbf{f_x̂}`` vectors are recalculated at each contr
447447
\mathbf{Ĉ W}(0) \\
448448
\mathbf{Ĉ W}(1) \\
449449
\vdots \\
450-
\mathbf{Ĉ W}(H_p-1) \end{bmatrix}
451-
\mathbf{\big(x̂_{op} + f̂_{op}\big)}
450+
\mathbf{Ĉ W}(H_p-1) \end{bmatrix} \mathbf{\big(x̂_{op} + f̂_{op}\big)}
452451
\end{aligned}
453452
```
454453
For the terminal constraints, the matrices are computed with:
@@ -468,7 +467,7 @@ The ``\mathbf{F}`` and ``\mathbf{f_x̂}`` vectors are recalculated at each contr
468467
\end{bmatrix} \\
469468
\mathbf{k_x̂} &= \mathbf{Â}^{H_p} \\
470469
\mathbf{v_x̂} &= \mathbf{W}(H_p-1)\mathbf{B̂_u} \\
471-
\mathbf{b_x̂} &= \mathbf{W}(H_p-1) \mathbf{\big(x̂_{op} + f̂_{op}\big)}
470+
\mathbf{b_x̂} &= \mathbf{W}(H_p-1) \mathbf{\big(f̂_{op} - x̂_{op}\big)}
472471
\end{aligned}
473472
```
474473
"""
@@ -525,15 +524,16 @@ function init_predmat(estim::StateEstimator{NT}, model::LinModel, Hp, Hc) where
525524
jx̂[: , iCol] = j < Hp ? getpower(Âpow, Hp-j-1)*B̂d : zeros(NT, nx̂, nd)
526525
end
527526
end
528-
# --- state and state update f̂op operating points ---
527+
# --- state x̂op and state update f̂op operating points ---
529528
coef_bx̂ = getpower(Âpow_csum, Hp-1)
530529
coef_B = Matrix{NT}(undef, ny*Hp, nx̂)
531530
for j=1:Hp
532531
iRow = (1:ny) .+ ny*(j-1)
533532
coef_B[iRow,:] =*getpower(Âpow_csum, j-1)
534533
end
535-
bx̂ = coef_bx̂ * (estim.f̂op - estim.x̂op)
536-
B = coef_B * (estim.f̂op - estim.x̂op)
534+
f̂op_n_x̂op = estim.f̂op - estim.x̂op
535+
bx̂ = coef_bx̂ * f̂op_n_x̂op
536+
B = coef_B * f̂op_n_x̂op
537537
return E, G, J, K, V, B, ex̂, gx̂, jx̂, kx̂, vx̂, bx̂
538538
end
539539

src/estimator/execute.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ Set model and operating points of `estim` [`StateEstimator`](@ref) to `model` va
245245
246246
Allows model adaptation of estimators based on [`LinModel`](@ref) at runtime ([`NonLinModel`](@ref)
247247
is not supported). Not supported by [`Luenberger`](@ref) and [`SteadyKalmanFilter`](@ref),
248-
use the time-varying [`KalmanFilter`](@ref) instead. The matrix dimensions and sample time
248+
use the time-varying [`KalmanFilter`](@ref) instead. The [`MovingHorizonEstimator`] model
249+
is kept constant over the estimation horizon ``H_e``. The matrix dimensions and sample time
249250
must stay the same. Note that the observability and controllability of the new augmented
250251
model is not verified (see Extended Help for details).
251252

0 commit comments

Comments
 (0)