Skip to content

Commit f37e9bb

Browse files
authored
Merge pull request #131 from JuliaControl/weights_struct
Changed: moved all controller weights in `mpc.weights` struct
2 parents bbb131b + 0fc2dd9 commit f37e9bb

File tree

7 files changed

+132
-128
lines changed

7 files changed

+132
-128
lines changed

src/controller/construct.jl

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
"Include all the objective function weights of [`PredictiveController`](@ref)"
2+
struct ControllerWeights{NT<:Real}
3+
M_Hp::Hermitian{NT, Matrix{NT}}
4+
Ñ_Hc::Hermitian{NT, Matrix{NT}}
5+
L_Hp::Hermitian{NT, Matrix{NT}}
6+
E ::NT
7+
function ControllerWeights{NT}(
8+
model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt=Inf, Ewt=0
9+
) where NT<:Real
10+
validate_weights(model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt, Ewt)
11+
# convert `Diagonal` to normal `Matrix` if required:
12+
M_Hp = Hermitian(convert(Matrix{NT}, M_Hp), :L)
13+
N_Hc = Hermitian(convert(Matrix{NT}, N_Hc), :L)
14+
L_Hp = Hermitian(convert(Matrix{NT}, L_Hp), :L)
15+
nΔU = size(N_Hc, 1)
16+
C = Cwt
17+
if !isinf(Cwt)
18+
# ΔŨ = [ΔU; ϵ] (ϵ is the slack variable)
19+
Ñ_Hc = Hermitian([N_Hc zeros(NT, nΔU, 1); zeros(NT, 1, nΔU) C], :L)
20+
else
21+
# ΔŨ = ΔU (only hard constraints)
22+
Ñ_Hc = N_Hc
23+
end
24+
E = Ewt
25+
return new{NT}(M_Hp, Ñ_Hc, L_Hp, E)
26+
end
27+
end
28+
129
"Include all the data for the constraints of [`PredictiveController`](@ref)"
230
struct ControllerConstraint{NT<:Real, GCfunc<:Function}
331
ẽx̂ ::Matrix{NT}
@@ -609,7 +637,7 @@ function init_predmat(estim::StateEstimator{NT}, model::SimModel, Hp, Hc) where
609637
end
610638

611639
@doc raw"""
612-
init_quadprog(model::LinModel, Ẽ, S, M_Hp, N_Hc, L_Hp) -> H̃
640+
init_quadprog(model::LinModel, weights::ControllerWeights, Ẽ, S) -> H̃
613641
614642
Init the quadratic programming Hessian `H̃` for MPC.
615643
@@ -626,29 +654,30 @@ The vector ``\mathbf{q̃}`` and scalar ``r`` need recalculation each control per
626654
[`initpred!`](@ref). ``r`` does not impact the minima position. It is thus useless at
627655
optimization but required to evaluate the minimal ``J`` value.
628656
"""
629-
function init_quadprog(::LinModel, Ẽ, S̃, M_Hp, Ñ_Hc, L_Hp)
657+
function init_quadprog(::LinModel, weights::ControllerWeights, Ẽ, S̃)
658+
M_Hp, Ñ_Hc, L_Hp = weights.M_Hp, weights.Ñ_Hc, weights.L_Hp
630659
= Hermitian(2*(Ẽ'*M_Hp*+ Ñ_Hc +'*L_Hp*S̃), :L)
631660
return
632661
end
633-
"Return empty matrices if `model` is not a [`LinModel`](@ref)."
634-
function init_quadprog(::SimModel{NT}, Ẽ, S̃, M_Hp, Ñ_Hc, L_Hp) where {NT<:Real}
662+
"Return empty matrix if `model` is not a [`LinModel`](@ref)."
663+
function init_quadprog(::SimModel{NT}, weights::ControllerWeights, _, _) where {NT<:Real}
635664
= Hermitian(zeros(NT, 0, 0), :L)
636665
return
637666
end
638667

