Skip to content

Commit 5284956

Browse files
authored
Merge pull request #531 from JuliaControl/getinfo_ahat_mhe
added: `:â` / `:ahat` field in `getinfo(mhe::MovingHorizonEstimator)`
2 parents 7df5732 + 9c54825 commit 5284956

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

‎docs/src/manual/mtk.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function generate_f_h_mtk(model, inputs, outputs, disturbances=nothing)
4747
f_ip_with_d(ẋ, x, u, p, nothing, d)
4848
catch err
4949
if err isa MethodError
50-
error("NonLinModel does not support a time argument t in the f "*
50+
error("NonLinModel(DAE) does not support a time argument t in the f "*
5151
"function, see the constructor docstring for a workaround.")
5252
else
5353
rethrow()
@@ -68,7 +68,7 @@ function generate_f_h_mtk(model, inputs, outputs, disturbances=nothing)
6868
h_ip_with_d(y, x, u_nothing, p, nothing, d)
6969
catch err
7070
if err isa MethodError
71-
error("NonLinModel only support strictly proper systems (no "*
71+
error("This package only support strictly proper systems (no "*
7272
"manipulated input argument u in the output function h)")
7373
else
7474
rethrow()

‎src/estimator/mhe/execute.jl‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ following fields:
9999
- `:ε` or *`:epsilon`* : optimal slack variable, ``ε``
100100
- `:X̂` or *`:Xhat`* : optimal estimated states over ``N_k``, ``\mathbf{X̂}``
101101
- `:x̂` or *`:xhat`* : optimal estimated state, ``\mathbf{x̂}_k(k+p)``
102-
- `:Â` or *`:Ahat`* : optimal estimated algebraic variables over ``N_k``, ``\mathbf{Â}``
102+
- `:Â` or *`:Ahat`* : optimal estimated algebraic variables over ``N_k`` (left limits), ``\mathbf{Â}``
103+
- `:â` or *`:ahat`* : optimal estimated algebraic variable (left limit), ``\mathbf{â}(k+p)``
103104
- `:V̂` or *`:Vhat`* : optimal estimated sensor noise over ``N_k``, ``\mathbf{V̂}``
104105
- `:P̄` or *`:Pbar`* : estimation error covariance at arrival, ``\mathbf{P̄}``
105106
- `:x̄` or *`:xbar`* : optimal estimation error at arrival, ``\mathbf{x̄}``
@@ -113,8 +114,8 @@ following fields:
113114
- `:D` : measured disturbances over ``N_k+1``, ``\mathbf{D}``
114115
- `:sol` : solution summary of the optimizer for printing
115116
116-
For [`NonLinModel`](@ref) or under custom nonlinear inequality constraints (`nc>0`), it also
117-
includes the following fields:
117+
For non-[`LinModel`](@ref) or under custom nonlinear inequality constraints (`nc>0`), it
118+
also includes the following fields:
118119
119120
- `:∇J` or *`:nablaJ`* : optimal gradient of the objective function, ``\mathbf{\nabla} J``
120121
- `:∇²J` or *`:nabla2J`* : optimal Hessian of the objective function, ``\mathbf{\nabla^2}J``
@@ -176,18 +177,20 @@ function getinfo(estim::MovingHorizonEstimator{NT}) where NT<:Real
176177
end
177178
D[end-nd+1:end] .+= model.dop
178179
x̂arr .+= estim.x̂op
180+
Â, âarr = Â0, â0arr # no operating points on the algebraic variable
179181
info[:Ŵ] = Ŵ[1:nŵ*Nk]
180182
info[:ε] = getslack(estim, Z̃)
181183
info[:X̂] = X̂[1:nx̂*Nk]
182-
info[:Â] = Â0[1:na*Nk]
183-
info[:x̂] = estim.x̂0 .+ estim.x̂op
184+
info[:x̂] = X̂[(1+nx̂*Nk-nx̂):(nx̂*Nk)]
185+
info[:Â] = Â[1:na*Nk]
186+
info[:â] = Â[(1+na*Nk-na):(na*Nk)]
184187
info[:V̂] = V̂[1:nym*Nk]
185188
info[:P̄] = estim.P̂arr_old
186189
info[:x̄] = x̄
187190
info[:Ŷ] = Ŷ[1:ny*Nk]
188191
info[:Ŷm] = Ŷ[vec(estim.i_ym .+ ny.*(0:Nk-1)')]
189192
info[:x̂arr] = x̂arr
190-
info[:âarr] = â0arr
193+
info[:âarr] = âarr
191194
info[:J] = J
192195
info[:Ym] = Ym
193196
info[:U] = U
@@ -199,7 +202,9 @@ function getinfo(estim::MovingHorizonEstimator{NT}) where NT<:Real
199202
info[:ahatarr] = info[:âarr]
200203
info[:epsilon] = info[:ε]
201204
info[:Xhat] = info[:X̂]
205+
info[:xhat] = info[:x̂]
202206
info[:Ahat] = info[:Â]
207+
info[:ahat] = info[:â]
203208
info[:Vhat] = info[:V̂]
204209
info[:Pbar] = info[:P̄]
205210
info[:xbar] = info[:x̄]

‎test/2_test_state_estim.jl‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,10 @@ end
15581558
preparestate!(mhe, [0], [0])
15591559
info = getinfo(mhe)
15601560
@test info[:x̂] ≈ x̂ atol=1e-5
1561+
@test info[:xhat] ≈ x̂ atol=1e-5
15611562
@test info[:Ŷ][end] ≈ 0 atol=1e-5
1563+
@test info[:â] ≈ [0.0] atol=1e-5
1564+
@test info[:ahat] ≈ [0.0] atol=1e-5
15621565
for i in 1:40
15631566
preparestate!(mhe, [0], [0])
15641567
updatestate!(mhe, [3.0], [0], [0])

0 commit comments

Comments
 (0)