Skip to content

Commit 8f358e0

Browse files
committed
views for d in predict! for MPC
1 parent 29d3469 commit 8f358e0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/predictive_control.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,15 +645,15 @@ Compute both vectors if `model` is not a [`LinModel`](@ref).
645645
"""
646646
function predict!(Ŷ, x̂, mpc::PredictiveController, model::SimModel, ΔŨ::Vector{NT}) where {NT<:Real}
647647
nu, ny, nd, Hp, Hc = model.nu, model.ny, model.nd, mpc.Hp, mpc.Hc
648-
u0::Vector{NT} = copy(mpc.estim.lastu0)
649-
d0::Vector{NT} = copy(mpc.d0)
650648
x̂[:] = mpc.estim.
649+
u0::Vector{NT} = copy(mpc.estim.lastu0)
650+
d0 = @views mpc.d0[1:end]
651651
for j=1:Hp
652652
if j Hc
653653
u0[:] = u0 + ΔŨ[(1 + nu*(j-1)):(nu*j)]
654654
end
655655
x̂[:] = (mpc.estim, model, x̂, u0, d0)
656-
d0[:] = mpc.D̂0[(1 + nd*(j-1)):(nd*j)]
656+
d0 = @views mpc.D̂0[(1 + nd*(j-1)):(nd*j)]
657657
Ŷ[(1 + ny*(j-1)):(ny*j)] = (mpc.estim, model, x̂, d0)
658658
end
659659
Ŷ[:] =+ mpc.Ŷop # Ŷop = Ŷs + Yop, and Ŷs=0 if mpc.estim is not an InternalModel

0 commit comments

Comments
 (0)