@@ -157,8 +157,7 @@ struct MovingHorizonEstimator{
157157 Z̃ = zeros (NT, nZ̃)
158158 X̂op = repeat (x̂op, He)
159159 X̂0, Y0m = zeros (NT, nx̂* He), zeros (NT, nym* He)
160- nD0 = direct ? nd* (He+ 1 ) : nd* He
161- U0, D0 = zeros (NT, nu* He), zeros (NT, nD0)
160+ U0, D0 = zeros (NT, nu* He), zeros (NT, nd* (He+ 1 ))
162161 Ŵ = zeros (NT, nx̂* He)
163162 buffer = StateEstimatorBuffer {NT} (nu, nx̂, nym, ny, nd, nk, He, nε)
164163 x̂0arr_old = zeros (NT, nx̂)
@@ -1038,14 +1037,14 @@ produces an estimator in the current form, while the prediction form is obtained
10381037 &= \m athbf{E Z + F}
10391038\e nd{aligned}
10401039```
1041- in which ``\m athbf{U_0}`` and ``\m athbf{Y_0^m}`` respectively include the deviation values of
1042- the manipulated inputs ``\m athbf{u_0}(k-j+p)`` from ``j=N_k`` to ``1`` and measured outputs
1043- ``\m athbf{y_0^m}(k-j+1)`` from ``j=N_k`` to ``1``. The vector ``\m athbf{D_0}`` comprises one
1044- additional measured disturbance if ``p=0``, that is, it includes the deviation vectors
1045- ``\m athbf{d_0}(k-j+1)`` from ``j =N_k+1-p `` to ``1 ``. The constant ``\m athbf{B}`` is the
1046- contribution for non-zero state ``\m athbf{x̂_{op}}`` and state update ``\m athbf{f̂_{op}}``
1047- operating points (for linearization, see [`augment_model`](@ref) and [`linearize`](@ref)).
1048- The method also returns the matrices for the estimation error at arrival:
1040+ in which ``\m athbf{U_0}`` and ``\m athbf{Y_0^m}`` respectively include the deviation values
1041+ of the manipulated inputs ``\m athbf{u_0}(k-j+p)`` from ``j=N_k`` to ``1`` and measured
1042+ outputs ``\m athbf{y_0^m}(k-j+1)`` from ``j=N_k`` to ``1``. The vector ``\m athbf{D_0}``
1043+ includes the the measured disturbance deviation values `` \m athbf{d_0}(k-j)`` from from
1044+ ``j =N_k`` to ``0 ``. The constant ``\m athbf{B}`` is the contribution for non-zero state
1045+ ``\m athbf{x̂_{op}}`` and state update ``\m athbf{f̂_{op}}`` operating points (for linearization,
1046+ see [`augment_model`](@ref) and [`linearize`](@ref)). The method also returns the matrices
1047+ for the estimation error at arrival:
10491048```math
10501049 \m athbf{x̄} = \m athbf{x̂_0^†}(k-N_k+p) - \m athbf{x̂_0}(k-N_k+p) = \m athbf{e_x̄ Z + f_x̄}
10511050```
@@ -1108,10 +1107,10 @@ see [`initpred!(::MovingHorizonEstimator, ::LinModel)`](@ref) and [`linconstrain
11081107 \v dots & \v dots & \d dots & \v dots \\
11091108 \m athbf{Ĉ^m}\m athbf{Â}^{H_e-2}\m athbf{B̂_u} & \m athbf{Ĉ^m}\m athbf{Â}^{H_e-3}\m athbf{B̂_u} & \c dots & \m athbf{0} \e nd{bmatrix} \\
11101109 \m athbf{J} &= - \b egin{bmatrix}
1111- \m athbf{D̂_d^m} & \m athbf{0} & \c dots & \m athbf{0} \\
1112- \m athbf{Ĉ^m}\m athbf{Â}^{0}\m athbf{B̂_d} & \m athbf{D̂_d^m} & \c dots & \m athbf{0} \\
1113- \v dots & \v dots & \d dots & \v dots \\
1114- \m athbf{Ĉ^m}\m athbf{Â}^{H_e-2}\m athbf{B̂_d} & \m athbf{Ĉ^m}\m athbf{Â}^{H_e-3}\m athbf{B̂_d} & \c dots & \m athbf{D̂_d^m} \e nd{bmatrix} \\
1110+ \m athbf{0} & \m athbf{ D̂_d^m} & \m athbf{0} & \c dots & \m athbf{0} \\
1111+ \m athbf{0} & \m athbf{ Ĉ^m}\m athbf{Â}^{0}\m athbf{B̂_d} & \m athbf{D̂_d^m} & \c dots & \m athbf{0} \\
1112+ \v dots & \v dots & \v dots & \d dots & \v dots \\
1113+ \m athbf{0} & \m athbf{ Ĉ^m}\m athbf{Â}^{H_e-2}\m athbf{B̂_d} & \m athbf{Ĉ^m}\m athbf{Â}^{H_e-3}\m athbf{B̂_d} & \c dots & \m athbf{D̂_d^m} \e nd{bmatrix} \\
11151114 \m athbf{B} &= - \b egin{bmatrix}
11161115 \m athbf{0} \\
11171116 \m athbf{Ĉ^m S}(0) \\
@@ -1138,8 +1137,8 @@ see [`initpred!(::MovingHorizonEstimator, ::LinModel)`](@ref) and [`linconstrain
11381137 \v dots & \v dots & \d dots & \v dots \\
11391138 \m athbf{Â}^{H_e-1}\m athbf{B̂_d} & \m athbf{Â}^{H_e-2}\m athbf{B̂_d} & \c dots & \m athbf{Â}^{0}\m athbf{B̂_d} \e nd{bmatrix} \ , \q uad
11401139 \m athbf{J_x̂} = \b egin{cases}
1141- [\b egin{smallmatrix} \m athbf{J_x̂^†} & \m athbf{0} \e nd{smallmatrix}] & p=0 \\
1142- \m athbf{J_x̂^†} & p=1 \e nd{cases} \\
1140+ [\b egin{smallmatrix} \m athbf{J_x̂^†} & \m athbf{0} \e nd{smallmatrix}] & p=0 \\
1141+ [ \b egin{smallmatrix} \m athbf{0} & \m athbf{J_x̂^†} \e nd{smallmatrix}] & p=1 \e nd{cases} \\
11431142 \m athbf{B_x̂} &= \b egin{bmatrix}
11441143 \m athbf{S}(0) \\
11451144 \m athbf{S}(1) \\
@@ -1218,22 +1217,20 @@ function init_predmat_mhe(
12181217 # --- measured disturbances D ---
12191218 nĈm_Âpow_B̂d = reduce (vcat, getpower (nĈm_Âpow3D, i)* B̂d for i= 0 : He- 1 )
12201219 nĈm_Âpow_B̂d = [- D̂dm; nĈm_Âpow_B̂d]
1221- J = zeros (NT, nym* He, nd* (He+ 1 - p))
1222- col_begin = iszero (p) ? 1 : 0
1223- col_end = iszero (p) ? He+ 1 : He
1224- i= 0
1225- for j= col_begin: col_end- 1
1220+ J = zeros (NT, nym* He, nd* (He+ 1 ))
1221+ i = 0
1222+ for j= 1 : He
12261223 iRow = (1 + i* nym): (nym* He)
12271224 iCol = (1 : nd) .+ j* nd
12281225 J[iRow, iCol] = nĈm_Âpow_B̂d[1 : length (iRow) ,:]
12291226 i+= 1
12301227 end
12311228 iszero (p) && @views (J[:, 1 : nd] = nĈm_Âpow_B̂d[nym+ 1 : end , :])
12321229 Âpow_B̂d = reduce (vcat, getpower (Âpow3D, i)* B̂d for i= 0 : He- 1 )
1233- Jx̂ = zeros (NT, nx̂* He, nd* (He+ 1 - p ))
1230+ Jx̂ = zeros (NT, nx̂* He, nd* (He+ 1 ))
12341231 for j= 0 : He- 1
12351232 iRow = (1 + j* nx̂): (nx̂* He)
1236- iCol = (1 : nd) .+ j* nd
1233+ iCol = (1 : nd) .+ j* nd .+ p
12371234 Jx̂[iRow, iCol] = Âpow_B̂d[1 : length (iRow) ,:]
12381235 end
12391236 # --- state x̂op and state update f̂op operating points ---
0 commit comments