@@ -41,7 +41,8 @@ struct ExplicitMPC{
4141 Dop:: Vector{NT}
4242 buffer:: PredictiveControllerBuffer{NT}
4343 function ExplicitMPC {NT} (
44- estim:: SE , Hp, Hc, nb, weights:: CW
44+ estim:: SE , Hp, Hc, nb, weights:: CW ;
45+ warn_cond= 1e6
4546 ) where {NT<: Real , SE<: StateEstimator , CW<: ControllerWeights }
4647 model = estim. model
4748 nu, ny, nd, nx̂ = model. nu, model. ny, model. nd, estim. nx̂
@@ -57,7 +58,7 @@ struct ExplicitMPC{
5758 E, G, J, K, V, B = init_predmat (model, estim, transcription, Hp, Hc, nb)
5859 F = zeros (NT, ny* Hp) # dummy value (updated just before optimization)
5960 P̃Δu, P̃u, Ẽ = PΔu, Pu, E # no slack variable ϵ for ExplicitMPC
60- H̃ = init_quadprog (model, transcription, weights, Ẽ, P̃Δu, P̃u)
61+ H̃ = init_quadprog (model, transcription, weights, Ẽ, P̃Δu, P̃u; warn_cond )
6162 # dummy vals (updated just before optimization):
6263 q̃, r = zeros (NT, size (H̃, 1 )), zeros (NT, 1 )
6364 H̃_chol = cholesky (H̃)
@@ -142,10 +143,11 @@ function ExplicitMPC(
142143 M_Hp = Diagonal (repeat (Mwt, Hp)),
143144 N_Hc = Diagonal (repeat (Nwt, get_Hc (move_blocking (Hp, Hc)))),
144145 L_Hp = Diagonal (repeat (Lwt, Hp)),
146+ warn_cond= 1e6 ,
145147 kwargs...
146148)
147149 estim = SteadyKalmanFilter (model; kwargs... )
148- return ExplicitMPC (estim; Hp, Hc, Mwt, Nwt, Lwt, M_Hp, N_Hc, L_Hp)
150+ return ExplicitMPC (estim; Hp, Hc, Mwt, Nwt, Lwt, M_Hp, N_Hc, L_Hp, warn_cond )
149151end
150152
151153"""
@@ -165,29 +167,21 @@ function ExplicitMPC(
165167 M_Hp = Diagonal (repeat (Mwt, Hp)),
166168 N_Hc = Diagonal (repeat (Nwt, get_Hc (move_blocking (Hp, Hc)))),
167169 L_Hp = Diagonal (repeat (Lwt, Hp)),
170+ warn_cond= 1e6 ,
168171) where {NT<: Real , SE<: StateEstimator{NT} }
169172 isa (estim. model, LinModel) || error (MSG_LINMODEL_ERR)
170- nk = try
171- estimate_delays (estim. model)
172- catch myerr
173- NaN
174- end
175- if Hp ≤ nk
176- @warn (" prediction horizon Hp ($Hp ) ≤ estimated number of delays in model " *
177- " ($nk ), the closed-loop system may be unstable or zero-gain (unresponsive)" )
178- end
179- isnan (nk) && @warn (" could not estimate the model delay, Hp ($Hp ) might be too small." )
173+ verify_delays (estim. model, Hp)
180174 nb = move_blocking (Hp, Hc)
181175 Hc = get_Hc (nb)
182176 weights = ControllerWeights (estim. model, Hp, Hc, M_Hp, N_Hc, L_Hp)
183- return ExplicitMPC {NT} (estim, Hp, Hc, nb, weights)
177+ return ExplicitMPC {NT} (estim, Hp, Hc, nb, weights; warn_cond )
184178end
185179
186180setconstraint! (:: ExplicitMPC ; kwargs... ) = error (" ExplicitMPC does not support constraints." )
187181
188182function Base. show (io:: IO , mpc:: ExplicitMPC )
189183 estim, model = mpc. estim, mpc. estim. model
190- Hp, Hc, nϵ = mpc. Hp, mpc. Hc, mpc . nϵ
184+ Hp, Hc = mpc. Hp, mpc. Hc
191185 nu, nd = model. nu, model. nd
192186 nx̂, nym, nyu = estim. nx̂, estim. nym, estim. nyu
193187 n = maximum (ndigits .((Hp, Hc, nu, nx̂, nym, nyu, nd))) + 1
0 commit comments