@@ -251,8 +251,8 @@ function moveinput!(
251251 ym:: Union{Vector{<:Real}, Nothing} = nothing
252252)
253253 getestimates! (mpc, mpc. estim, ym, d)
254- ŷs, Ŷs = predictstoch! (mpc, mpc. estim, d, ym)
255- p = initpred! (mpc, mpc. estim. model, d, D̂, Ŷs, R̂y)
254+ predictstoch! (mpc, mpc. estim, d, ym)
255+ p = initpred! (mpc, mpc. estim. model, d, D̂, R̂y)
256256 linconstraint! (mpc, mpc. estim. model)
257257 ΔŨ, _ = optim_objective! (mpc, p)
258258 Δu = ΔŨ[1 : mpc. estim. model. nu] # receding horizon principle: only Δu(k) is used (1st one)
@@ -316,11 +316,14 @@ end
316316"""
317317 predictstoch!(mpc, estim::StateEstimator, x̂s, d, _ )
318318
319- Predict the current `ŷs` and future `Ŷs` stochastic model outputs over `Hp`.
319+ Predict the future `Ŷs` stochastic model outputs over `Hp`.
320320
321321See [`init_stochpred`](@ref) for details on `Ŷs` and `Ks` matrices.
322322"""
323- predictstoch! (mpc, estim:: StateEstimator , _ , _ ) = (estim. Cs* mpc. x̂s, mpc. Ks* mpc. x̂s)
323+ function predictstoch! (mpc, estim:: StateEstimator , _ , _ )
324+ mpc. Ŷs[:] = mpc. Ks* mpc. x̂s
325+ return mpc. Ŷs
326+ end
324327
325328"""
326329 predictstoch!(mpc, estim::InternalModel, x̂s, d, ym )
@@ -331,8 +334,8 @@ function predictstoch!(mpc, estim::InternalModel, d, ym )
331334 ŷd = h (estim. model, mpc. x̂d, d - estim. model. dop) + estim. model. yop
332335 ŷs = zeros (estim. model. ny)
333336 ŷs[estim. i_ym] = ym - ŷd[estim. i_ym] # ŷs=0 for unmeasured outputs
334- Ŷs = mpc. Ks* mpc. x̂s + mpc. Ps* ŷs
335- return ŷs, Ŷs
337+ mpc . Ŷs[:] = mpc. Ks* mpc. x̂s + mpc. Ps* ŷs
338+ return mpc . Ŷs
336339end
337340
338341
@@ -343,8 +346,8 @@ Init linear model prediction matrices `F`, `q̃` and `p`.
343346
344347See [`init_deterpred`](@ref) and [`init_quadprog`](@ref) for the definition of the matrices.
345348"""
346- function initpred! (mpc:: PredictiveController , model:: LinModel , d, D̂, Ŷs, R̂y)
347- mpc. F[:] = mpc. Kd* mpc. x̂d + mpc. Q* mpc. estim. lastu0 + Ŷs + mpc. Yop
349+ function initpred! (mpc:: PredictiveController , model:: LinModel , d, D̂, R̂y)
350+ mpc. F[:] = mpc. Kd* mpc. x̂d + mpc. Q* mpc. estim. lastu0 + mpc . Ŷs + mpc. Yop
348351 if model. nd ≠ 0
349352 mpc. d0[:], mpc. D̂0[:] = d - model. dop, D̂ - mpc. Dop
350353 mpc. F[:] = mpc. F + mpc. G* mpc. d0 + mpc. J* mpc. D̂0
@@ -365,15 +368,12 @@ end
365368@doc raw """
366369 initpred!(mpc::PredictiveController, model::SimModel, d, D̂, Ŷs, R̂y )
367370
368- Init `F`, ` d0` and `D̂0` prediction matrices when model is not a [`LinModel`](@ref).
371+ Init `d0` and `D̂0` prediction matrices when model is not a [`LinModel`](@ref).
369372
370- In such a case, the constant matrix is ``\m athbf{F = Ŷ_s + Y_{op}}``, thus it
371- incorporates the stochastic predictions and the output operating point ``\m athbf{y_{op}}``
372- repeated over ``H_p``. `d0` and `D̂0` are the measured disturbances and its predictions
373- without the operating points ``\m athbf{d_{op}}``.
373+ `d0` and `D̂0` are the measured disturbances and its predictions without the operating points
374+ ``\m athbf{d_{op}}``.
374375"""
375- function initpred! (mpc:: PredictiveController , model:: SimModel , d, D̂, Ŷs , R̂y )
376- mpc. F[:] = Ŷs + mpc. Yop
376+ function initpred! (mpc:: PredictiveController , model:: SimModel , d, D̂, R̂y)
377377 if model. nd ≠ 0
378378 mpc. d0[:], mpc. D̂0[:] = d - model. dop, D̂ - mpc. Dop
379379 end
@@ -600,7 +600,7 @@ function init_deterpred(model::SimModel, Hp, Hc)
600600 J = zeros (0 , nd* Hp)
601601 Kd = zeros (0 , nx)
602602 Q = zeros (0 , nu)
603- F = zeros (ny * Hp) # dummy value (updated just before optimization )
603+ F = zeros (0 )
604604 return E, F, G, J, Kd, Q
605605end
606606
0 commit comments