639668
"""
640669
init_defaultcon_mpc(
641-
estim, C, S, N_Hc, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂,
670+
estim, C, S, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂,
642671
gc!=(_,_,_,_,_,_)->nothing, nc=0
643-
) -> con, S̃, Ñ_Hc,
672+
) -> con, S̃, Ẽ
644673
645674
Init `ControllerConstraint` struct with default parameters based on estimator `estim`.
646675
647-
Also return `S̃`, `Ñ_Hc` and `Ẽ` matrices for the the augmented decision vector `ΔŨ`.
676+
Also return `S̃` and `Ẽ` matrices for the the augmented decision vector `ΔŨ`.
648677
"""
649678
function init_defaultcon_mpc(
650679
estim::StateEstimator{NT},
651-
Hp, Hc, C, S, N_Hc, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
680+
Hp, Hc, C, S, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
652681
gc!::GCfunc=(_,_,_,_,_,_)->nothing, nc=0
653682
) where {NT<:Real, GCfunc<:Function}
654683
model = estim.model
@@ -667,9 +696,7 @@ function init_defaultcon_mpc(
667696
C_umin, C_umax, C_Δumin, C_Δumax, C_ymin, C_ymax =
668697
repeat_constraints(Hp, Hc, c_umin, c_umax, c_Δumin, c_Δumax, c_ymin, c_ymax)
669698
A_Umin, A_Umax, S̃ = relaxU(model, nϵ, C_umin, C_umax, S)
670-
A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, Ñ_Hc = relaxΔU(
671-
model, nϵ, C, C_Δumin, C_Δumax, ΔUmin, ΔUmax, N_Hc
672-
)
699+
A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax = relaxΔU(model, nϵ, C, C_Δumin, C_Δumax, ΔUmin, ΔUmax)
673700
A_Ymin, A_Ymax, Ẽ = relaxŶ(model, nϵ, C_ymin, C_ymax, E)
674701
A_x̂min, A_x̂max, ẽx̂ = relaxterminal(model, nϵ, c_x̂min, c_x̂max, ex̂)
675702
i_Umin, i_Umax = .!isinf.(U0min), .!isinf.(U0max)
@@ -689,7 +716,7 @@ function init_defaultcon_mpc(
689716
A , b , i_b , C_ymin , C_ymax , c_x̂min , c_x̂max , i_g,
690717
gc! , nc
691718
)
692-
return con, nϵ, S̃, Ñ_Hc,
719+
return con, nϵ, S̃, Ẽ
693720
end
694721

695722
"Repeat predictive controller constraints over prediction `Hp` and control `Hc` horizons."
@@ -742,17 +769,14 @@ function relaxU(::SimModel{NT}, nϵ, C_umin, C_umax, S) where NT<:Real
742769
end
743770

744771
@doc raw"""
745-
relaxΔU(
746-
model, nϵ, C, C_Δumin, C_Δumax, ΔUmin, ΔUmax, N_Hc
747-
) -> A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, Ñ_Hc
772+
relaxΔU(model, nϵ, C, C_Δumin, C_Δumax, ΔUmin, ΔUmax) -> A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax
748773
749774
Augment input increments constraints with slack variable ϵ for softening.
750775
751776
Denoting the input increments augmented with the slack variable
752777
``\mathbf{ΔŨ} = [\begin{smallmatrix} \mathbf{ΔU} \\ ϵ \end{smallmatrix}]``, it returns the
753-
augmented input increment weights ``\mathbf{Ñ}_{H_c}`` (that incorporate ``C``). It also
754-
returns the augmented constraints ``\mathbf{ΔŨ_{min}}`` and ``\mathbf{ΔŨ_{max}}`` and the
755-
``\mathbf{A}`` matrices for the inequality constraints:
778+
augmented constraints ``\mathbf{ΔŨ_{min}}`` and ``\mathbf{ΔŨ_{max}}`` and the ``\mathbf{A}``
779+
matrices for the inequality constraints:
756780
```math
757781
\begin{bmatrix}
758782
\mathbf{A_{ΔŨ_{min}}} \\
@@ -764,21 +788,19 @@ returns the augmented constraints ``\mathbf{ΔŨ_{min}}`` and ``\mathbf{ΔŨ_{
764788
\end{bmatrix}
765789
```
766790
"""
767-
function relaxΔU(::SimModel{NT}, nϵ, C, C_Δumin, C_Δumax, ΔUmin, ΔUmax, N_Hc) where NT<:Real
768-
nΔU = size(N_Hc, 1)
791+
function relaxΔU(::SimModel{NT}, nϵ, C, C_Δumin, C_Δumax, ΔUmin, ΔUmax) where NT<:Real
792+
nΔU = length(ΔUmin)
769793
if== 1 # ΔŨ = [ΔU; ϵ]
770794
# 0 ≤ ϵ ≤ ∞
771795
ΔŨmin, ΔŨmax = [ΔUmin; NT[0.0]], [ΔUmax; NT[Inf]]
772-
A_ϵ = [zeros(NT, 1, length(ΔUmin)) NT[1.0]]
796+
A_ϵ = [zeros(NT, 1, nΔU) NT[1.0]]
773797
A_ΔŨmin, A_ΔŨmax = -[I C_Δumin; A_ϵ], [I -C_Δumax; A_ϵ]
774-
Ñ_Hc = Hermitian([N_Hc zeros(NT, nΔU, 1);zeros(NT, 1, nΔU) C], :L)
775798
else # ΔŨ = ΔU (only hard constraints)
776799
ΔŨmin, ΔŨmax = ΔUmin, ΔUmax
777800
I_Hc = Matrix{NT}(I, nΔU, nΔU)
778801
A_ΔŨmin, A_ΔŨmax = -I_Hc, I_Hc
779-
Ñ_Hc = N_Hc
780802
end
781-
return A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, Ñ_Hc
803+
return A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax
782804
end
783805

784806
@doc raw"""

src/controller/execute.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ function initpred!(mpc::PredictiveController, model::LinModel, d, D̂, R̂y, R̂
206206
end
207207
mpc.R̂y .= R̂y
208208
Cy = F .- (R̂y .- mpc.Yop)
209-
M_Hp_Ẽ = mpc.M_Hp*mpc.
209+
M_Hp_Ẽ = mpc.weights.M_Hp*mpc.
210210
mul!(q̃, M_Hp_Ẽ', Cy)
211-
r .= dot(Cy, mpc.M_Hp, Cy)
211+
r .= dot(Cy, mpc.weights.M_Hp, Cy)
212212
if ~mpc.noR̂u
213213
mpc.R̂u .= R̂u
214214
Cu = mpc.T_lastu0 .- (R̂u .- mpc.Uop)
215-
L_Hp_S̃ = mpc.L_Hp*mpc.
215+
L_Hp_S̃ = mpc.weights.L_Hp*mpc.
216216
mul!(q̃, L_Hp_S̃', Cu, 1, 1)
217-
r .+= dot(Cu, mpc.L_Hp, Cu)
217+
r .+= dot(Cu, mpc.weights.L_Hp, Cu)
218218
end
219219
lmul!(2, q̃)
220220
return nothing
@@ -414,14 +414,14 @@ function obj_nonlinprog!(
414414
# --- output setpoint tracking term ---
415415
Ȳ .= @views Ŷe[ny+1:end]
416416
Ȳ .= mpc.R̂y .-
417-
JR̂y = dot(Ȳ, mpc.M_Hp, Ȳ)
417+
JR̂y = dot(Ȳ, mpc.weights.M_Hp, Ȳ)
418418
# --- move suppression and slack variable term ---
419-
JΔŨ = dot(ΔŨ, mpc.Ñ_Hc, ΔŨ)
419+
JΔŨ = dot(ΔŨ, mpc.weights.Ñ_Hc, ΔŨ)
420420
# --- input setpoint tracking term ---
421421
if !mpc.noR̂u
422422
Ū .= @views Ue[1:end-nu]
423423
Ū .= mpc.R̂u .-
424-
JR̂u = dot(Ū, mpc.L_Hp, Ū)
424+
JR̂u = dot(Ū, mpc.weights.L_Hp, Ū)
425425
else
426426
JR̂u = 0.0
427427
end
@@ -589,12 +589,12 @@ prediction horizon ``H_p``.
589589
```jldoctest
590590
julia> mpc = LinMPC(KalmanFilter(LinModel(ss(0.1, 0.5, 1, 0, 4.0)), σR=[√25]), Hp=1, Hc=1);
591591
592-
julia> mpc.estim.model.A[1], mpc.estim.R̂[1], mpc.M_Hp[1], mpc.Ñ_Hc[1]
592+
julia> mpc.estim.model.A[1], mpc.estim.R̂[1], mpc.weights.M_Hp[1], mpc.weights.Ñ_Hc[1]
593593
(0.1, 25.0, 1.0, 0.1)
594594
595595
julia> setmodel!(mpc, LinModel(ss(0.42, 0.5, 1, 0, 4.0)); R̂=[9], M_Hp=[10], Nwt=[0.666]);
596596
597-
julia> mpc.estim.model.A[1], mpc.estim.R̂[1], mpc.M_Hp[1], mpc.Ñ_Hc[1]
597+
julia> mpc.estim.model.A[1], mpc.estim.R̂[1], mpc.weights.M_Hp[1], mpc.weights.Ñ_Hc[1]
598598
(0.42, 9.0, 10.0, 0.666)
599599
```
600600
"""
@@ -617,44 +617,44 @@ function setmodel!(
617617
size(Mwt) == (ny,) || throw(ArgumentError("Mwt should be a vector of length $ny"))
618618
any(x -> x < 0, Mwt) && throw(ArgumentError("Mwt values should be nonnegative"))
619619
for i=1:ny*Hp
620-
mpc.M_Hp[i, i] = Mwt[(i-1) % ny + 1]
620+
mpc.weights.M_Hp[i, i] = Mwt[(i-1) % ny + 1]
621621
end
622622
elseif !isnothing(M_Hp)
623623
M_Hp = to_hermitian(M_Hp)
624624
nŶ = ny*Hp
625625
size(M_Hp) == (nŶ, nŶ) || throw(ArgumentError("M_Hp size should be ($nŶ, $nŶ)"))
626-
mpc.M_Hp .= M_Hp
626+
mpc.weights.M_Hp .= M_Hp
627627
end
628628
if isnothing(Ñ_Hc) && !isnothing(Nwt)
629629
size(Nwt) == (nu,) || throw(ArgumentError("Nwt should be a vector of length $nu"))
630630
any(x -> x < 0, Nwt) && throw(ArgumentError("Nwt values should be nonnegative"))
631631
for i=1:nu*Hc
632-
mpc.Ñ_Hc[i, i] = Nwt[(i-1) % nu + 1]
632+
mpc.weights.Ñ_Hc[i, i] = Nwt[(i-1) % nu + 1]
633633
end
634634
elseif !isnothing(Ñ_Hc)
635635
Ñ_Hc = to_hermitian(Ñ_Hc)
636636
nΔŨ = nu*Hc+
637637
size(Ñ_Hc) == (nΔŨ, nΔŨ) || throw(ArgumentError("Ñ_Hc size should be ($nΔŨ, $nΔŨ)"))
638-
mpc.Ñ_Hc .= Ñ_Hc
638+
mpc.weights.Ñ_Hc .= Ñ_Hc
639639
end
640640
if isnothing(L_Hp) && !isnothing(Lwt)
641641
size(Lwt) == (nu,) || throw(ArgumentError("Lwt should be a vector of length $nu"))
642642
any(x -> x < 0, Lwt) && throw(ArgumentError("Lwt values should be nonnegative"))
643643
for i=1:nu*Hp
644-
mpc.L_Hp[i, i] = Lwt[(i-1) % nu + 1]
644+
mpc.weights.L_Hp[i, i] = Lwt[(i-1) % nu + 1]
645645
end
646646
elseif !isnothing(L_Hp)
647647
L_Hp = to_hermitian(L_Hp)
648648
nU = nu*Hp
649649
size(L_Hp) == (nU, nU) || throw(ArgumentError("L_Hp size should be ($nU, $nU)"))
650-
mpc.L_Hp .= L_Hp
650+
mpc.weights.L_Hp .= L_Hp
651651
end
652-
setmodel_controller!(mpc, x̂op_old, M_Hp, Ñ_Hc, L_Hp)
652+
setmodel_controller!(mpc, x̂op_old)
653653
return mpc
654654
end
655655

656656
"Update the prediction matrices, linear constraints and JuMP optimization."
657-
function setmodel_controller!(mpc::PredictiveController, x̂op_old, M_Hp, Ñ_Hc, L_Hp)
657+
function setmodel_controller!(mpc::PredictiveController, x̂op_old)
658658
estim, model = mpc.estim, mpc.estim.model
659659
nu, ny, nd, Hp, Hc = model.nu, model.ny, model.nd, mpc.Hp, mpc.Hc
660660
optim, con = mpc.optim, mpc.con
@@ -715,7 +715,7 @@ function setmodel_controller!(mpc::PredictiveController, x̂op_old, M_Hp, Ñ_Hc
715715
JuMP.unregister(optim, :linconstraint)
716716
@constraint(optim, linconstraint, A*ΔŨvar .≤ b)
717717
# --- quadratic programming Hessian matrix ---
718-
= init_quadprog(model, mpc., mpc., mpc.M_Hp, mpc.Ñ_Hc, mpc.L_Hp)
718+
= init_quadprog(model, mpc.weights, mpc., mpc.)
719719
mpc.H̃ .=
720720
set_objective_hessian!(mpc, ΔŨvar)
721721
return nothing

src/controller/explicitmpc.jl

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ struct ExplicitMPC{NT<:Real, SE<:StateEstimator} <: PredictiveController{NT}
55
Hp::Int
66
Hc::Int
77
::Int
8-
M_Hp::Hermitian{NT, Matrix{NT}}
9-
Ñ_Hc::Hermitian{NT, Matrix{NT}}
10-
L_Hp::Hermitian{NT, Matrix{NT}}
11-
E::NT
8+
weights::ControllerWeights{NT}
129
R̂u::Vector{NT}
1310
R̂y::Vector{NT}
1411
noR̂u::Bool
@@ -42,8 +39,7 @@ struct ExplicitMPC{NT<:Real, SE<:StateEstimator} <: PredictiveController{NT}
4239
nu, ny, nd, nx̂ = model.nu, model.ny, model.nd, estim.nx̂
4340
= copy(model.yop) # dummy vals (updated just before optimization)
4441
= 0 # no slack variable ϵ for ExplicitMPC
45-
Ewt = 0 # economic costs not supported for ExplicitMPC
46-
validate_weights(model, Hp, Hc, M_Hp, N_Hc, L_Hp)
42+
weights = ControllerWeights{NT}(model, Hp, Hc, M_Hp, N_Hc, L_Hp)
4743
# convert `Diagonal` to normal `Matrix` if required:
4844
M_Hp = Hermitian(convert(Matrix{NT}, M_Hp), :L)
4945
N_Hc = Hermitian(convert(Matrix{NT}, N_Hc), :L)
@@ -56,7 +52,7 @@ struct ExplicitMPC{NT<:Real, SE<:StateEstimator} <: PredictiveController{NT}
5652
# dummy val (updated just before optimization):
5753
F, fx̂ = zeros(NT, ny*Hp), zeros(NT, nx̂)
5854
S̃, Ñ_Hc, Ẽ = S, N_Hc, E # no slack variable ϵ for ExplicitMPC
59-
= init_quadprog(model, Ẽ, S̃, M_Hp, Ñ_Hc, L_Hp)
55+
= init_quadprog(model, weights ,Ẽ, S̃)
6056
# dummy vals (updated just before optimization):
6157
q̃, r = zeros(NT, size(H̃, 1)), zeros(NT, 1)
6258
H̃_chol = cholesky(H̃)
@@ -71,7 +67,7 @@ struct ExplicitMPC{NT<:Real, SE<:StateEstimator} <: PredictiveController{NT}
7167
estim,
7268
ΔŨ, ŷ,
7369
Hp, Hc, nϵ,
74-
M_Hp, Ñ_Hc, L_Hp, Ewt,
70+
weights,
7571
R̂u, R̂y, noR̂u,
7672
S̃, T, T_lastu0,
7773
Ẽ, F, G, J, K, V, B,
@@ -211,7 +207,7 @@ addinfo!(info, mpc::ExplicitMPC) = info
211207

212208

213209
"Update the prediction matrices and Cholesky factorization."
214-
function setmodel_controller!(mpc::ExplicitMPC, _ , M_Hp, Ñ_Hc, L_Hp)
210+
function setmodel_controller!(mpc::ExplicitMPC, _ )
215211
estim, model = mpc.estim, mpc.estim.model
216212
nu, ny, nd, Hp, Hc = model.nu, model.ny, model.nd, mpc.Hp, mpc.Hc
217213
# --- predictions matrices ---
@@ -224,7 +220,7 @@ function setmodel_controller!(mpc::ExplicitMPC, _ , M_Hp, Ñ_Hc, L_Hp)
224220
mpc.V .= V
225221
mpc.B .= B
226222
# --- quadratic programming Hessian matrix ---
227-
= init_quadprog(model, mpc., mpc., mpc.M_Hp, mpc.Ñ_Hc, mpc.L_Hp)
223+
= init_quadprog(model, mpc.weights, mpc., mpc.)
228224
mpc.H̃ .=
229225
set_objective_hessian!(mpc)
230226
# --- operating points ---

src/controller/linmpc.jl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ struct LinMPC{
1515
Hp::Int
1616
Hc::Int
1717
::Int
18-
M_Hp::Hermitian{NT, Matrix{NT}}
19-
Ñ_Hc::Hermitian{NT, Matrix{NT}}
20-
L_Hp::Hermitian{NT, Matrix{NT}}
21-
E::NT
18+
weights::ControllerWeights{NT}
2219
R̂u::Vector{NT}
2320
R̂y::Vector{NT}
2421
noR̂u::Bool
@@ -50,23 +47,18 @@ struct LinMPC{
5047
model = estim.model
5148
nu, ny, nd, nx̂ = model.nu, model.ny, model.nd, estim.nx̂
5249
= copy(model.yop) # dummy vals (updated just before optimization)
53-
Ewt = 0 # economic costs not supported for LinMPC
54-
validate_weights(model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt)
55-
# convert `Diagonal` to normal `Matrix` if required:
56-
M_Hp = Hermitian(convert(Matrix{NT}, M_Hp), :L)
57-
N_Hc = Hermitian(convert(Matrix{NT}, N_Hc), :L)
58-
L_Hp = Hermitian(convert(Matrix{NT}, L_Hp), :L)
50+
weights = ControllerWeights{NT}(model, Hp, Hc, M_Hp, N_Hc, L_Hp, Cwt)
5951
# dummy vals (updated just before optimization):
6052
R̂y, R̂u, T_lastu0 = zeros(NT, ny*Hp), zeros(NT, nu*Hp), zeros(NT, nu*Hp)
6153
noR̂u = iszero(L_Hp)
6254
S, T = init_ΔUtoU(model, Hp, Hc)
6355
E, G, J, K, V, B, ex̂, gx̂, jx̂, kx̂, vx̂, bx̂ = init_predmat(estim, model, Hp, Hc)
6456
# dummy vals (updated just before optimization):
6557
F, fx̂ = zeros(NT, ny*Hp), zeros(NT, nx̂)
66-
con, nϵ, S̃, Ñ_Hc, = init_defaultcon_mpc(
67-
estim, Hp, Hc, Cwt, S, N_Hc, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂
58+
con, nϵ, S̃, Ẽ = init_defaultcon_mpc(
59+
estim, Hp, Hc, Cwt, S, E, ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂
6860
)
69-
= init_quadprog(model, Ẽ, S̃, M_Hp, Ñ_Hc, L_Hp)
61+
= init_quadprog(model, weights, Ẽ, S̃)
7062
# dummy vals (updated just before optimization):
7163
q̃, r = zeros(NT, size(H̃, 1)), zeros(NT, 1)
7264
Ks, Ps = init_stochpred(estim, Hp)
@@ -80,7 +72,7 @@ struct LinMPC{
8072
estim, optim, con,
8173
ΔŨ, ŷ,
8274
Hp, Hc, nϵ,
83-
M_Hp, Ñ_Hc, L_Hp, Ewt,
75+
weights,
8476
R̂u, R̂y, noR̂u,
8577
S̃, T, T_lastu0,
8678
Ẽ, F, G, J, K, V, B,

0 commit comments

Comments
 (0)