@@ -328,13 +328,18 @@ Set the estimate at `mpc.estim.x̂`.
328328"""
329329setstate! (mpc:: PredictiveController , x̂) = (setstate! (mpc. estim, x̂); return mpc)
330330
331- """
331+ @doc raw """
332332 initstate!(mpc::PredictiveController, u, ym, d=Float64[])
333333
334334Init `mpc.ΔŨ` for warm-starting and the states of `mpc.estim` [`StateEstimator`](@ref).
335+
336+ Before calling [`initstate!(::StateEstimator,::Any,::Any,::Any)`](@ref), it warm-starts ``\m athbf{ΔŨ}``:
337+ - If `model` is a [`LinModel`], the vector is filled with the analytical minimum ``J`` of
338+ the unconstrained problem.
339+ - Else, the vector is filled with zeros.
335340"""
336341function initstate! (mpc:: PredictiveController , u, ym, d= Float64[])
337- mpc. ΔŨ . = 0
342+ mpc. ΔŨ[:] = unconstrained_solution (mpc, mpc . estim . model)
338343 return initstate! (mpc. estim, u, ym, d)
339344end
340345
730735" Return the quadratic programming objective function, see [`init_quadprog`](@ref)."
731736obj_quadprog (ΔŨ, P̃, q̃) = 0.5 * ΔŨ' * P̃* ΔŨ + q̃' * ΔŨ
732737
738+
739+ " Calc the analytical unconstrained minimum of ``J`` for [`LinModel`](@ref)."
740+ unconstrained_solution (mpc:: PredictiveController , model:: LinModel ) = - mpc. P̃\ mpc. q̃
741+
742+ " When model is not a `LinModel`(@ref), returns a null vector ``\\ mathbf{0}``."
743+ unconstrained_solution (mpc:: PredictiveController , :: SimModel ) = zeros (size (mpc. ΔŨ))
744+
733745"""
734746 init_defaultcon(model, C, S_Hp, S_Hc, N_Hc, E) -> con, S̃_Hp, Ñ_Hc, Ẽ
735747
@@ -1024,6 +1036,9 @@ function isfatal(status::TerminationStatusCode)
10241036 return any (status .== fatalstatuses)
10251037end
10261038
1039+
1040+
1041+
10271042" Functor allowing callable `PredictiveController` object as an alias for `moveinput!`."
10281043function (mpc:: PredictiveController )(
10291044 ry:: Vector = mpc. estim. model. yop,
0 commit comments