@@ -131,6 +131,31 @@ N_k = \begin{cases}
131131 k + 1 & k < H_e \\
132132 H_e & k ≥ H_e \e nd{cases}
133133```
134+ See [`SteadyKalmanFilter`](@ref) for details on ``\m athbf{R̂}, \m athbf{Q̂}`` covariances and
135+ model augmentation.
136+
137+ # Arguments
138+ - `model::SimModel` : (deterministic) model for the estimations.
139+ - `He=nothing`: estimation horizon ``H_e``, must be specified.
140+ - `optim=JuMP.Model(Ipopt.Optimizer)` : nonlinear optimizer used in the moving horizon
141+ estimator, provided as a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/api/JuMP/#JuMP.Model)
142+ (default to [`Ipopt.jl`](https://github.com/jump-dev/Ipopt.jl) optimizer).
143+ - `<keyword arguments>` of [`SteadyKalmanFilter`](@ref) constructor.
144+ - `<keyword arguments>` of [`KalmanFilter`](@ref) constructor.
145+
146+ # Examples
147+ ```jldoctest
148+ julia> model = NonLinModel((x,u,_)->0.1x+u, (x,_)->2x, 10.0, 1, 1, 1);
149+
150+ julia> estim = MovingHorizonEstimator(model, He=5, σR=[1], σP0=[0.01])
151+ MovingHorizonEstimator estimator with a sample time Ts = 10.0 s, NonLinModel and:
152+ 5 estimation steps He
153+ 1 manipulated inputs u (0 integrating states)
154+ 2 states x̂
155+ 1 measured outputs ym (1 integrating states)
156+ 0 unmeasured outputs yu
157+ 0 measured disturbances d
158+ ```
134159"""
135160function MovingHorizonEstimator (
136161 model:: SM ;
@@ -157,6 +182,21 @@ function MovingHorizonEstimator(
157182 )
158183end
159184
185+ @doc raw """
186+ MovingHorizonEstimator(model, He, i_ym, nint_u, nint_ym, P̂0, Q̂, R̂, optim)
187+
188+ Construct the estimator from the augmented covariance matrices `P̂0`, `Q̂` and `R̂`.
189+
190+ This syntax allows nonzero off-diagonal elements in ``\m athbf{P̂}_{-1}(0), \m athbf{Q̂, R̂}``.
191+ """
192+ function MovingHorizonEstimator (
193+ model:: SM , He, i_ym, nint_u, nint_ym, P̂0, Q̂, R̂, optim
194+ ) where {NT<: Real , SM<: SimModel{NT} }
195+ return MovingHorizonEstimator {NT, SM} (
196+ model, He, i_ym, nint_u, nint_ym, P̂0, Q̂ , R̂, optim
197+ )
198+ end
199+
160200
161201"""
162202 init_optimization!(estim::MovingHorizonEstimator, optim::JuMP.GenericModel)
@@ -244,8 +284,6 @@ function init_optimization!(
244284 register (optim, sym, nvar, gfunc[i_end_X̂min+ i], autodiff= true )
245285 end
246286 end
247- # TODO : moved this call to setconstraint! when the function will handle MHE
248- setnonlincon! (estim, estim. model)
249287 return nothing
250288end
251289
@@ -464,6 +502,13 @@ function obj_nonlinprog(
464502 return dot (x̄0, invP̄, x̄0) + dot (Ŵ, invQ̂_Nk, Ŵ) + dot (V̂, invR̂_Nk, V̂)
465503end
466504
505+ """
506+ predict!(Ŷm, X̂, estim::MovingHorizonEstimator, model::SimModel, W̃) -> Ŷm, X̂
507+
508+ Compute the predicted measured outputs `Ŷm` and states `X̂` for the `MovingHorizonEstimator`.
509+
510+ The method mutates `Ŷm` and `X̂` vector arguments.
511+ """
467512function predict! (
468513 Ŷm, X̂, estim:: MovingHorizonEstimator , model:: SimModel , W̃:: Vector{T}
469514) where {T<: Real }
@@ -480,6 +525,11 @@ function predict!(
480525 return Ŷm, X̂
481526end
482527
528+ """
529+ con_nonlinprog!(g, estim::MovingHorizonEstimator, model::SimModel, X̂)
530+
531+ Nonlinear constrains for [`MovingHorizonEstimator`](@ref).
532+ """
483533function con_nonlinprog! (g, estim:: MovingHorizonEstimator , :: SimModel , X̂)
484534 nX̂con, nX̂ = length (estim. X̂min), estim. Nk[]* estim. nx̂
485535 for i in eachindex (g)
0 commit comments