4343
4444Update [`MovingHorizonEstimator`](@ref) state `estim.x̂0`.
4545
46- The optimization problem of [`MovingHorizonEstimator`](@ref) documentation is solved at
47- each discrete time ``k``. The prediction matrices are provided at [`init_predmat_mhe`](@ref)
48- documentation. Once solved, the optimal estimate ``\m athbf{x̂}_k(k+p)`` is computed by
49- inserting the optimal values of ``\m athbf{x̂}_k(k-N_k+p)`` and ``\m athbf{Ŵ}`` in the
50- augmented model from ``j = N_k-1`` to ``0`` inclusively. Afterward, if ``N_k = H_e``, the
51- arrival covariance for the next time step ``\m athbf{P̂}_{k-N_k}(k-N_k+1)`` is estimated using
52- `estim.covestim` object.
46+ The optimization problem of [`MovingHorizonEstimator`](@ref) documentation is solved if
47+ `estim.direct` is `false` (otherwise solved in [`correct_estimate!`](@ref)). The prediction
48+ matrices are provided at [`init_predmat_mhe`](@ref) documentation. Once solved, the optimal
49+ estimate ``\m athbf{x̂}_k(k+p)`` is computed by inserting the optimal values of
50+ ``\m athbf{x̂}_k(k-N_k+p)`` and ``\m athbf{Ŵ}`` in the augmented model from ``j = N_k-1`` to
51+ ``0`` inclusively. Afterward, if ``N_k = H_e``, the arrival covariance for the next time
52+ step ``\m athbf{P̂}_{k-N_k}(k-N_k+1)`` is estimated using `estim.covestim` object. It
53+ also stores `u0` at `estim.lastu0`, so it can be added to the data window at the next time
54+ step in [`correct_estimate!`](@ref).
5355"""
5456function update_estimate! (estim:: MovingHorizonEstimator , y0m, d0, u0)
5557 if ! estim. direct
@@ -59,6 +61,7 @@ function update_estimate!(estim::MovingHorizonEstimator, y0m, d0, u0)
5961 optim_objective! (estim)
6062 end
6163 (estim. Nk[] == estim. He) && update_cov! (estim)
64+ estim. lastu0 .= u0
6265 return nothing
6366end
6467
@@ -779,8 +782,10 @@ function setmodel_estimator!(
779782 # convert d to d0 with the new operating point:
780783 estim. D0[(1 + nd* (i- 1 )): (nd* i)] .- = model. dop
781784 end
785+ estim. lastu0 .+ = uop_old
782786 estim. Z̃[nϵ+ 1 : nϵ+ nx̂] .+ = x̂op_old
783787 estim. x̂0arr_old .+ = x̂op_old
788+ estim. lastu0 .- = model. uop
784789 estim. Z̃[nϵ+ 1 : nϵ+ nx̂] .- = x̂op
785790 estim. x̂0arr_old .- = x̂op
786791 # --- covariance matrices ---
0 commit comments