Skip to content

Commit 5339531

Browse files
committed
changed: conversion matrices with lower case 'u' for readability
1 parent e6ba1ef commit 5339531

File tree

6 files changed

+103
-103
lines changed

6 files changed

+103
-103
lines changed

src/controller/construct.jl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct PredictiveControllerBuffer{NT<:Real}
55
::Vector{NT}
66
U ::Vector{NT}
77
::Matrix{NT}
8-
P̃U::Matrix{NT}
8+
P̃u::Matrix{NT}
99
empty::Vector{NT}
1010
end
1111

@@ -27,9 +27,9 @@ function PredictiveControllerBuffer(
2727
= Vector{NT}(undef, ny*Hp)
2828
U = Vector{NT}(undef, nu*Hp)
2929
= Matrix{NT}(undef, ny*Hp, nZ̃)
30-
P̃U = Matrix{NT}(undef, nu*Hp, nZ̃)
30+
P̃u = Matrix{NT}(undef, nu*Hp, nZ̃)
3131
empty = Vector{NT}(undef, 0)
32-
return PredictiveControllerBuffer{NT}(u, Z̃, D̂, Ŷ, U, Ẽ, P̃U, empty)
32+
return PredictiveControllerBuffer{NT}(u, Z̃, D̂, Ŷ, U, Ẽ, P̃u, empty)
3333
end
3434

3535
"Include all the objective function weights of [`PredictiveController`](@ref)"
@@ -526,7 +526,7 @@ function validate_args(mpc::PredictiveController, ry, d, D̂, R̂y, R̂u)
526526
end
527527

528528
@doc raw"""
529-
init_quadprog(model::LinModel, weights::ControllerWeights, Ẽ, P̃ΔU, P̃U) -> H̃
529+
init_quadprog(model::LinModel, weights::ControllerWeights, Ẽ, P̃Δu, P̃u) -> H̃
530530
531531
Init the quadratic programming Hessian `H̃` for MPC.
532532
@@ -537,16 +537,16 @@ The matrix appear in the quadratic general form:
537537
The Hessian matrix is constant if the model and weights are linear and time invariant (LTI):
538538
```math
539539
\mathbf{H̃} = 2 ( \mathbf{Ẽ}' \mathbf{M}_{H_p} \mathbf{Ẽ}
540-
+ \mathbf{P̃_{ΔU}}' \mathbf{Ñ}_{H_c} \mathbf{P̃_{ΔU}}
541-
+ \mathbf{P̃_{U}}' \mathbf{L}_{H_p} \mathbf{P̃_{U}} )
540+
+ \mathbf{P̃_{Δu}}' \mathbf{Ñ}_{H_c} \mathbf{P̃_{Δu}}
541+
+ \mathbf{P̃_{u}}' \mathbf{L}_{H_p} \mathbf{P̃_{u}} )
542542
```
543543
The vector ``\mathbf{q̃}`` and scalar ``r`` need recalculation each control period ``k``, see
544544
[`initpred!`](@ref). ``r`` does not impact the minima position. It is thus useless at
545545
optimization but required to evaluate the minimal ``J`` value.
546546
"""
547-
function init_quadprog(::LinModel, weights::ControllerWeights, Ẽ, P̃ΔU, P̃U)
547+
function init_quadprog(::LinModel, weights::ControllerWeights, Ẽ, P̃Δu, P̃u)
548548
M_Hp, Ñ_Hc, L_Hp = weights.M_Hp, weights.Ñ_Hc, weights.L_Hp
549-
= Hermitian(2*(Ẽ'*M_Hp*+ P̃ΔU'*Ñ_Hc*P̃ΔU + P̃U'*L_Hp*P̃U), :L)
549+
= Hermitian(2*(Ẽ'*M_Hp*+ P̃Δu'*Ñ_Hc*P̃Δu + P̃u'*L_Hp*P̃u), :L)
550550
return
551551
end
552552
"Return empty matrix if `model` is not a [`LinModel`](@ref)."
@@ -559,20 +559,20 @@ end
559559
init_defaultcon_mpc(
560560
estim::StateEstimator, transcription::TranscriptionMethod,
561561
Hp, Hc, C,
562-
PΔU, PU, E,
562+
PΔu, Pu, E,
563563
ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
564564
Eŝ, Fŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ,
565565
gc!=nothing, nc=0
566-
) -> con, nϵ, P̃ΔU, P̃U, Ẽ, Ẽŝ
566+
) -> con, nϵ, P̃Δu, P̃u, Ẽ, Ẽŝ
567567
568568
Init `ControllerConstraint` struct with default parameters based on estimator `estim`.
569569
570-
Also return `P̃ΔU`, `P̃U`, `Ẽ` and `Ẽŝ` matrices for the the augmented decision vector `Z̃`.
570+
Also return `P̃Δu`, `P̃u`, `Ẽ` and `Ẽŝ` matrices for the the augmented decision vector `Z̃`.
571571
"""
572572
function init_defaultcon_mpc(
573573
estim::StateEstimator{NT}, transcription::TranscriptionMethod,
574574
Hp, Hc, C,
575-
PΔU, PU, E,
575+
PΔu, Pu, E,
576576
ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
577577
Eŝ, Fŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ,
578578
gc!::GCfunc = nothing, nc = 0
@@ -592,8 +592,8 @@ function init_defaultcon_mpc(
592592
repeat_constraints(Hp, Hc, u0min, u0max, Δumin, Δumax, y0min, y0max)
593593
C_umin, C_umax, C_Δumin, C_Δumax, C_ymin, C_ymax =
594594
repeat_constraints(Hp, Hc, c_umin, c_umax, c_Δumin, c_Δumax, c_ymin, c_ymax)
595-
A_Umin, A_Umax, P̃U = relaxU(PU, C_umin, C_umax, nϵ)
596-
A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃ΔU = relaxΔU(PΔU, C_Δumin, C_Δumax, ΔUmin, ΔUmax, nϵ)
595+
A_Umin, A_Umax, P̃u = relaxU(Pu, C_umin, C_umax, nϵ)
596+
A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃Δu = relaxΔU(PΔu, C_Δumin, C_Δumax, ΔUmin, ΔUmax, nϵ)
597597
A_Ymin, A_Ymax, Ẽ = relaxŶ(E, C_ymin, C_ymax, nϵ)
598598
A_x̂min, A_x̂max, ẽx̂ = relaxterminal(ex̂, c_x̂min, c_x̂max, nϵ)
599599
A_ŝ, Ẽŝ = augmentdefect(Eŝ, nϵ)
@@ -620,7 +620,7 @@ function init_defaultcon_mpc(
620620
C_ymin , C_ymax , c_x̂min , c_x̂max , i_g,
621621
gc! , nc
622622
)
623-
return con, nϵ, P̃ΔU, P̃U, Ẽ, Ẽŝ
623+
return con, nϵ, P̃Δu, P̃u, Ẽ, Ẽŝ
624624
end
625625

626626
"Repeat predictive controller constraints over prediction `Hp` and control `Hc` horizons."
@@ -635,13 +635,13 @@ function repeat_constraints(Hp, Hc, umin, umax, Δumin, Δumax, ymin, ymax)
635635
end
636636

637637
@doc raw"""
638-
relaxU(PU, C_umin, C_umax, nϵ) -> A_Umin, A_Umax, P̃U
638+
relaxU(Pu, C_umin, C_umax, nϵ) -> A_Umin, A_Umax, P̃u
639639
640640
Augment manipulated inputs constraints with slack variable ϵ for softening.
641641
642642
Denoting the decision variables augmented with the slack variable
643643
``\mathbf{Z̃} = [\begin{smallmatrix} \mathbf{Z} \\ ϵ \end{smallmatrix}]``, it returns the
644-
augmented conversion matrix ``\mathbf{P̃U}``, similar to the one described at
644+
augmented conversion matrix ``\mathbf{P̃u}``, similar to the one described at
645645
[`init_ZtoU`](@ref). It also returns the ``\mathbf{A}`` matrices for the inequality
646646
constraints:
647647
```math
@@ -650,36 +650,36 @@ constraints:
650650
\mathbf{A_{U_{max}}}
651651
\end{bmatrix} \mathbf{Z̃} ≤
652652
\begin{bmatrix}
653-
- \mathbf{U_{min} + T_U u}(k-1) \\
654-
+ \mathbf{U_{max} - T_U u}(k-1)
653+
- \mathbf{U_{min} + T_u u}(k-1) \\
654+
+ \mathbf{U_{max} - T_u u}(k-1)
655655
\end{bmatrix}
656656
```
657657
in which ``\mathbf{U_{min}}`` and ``\mathbf{U_{max}}`` vectors respectively contains
658658
``\mathbf{u_{min}}`` and ``\mathbf{u_{max}}`` repeated ``H_p`` times.
659659
"""
660-
function relaxU(PU::Matrix{NT}, C_umin, C_umax, nϵ) where NT<:Real
660+
function relaxU(Pu::Matrix{NT}, C_umin, C_umax, nϵ) where NT<:Real
661661
if== 1 # Z̃ = [Z; ϵ]
662662
# ϵ impacts Z → U conversion for constraint calculations:
663-
A_Umin, A_Umax = -[PU C_umin], [PU -C_umax]
663+
A_Umin, A_Umax = -[Pu C_umin], [Pu -C_umax]
664664
# ϵ has no impact on Z → U conversion for prediction calculations:
665-
P̃U = [PU zeros(NT, size(PU, 1))]
665+
P̃u = [Pu zeros(NT, size(Pu, 1))]
666666
else # Z̃ = Z (only hard constraints)
667-
A_Umin, A_Umax = -PU, PU
668-
P̃U = PU
667+
A_Umin, A_Umax = -Pu, Pu
668+
P̃u = Pu
669669
end
670-
return A_Umin, A_Umax, P̃U
670+
return A_Umin, A_Umax, P̃u
671671
end
672672

673673
@doc raw"""
674-
relaxΔU(PΔU, C_Δumin, C_Δumax, ΔUmin, ΔUmax, nϵ) -> A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃ΔU
674+
relaxΔU(PΔu, C_Δumin, C_Δumax, ΔUmin, ΔUmax, nϵ) -> A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃Δu
675675
676676
Augment input increments constraints with slack variable ϵ for softening.
677677
678678
Denoting the decision variables augmented with the slack variable
679679
``\mathbf{Z̃} = [\begin{smallmatrix} \mathbf{Z} \\ ϵ \end{smallmatrix}]``, it returns the
680-
augmented conversion matrix ``\mathbf{P̃_{ΔU}}``, similar to the one described at
680+
augmented conversion matrix ``\mathbf{P̃_{Δu}}``, similar to the one described at
681681
[`init_ZtoΔU`](@ref), but extracting the input increments augmented with the slack variable
682-
``\mathbf{ΔŨ} = [\begin{smallmatrix} \mathbf{ΔU} \\ ϵ \end{smallmatrix}] = \mathbf{P̃_{ΔU} Z̃}``.
682+
``\mathbf{ΔŨ} = [\begin{smallmatrix} \mathbf{ΔU} \\ ϵ \end{smallmatrix}] = \mathbf{P̃_{Δu} Z̃}``.
683683
Also, knowing that ``0 ≤ ϵ ≤ ∞``, it also returns the augmented bounds
684684
``\mathbf{ΔŨ_{min}} = [\begin{smallmatrix} \mathbf{ΔU_{min}} \\ 0 \end{smallmatrix}]`` and
685685
``\mathbf{ΔŨ_{max}} = [\begin{smallmatrix} \mathbf{ΔU_{min}} \\\end{smallmatrix}]``,
@@ -699,19 +699,19 @@ bound, which is more precise than a linear inequality constraint. However, it is
699699
convenient to treat it as a linear inequality constraint since the optimizer `OSQP.jl` does
700700
not support pure bounds on the decision variables.
701701
"""
702-
function relaxΔU(PΔU::Matrix{NT}, C_Δumin, C_Δumax, ΔUmin, ΔUmax, nϵ) where NT<:Real
703-
nZ = size(PΔU, 2)
702+
function relaxΔU(PΔu::Matrix{NT}, C_Δumin, C_Δumax, ΔUmin, ΔUmax, nϵ) where NT<:Real
703+
nZ = size(PΔu, 2)
704704
if== 1 # Z̃ = [Z; ϵ]
705705
ΔŨmin, ΔŨmax = [ΔUmin; NT[0.0]], [ΔUmax; NT[Inf]] # 0 ≤ ϵ ≤ ∞
706706
A_ϵ = [zeros(NT, 1, nZ) NT[1.0]]
707-
A_ΔŨmin, A_ΔŨmax = -[PΔU C_Δumin; A_ϵ], [PΔU -C_Δumax; A_ϵ]
708-
P̃ΔU = [PΔU zeros(NT, size(PΔU, 1), 1); zeros(NT, 1, size(PΔU, 2)) NT[1.0]]
707+
A_ΔŨmin, A_ΔŨmax = -[PΔu C_Δumin; A_ϵ], [PΔu -C_Δumax; A_ϵ]
708+
P̃Δu = [PΔu zeros(NT, size(PΔu, 1), 1); zeros(NT, 1, size(PΔu, 2)) NT[1.0]]
709709
else # Z̃ = Z (only hard constraints)
710710
ΔŨmin, ΔŨmax = ΔUmin, ΔUmax
711-
A_ΔŨmin, A_ΔŨmax = -PΔU, PΔU
712-
P̃ΔU = PΔU
711+
A_ΔŨmin, A_ΔŨmax = -PΔu, PΔu
712+
P̃Δu = PΔu
713713
end
714-
return A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃ΔU
714+
return A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃Δu
715715
end
716716

717717
@doc raw"""

src/controller/execute.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function getinfo(mpc::PredictiveController{NT}) where NT<:Real
128128
ΔŨ, Ŷe, Ue = nonlinprog_vectors!(ΔŨ, Ŷe, Ue, Ū, mpc, Ŷ0, Z̃)
129129
J = obj_nonlinprog!(Ȳ, Ū, mpc, model, Ue, Ŷe, ΔŨ, Z̃)
130130
U, Ŷ = Ū, Ȳ
131-
U .= mul!(U, mpc.P̃U, mpc.Z̃) .+ mpc.TU_lastu
131+
U .= mul!(U, mpc.P̃u, mpc.Z̃) .+ mpc.Tu_lastu
132132
Ŷ .= Ŷ0 .+ mpc.Yop
133133
predictstoch!(Ŷs, mpc, mpc.estim)
134134
info[:ΔU] = Z̃[1:mpc.Hc*model.nu]
@@ -197,7 +197,7 @@ function initpred!(mpc::PredictiveController, model::LinModel, d, D̂, R̂y, R̂
197197
mul!(F, mpc.G, mpc.d0, 1, 1) # F = F + G*d0
198198
mul!(F, mpc.J, mpc.D̂0, 1, 1) # F = F + J*D̂0
199199
end
200-
Cy, Cu, M_Hp_Ẽ, L_Hp_P̃U = mpc.buffer.Ŷ, mpc.buffer.U, mpc.buffer.Ẽ, mpc.buffer.P̃U
200+
Cy, Cu, M_Hp_Ẽ, L_Hp_P̃U = mpc.buffer.Ŷ, mpc.buffer.U, mpc.buffer.Ẽ, mpc.buffer.P̃u
201201
q̃, r = mpc.q̃, mpc.r
202202
q̃ .= 0
203203
r .= 0
@@ -210,9 +210,9 @@ function initpred!(mpc::PredictiveController, model::LinModel, d, D̂, R̂y, R̂
210210
end
211211
# --- input setpoint tracking term ---
212212
if !mpc.weights.iszero_L_Hp[]
213-
Cu .= mpc.TU_lastu .- R̂u
214-
mul!(L_Hp_P̃U, mpc.weights.L_Hp, mpc.P̃U)
215-
mul!(q̃, L_Hp_P̃U', Cu, 1, 1) # q̃ = q̃ + L_Hp*P̃U'*Cu
213+
Cu .= mpc.Tu_lastu .- R̂u
214+
mul!(L_Hp_P̃U, mpc.weights.L_Hp, mpc.P̃u)
215+
mul!(q̃, L_Hp_P̃U', Cu, 1, 1) # q̃ = q̃ + L_Hp*P̃u'*Cu
216216
r .+= dot(Cu, mpc.weights.L_Hp, Cu) # r = r + Cu'*L_Hp*Cu
217217
end
218218
# --- finalize ---
@@ -241,7 +241,7 @@ is an [`InternalModel`](@ref). The function returns `mpc.F`.
241241
function initpred_common!(mpc::PredictiveController, model::SimModel, d, D̂, R̂y, R̂u)
242242
lastu = mpc.buffer.u
243243
lastu .= mpc.estim.lastu0 .+ model.uop
244-
mul!(mpc.TU_lastu, mpc.TU, lastu)
244+
mul!(mpc.Tu_lastu, mpc.Tu, lastu)
245245
mpc.ŷ .= evaloutput(mpc.estim, d)
246246
if model.nd 0
247247
mpc.d0 .= d .- model.dop
@@ -288,9 +288,9 @@ function linconstraint!(mpc::PredictiveController, model::LinModel)
288288
mul!(fx̂, mpc.con.jx̂, mpc.D̂0, 1, 1)
289289
end
290290
n = 0
291-
mpc.con.b[(n+1):(n+nU)] .= @. -mpc.con.U0min - mpc.Uop + mpc.TU_lastu
291+
mpc.con.b[(n+1):(n+nU)] .= @. -mpc.con.U0min - mpc.Uop + mpc.Tu_lastu
292292
n += nU
293-
mpc.con.b[(n+1):(n+nU)] .= @. +mpc.con.U0max + mpc.Uop - mpc.TU_lastu
293+
mpc.con.b[(n+1):(n+nU)] .= @. +mpc.con.U0max + mpc.Uop - mpc.Tu_lastu
294294
n += nU
295295
mpc.con.b[(n+1):(n+nΔŨ)] .= @. -mpc.con.ΔŨmin
296296
n += nΔŨ
@@ -314,9 +314,9 @@ end
314314
function linconstraint!(mpc::PredictiveController, ::SimModel)
315315
nU, nΔŨ = length(mpc.con.U0min), length(mpc.con.ΔŨmin)
316316
n = 0
317-
mpc.con.b[(n+1):(n+nU)] .= @. -mpc.con.U0min - mpc.Uop + mpc.TU_lastu
317+
mpc.con.b[(n+1):(n+nU)] .= @. -mpc.con.U0min - mpc.Uop + mpc.Tu_lastu
318318
n += nU
319-
mpc.con.b[(n+1):(n+nU)] .= @. +mpc.con.U0max + mpc.Uop - mpc.TU_lastu
319+
mpc.con.b[(n+1):(n+nU)] .= @. +mpc.con.U0max + mpc.Uop - mpc.Tu_lastu
320320
n += nU
321321
mpc.con.b[(n+1):(n+nΔŨ)] .= @. -mpc.con.ΔŨmin
322322
n += nΔŨ
@@ -351,7 +351,7 @@ function nonlinprog_vectors!(ΔŨ, Ŷe, Ue, Ū, mpc::PredictiveController, Y
351351
nocustomfcts = (mpc.weights.iszero_E && iszero_nc(mpc))
352352
# --- augmented input increments ΔŨ = [ΔU; ϵ] ---
353353
if !(mpc.weights.iszero_Ñ_Hc[])
354-
ΔŨ .= mul!(ΔŨ, mpc.P̃ΔU, Z̃)
354+
ΔŨ .= mul!(ΔŨ, mpc.P̃Δu, Z̃)
355355
end
356356
# --- extended output predictions Ŷe = [ŷ(k); Ŷ] ---
357357
if !(mpc.weights.iszero_M_Hp[] && nocustomfcts)
@@ -361,7 +361,7 @@ function nonlinprog_vectors!(ΔŨ, Ŷe, Ue, Ū, mpc::PredictiveController, Y
361361
# --- extended manipulated inputs Ue = [U; u(k+Hp-1)] ---
362362
if !(mpc.weights.iszero_L_Hp[] && nocustomfcts)
363363
U =
364-
U .= mul!(U, mpc.P̃U, Z̃) .+ mpc.TU_lastu
364+
U .= mul!(U, mpc.P̃u, Z̃) .+ mpc.Tu_lastu
365365
Ue[1:end-nu] .= U
366366
# u(k + Hp) = u(k + Hp - 1) since Δu(k+Hp) = 0 (because Hc ≤ Hp):
367367
Ue[end-nu+1:end] .= @views U[end-nu+1:end]
@@ -719,7 +719,7 @@ function setmodel_controller!(mpc::PredictiveController, x̂op_old)
719719
JuMP.unregister(optim, :linconstrainteq)
720720
@constraint(optim, linconstrainteq, Aeq*Z̃var .== beq)
721721
# --- quadratic programming Hessian matrix ---
722-
= init_quadprog(model, mpc.weights, mpc.Ẽ, mpc.P̃ΔU, mpc.P̃U)
722+
= init_quadprog(model, mpc.weights, mpc.Ẽ, mpc.P̃Δu, mpc.P̃u)
723723
mpc.H̃ .=
724724
set_objective_hessian!(mpc, Z̃var)
725725
return nothing

src/controller/explicitmpc.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ struct ExplicitMPC{NT<:Real, SE<:StateEstimator} <: PredictiveController{NT}
99
weights::ControllerWeights{NT}
1010
R̂u::Vector{NT}
1111
R̂y::Vector{NT}
12-
P̃ΔU::Matrix{NT}
13-
P̃U ::Matrix{NT}
14-
TU ::Matrix{NT}
15-
TU_lastu::Vector{NT}
12+
P̃Δu::Matrix{NT}
13+
P̃u ::Matrix{NT}
14+
Tu ::Matrix{NT}
15+
Tu_lastu::Vector{NT}
1616
::Matrix{NT}
1717
F::Vector{NT}
1818
G::Matrix{NT}
@@ -46,15 +46,15 @@ struct ExplicitMPC{NT<:Real, SE<:StateEstimator} <: PredictiveController{NT}
4646
N_Hc = Hermitian(convert(Matrix{NT}, N_Hc), :L)
4747
L_Hp = Hermitian(convert(Matrix{NT}, L_Hp), :L)
4848
# dummy vals (updated just before optimization):
49-
R̂y, R̂u, TU_lastu = zeros(NT, ny*Hp), zeros(NT, nu*Hp), zeros(NT, nu*Hp)
49+
R̂y, R̂u, Tu_lastu = zeros(NT, ny*Hp), zeros(NT, nu*Hp), zeros(NT, nu*Hp)
5050
transcription = SingleShooting() # explicit MPC only supports SingleShooting
51-
PΔU = init_ZtoΔU(estim, transcription, Hp, Hc)
52-
PU, TU = init_ZtoU(estim, transcription, Hp, Hc)
51+
PΔu = init_ZtoΔU(estim, transcription, Hp, Hc)
52+
Pu, Tu = init_ZtoU(estim, transcription, Hp, Hc)
5353
E, G, J, K, V, B = init_predmat(model, estim, transcription, Hp, Hc)
5454
# dummy val (updated just before optimization):
5555
F, fx̂ = zeros(NT, ny*Hp), zeros(NT, nx̂)
56-
P̃ΔU, P̃U, Ñ_Hc, Ẽ = PΔU, PU, N_Hc, E # no slack variable ϵ for ExplicitMPC
57-
= init_quadprog(model, weights, Ẽ, P̃ΔU, P̃U)
56+
P̃Δu, P̃u, Ñ_Hc, Ẽ = PΔu, Pu, N_Hc, E # no slack variable ϵ for ExplicitMPC
57+
= init_quadprog(model, weights, Ẽ, P̃Δu, P̃u)
5858
# dummy vals (updated just before optimization):
5959
q̃, r = zeros(NT, size(H̃, 1)), zeros(NT, 1)
6060
H̃_chol = cholesky(H̃)
@@ -72,7 +72,7 @@ struct ExplicitMPC{NT<:Real, SE<:StateEstimator} <: PredictiveController{NT}
7272
Hp, Hc, nϵ,
7373
weights,
7474
R̂u, R̂y,
75-
P̃ΔU, P̃U, TU, TU_lastu,
75+
P̃Δu, P̃u, Tu, Tu_lastu,
7676
Ẽ, F, G, J, K, V, B,
7777
H̃, q̃, r,
7878
H̃_chol,
@@ -225,7 +225,7 @@ function setmodel_controller!(mpc::ExplicitMPC, _ )
225225
mpc.V .= V
226226
mpc.B .= B
227227
# --- quadratic programming Hessian matrix ---
228-
= init_quadprog(model, mpc.weights, mpc.Ẽ, mpc.P̃ΔU, mpc.P̃U)
228+
= init_quadprog(model, mpc.weights, mpc.Ẽ, mpc.P̃Δu, mpc.P̃u)
229229
mpc.H̃ .=
230230
set_objective_hessian!(mpc)
231231
# --- operating points ---

src/controller/linmpc.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ struct LinMPC{
2121
weights::ControllerWeights{NT}
2222
R̂u::Vector{NT}
2323
R̂y::Vector{NT}
24-
P̃ΔU::Matrix{NT}
25-
P̃U ::Matrix{NT}
26-
TU ::Matrix{NT}
27-
TU_lastu::Vector{NT}
24+
P̃Δu::Matrix{NT}
25+
P̃u ::Matrix{NT}
26+
Tu ::Matrix{NT}
27+
Tu_lastu::Vector{NT}
2828
::Matrix{NT}
2929
F::Vector{NT}
3030
G::Matrix{NT}
@@ -53,22 +53,22 @@ struct LinMPC{
5353
= copy(model.yop) # dummy vals (updated just before optimization)
5454
weights = ControllerWeights{NT}(model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt)
5555
# dummy vals (updated just before optimization):
56-
R̂y, R̂u, TU_lastu = zeros(NT, ny*Hp), zeros(NT, nu*Hp), zeros(NT, nu*Hp)
57-
PΔU = init_ZtoΔU(estim, transcription, Hp, Hc)
58-
PU, TU = init_ZtoU(estim, transcription, Hp, Hc)
56+
R̂y, R̂u, Tu_lastu = zeros(NT, ny*Hp), zeros(NT, nu*Hp), zeros(NT, nu*Hp)
57+
PΔu = init_ZtoΔU(estim, transcription, Hp, Hc)
58+
Pu, Tu = init_ZtoU(estim, transcription, Hp, Hc)
5959
E, G, J, K, V, B, ex̂, gx̂, jx̂, kx̂, vx̂, bx̂ = init_predmat(
6060
model, estim, transcription, Hp, Hc
6161
)
6262
Eŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ = init_defectmat(model, estim, transcription, Hp, Hc)
6363
# dummy vals (updated just before optimization):
6464
F, fx̂, Fŝ = zeros(NT, ny*Hp), zeros(NT, nx̂), zeros(NT, nx̂*Hp)
65-
con, nϵ, P̃ΔU, P̃U, Ẽ, Ẽŝ = init_defaultcon_mpc(
65+
con, nϵ, P̃Δu, P̃u, Ẽ, Ẽŝ = init_defaultcon_mpc(
6666
estim, transcription,
67-
Hp, Hc, Cwt, PΔU, PU, E,
67+
Hp, Hc, Cwt, PΔu, Pu, E,
6868
ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
6969
Eŝ, Fŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ
7070
)
71-
= init_quadprog(model, weights, Ẽ, P̃ΔU, P̃U)
71+
= init_quadprog(model, weights, Ẽ, P̃Δu, P̃u)
7272
# dummy vals (updated just before optimization):
7373
q̃, r = zeros(NT, size(H̃, 1)), zeros(NT, 1)
7474
Ks, Ps = init_stochpred(estim, Hp)
@@ -84,7 +84,7 @@ struct LinMPC{
8484
Hp, Hc, nϵ,
8585
weights,
8686
R̂u, R̂y,
87-
P̃ΔU, P̃U, TU, TU_lastu,
87+
P̃Δu, P̃u, Tu, Tu_lastu,
8888
Ẽ, F, G, J, K, V, B,
8989
H̃, q̃, r,
9090
Ks, Ps,

0 commit comments

Comments
 (0)