@@ -126,10 +126,7 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
126
126
U, Ŷ = Ū, Ȳ
127
127
U .= mul! (U, mpc. S̃, mpc. ΔŨ) .+ mpc. T_lastu
128
128
Ŷ .= Ŷ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)
133
130
info[:ΔU ] = mpc. ΔŨ[1 : mpc. Hc* model. nu]
134
131
info[:ϵ ] = mpc. nϵ == 1 ? mpc. ΔŨ[end ] : zero (NT)
135
132
info[:J ] = J
@@ -231,7 +228,7 @@ function initpred!(mpc::PredictiveController, model::SimModel, d, D̂, R̂y, R̂
231
228
end
232
229
233
230
"""
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
235
232
236
233
Common computations of `initpred!` for all types of [`SimModel`](@ref).
237
234
@@ -251,23 +248,22 @@ function initpred_common!(mpc::PredictiveController, model::SimModel, d, D̂, R
251
248
end
252
249
mpc. R̂y .= R̂y
253
250
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
256
253
end
257
254
258
255
@doc raw """
259
- predictstoch!(mpc::PredictiveController, estim::InternalModel) -> F
256
+ predictstoch!(Ŷs, mpc::PredictiveController, estim::InternalModel) -> nothing
260
257
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).
262
259
"""
263
- function predictstoch! (mpc:: PredictiveController , estim:: InternalModel )
264
- Ŷs = mpc. F
260
+ function predictstoch! (Ŷs, mpc:: PredictiveController , estim:: InternalModel )
265
261
mul! (Ŷs, mpc. Ks, estim. x̂s)
266
262
mul! (Ŷs, mpc. Ps, estim. ŷs, 1 , 1 )
267
- return mpc . F
263
+ return nothing
268
264
end
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 )
271
267
272
268
@doc raw """
273
269
linconstraint!(mpc::PredictiveController, model::LinModel)
0 commit comments