@@ -126,10 +126,7 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
126126 U, Ŷ = Ū, Ȳ
127127 U .= mul! (U, mpc. S̃, mpc. ΔŨ) .+ mpc. T_lastu
128128 Ŷ .= Ŷ0 .+ mpc. Yop
129- oldF = copy (mpc. F)
130- F = predictstoch! (mpc, mpc. estim)
131- Ŷs .= F # predictstoch! init mpc.F with Ŷs value if estim is an InternalModel
132- F .= oldF # restore old F value
129+ predictstoch! (Ŷs, mpc, mpc. estim)
133130 info[:ΔU ] = mpc. ΔŨ[1 : mpc. Hc* model. nu]
134131 info[:ϵ ] = mpc. nϵ == 1 ? mpc. ΔŨ[end ] : zero (NT)
135132 info[:J ] = J
@@ -231,7 +228,7 @@ function initpred!(mpc::PredictiveController, model::SimModel, d, D̂, R̂y, R̂
231228end
232229
233230"""
234- initpred_common!(mpc::PredictiveController, model::SimModel, d, D̂, R̂y, R̂u) -> F
231+ initpred_common!(mpc::PredictiveController, model::SimModel, d, D̂, R̂y, R̂u) -> mpc. F
235232
236233Common computations of `initpred!` for all types of [`SimModel`](@ref).
237234
@@ -251,23 +248,22 @@ function initpred_common!(mpc::PredictiveController, model::SimModel, d, D̂, R
251248 end
252249 mpc. R̂y .= R̂y
253250 mpc. R̂u .= R̂u
254- F = predictstoch! (mpc, mpc. estim) # init mpc.F with Ŷs for InternalModel
255- return F
251+ predictstoch! (mpc. F , mpc, mpc. estim)
252+ return mpc . F
256253end
257254
258255@doc raw """
259- predictstoch!(mpc::PredictiveController, estim::InternalModel) -> F
256+ predictstoch!(Ŷs, mpc::PredictiveController, estim::InternalModel) -> nothing
260257
261- Init `mpc.F` vector with `` \m athbf{F = Ŷ_s}`` when `estim` is an [`InternalModel`](@ref).
258+ Fill `Ŷs` in-place with stochastic predictions if `estim` is an [`InternalModel`](@ref).
262259"""
263- function predictstoch! (mpc:: PredictiveController , estim:: InternalModel )
264- Ŷs = mpc. F
260+ function predictstoch! (Ŷs, mpc:: PredictiveController , estim:: InternalModel )
265261 mul! (Ŷs, mpc. Ks, estim. x̂s)
266262 mul! (Ŷs, mpc. Ps, estim. ŷs, 1 , 1 )
267- return mpc . F
263+ return nothing
268264end
269- " Separate stochastic predictions are not needed if `estim` is not [`InternalModel`](@ref)."
270- predictstoch! (mpc:: PredictiveController , :: StateEstimator ) = (mpc . F .= 0 )
265+ " Fill `Ŷs` vector with 0 values when `estim` is not an [`InternalModel`](@ref)."
266+ predictstoch! (Ŷs, mpc:: PredictiveController , :: StateEstimator ) = (Ŷs .= 0 ; nothing )
271267
272268@doc raw """
273269 linconstraint!(mpc::PredictiveController, model::LinModel)
0 commit comments