Skip to content

Commit 075f955

Browse files
committed
changed: removed A_Ŝ matrix
It is never used, since the same as `Aeq` matrix, and it cause confusion with the linear defect constraint of `CollocationMethod`s
1 parent af6f2e6 commit 075f955

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

src/controller/construct.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ struct ControllerConstraint{NT<:Real, GCfunc<:Union{Nothing, Function}}
176176
# indices of finite numbers in the b vector (linear inequality constraints):
177177
i_b ::BitVector
178178
# A matrices for the linear equality constraints:
179-
A_Ŝ ::Matrix{NT}
180179
Aeq ::Matrix{NT}
181180
# b vector for the linear equality constraints:
182181
beq ::Vector{NT}
@@ -518,7 +517,7 @@ function setconstraint!(
518517
con.A_Umin, con.A_Umax, con.A_ΔŨmin, con.A_ΔŨmax,
519518
con.A_Ymin, con.A_Ymax, con.A_Wmin, con.A_Wmax,
520519
con.A_x̂min, con.A_x̂max,
521-
con.A_Ŝ
520+
con.Aeq
522521
)
523522
A = con.A[con.i_b, :]
524523
b = con.b[con.i_b]
@@ -910,7 +909,7 @@ function init_defaultcon_mpc(
910909
A_Ymin, A_Ymax, Ẽ = relaxŶ(E, C_ymin, C_ymax, nϵ)
911910
A_Wmin, A_Wmax, Ẽw = relaxW(E, Pu, Hp, W̄y, W̄u, C_wmin, C_wmax, nϵ)
912911
A_x̂min, A_x̂max, ẽx̂ = relaxterminal(ex̂, c_x̂min, c_x̂max, nϵ)
913-
A_Ŝ, Ẽŝ = augmentdefect(Eŝ, nϵ)
912+
Aeq, Ẽŝ = augmentdefect(Eŝ, nϵ)
914913
i_Umin, i_Umax = .!isinf.(U0min), .!isinf.(U0max)
915914
i_ΔŨmin, i_ΔŨmax = .!isinf.(ΔŨmin), .!isinf.(ΔŨmax)
916915
i_Ymin, i_Ymax = .!isinf.(Y0min), .!isinf.(Y0max)
@@ -920,7 +919,7 @@ function init_defaultcon_mpc(
920919
model, transcription, nc,
921920
i_Umin, i_Umax, i_ΔŨmin, i_ΔŨmax, i_Ymin, i_Ymax, i_Wmin, i_Wmax, i_x̂min, i_x̂max,
922921
A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, A_Ymin, A_Ymax, A_Wmin, A_Wmax, A_x̂max, A_x̂min,
923-
A_Ŝ
922+
Aeq
924923
)
925924
# dummy fx̂, Fw and Fŝ vectors (updated just before optimization)
926925
fx̂, Fw, Fŝ = zeros(NT, nx̂), zeros(NT, nW), zeros(NT, nx̂*Hp)
@@ -935,7 +934,6 @@ function init_defaultcon_mpc(
935934
A_Umin , A_Umax , A_ΔŨmin , A_ΔŨmax ,
936935
A_Ymin , A_Ymax , A_Wmin , A_Wmax , A_x̂min , A_x̂max ,
937936
A , b , i_b ,
938-
A_Ŝ ,
939937
Aeq , beq ,
940938
neq ,
941939
C_ymin , C_ymax , C_wmin , C_wmax , c_x̂min , c_x̂max ,
@@ -1194,14 +1192,14 @@ function relaxterminal(ex̂::AbstractMatrix{NT}, c_x̂min, c_x̂max, nϵ) where
11941192
end
11951193

11961194
@doc raw"""
1197-
augmentdefect(Eŝ, nϵ) -> A_Ŝ, Ẽŝ
1195+
augmentdefect(Eŝ, nϵ) -> Aeq, Ẽŝ
11981196
11991197
Augment defect equality constraints with slack variable ϵ if `nϵ == 1`.
12001198
1201-
It returns the ``\mathbf{Ẽ_ŝ}`` matrix that appears in the defect equation
1202-
``\mathbf{Ŝ = Ẽ_ŝ Z̃ + F_ŝ}`` and the ``\mathbf{A}`` matrix for the equality constraints:
1199+
It returns the ``\mathbf{Ẽ_ŝ}`` matrix that appears in the linear defect equation
1200+
``\mathbf{Ẽ_ŝ Z̃ + F_ŝ}`` and the ``\mathbf{A}`` matrix for the equality constraints:
12031201
```math
1204-
\mathbf{A_Ŝ Z̃} = - \mathbf{F_ŝ}
1202+
\mathbf{A_{eq}} = \mathbf{b_{eq}} = - \mathbf{F_ŝ}
12051203
```
12061204
"""
12071205
function augmentdefect(Eŝ::AbstractMatrix{NT}, nϵ) where NT<:Real
@@ -1210,8 +1208,8 @@ function augmentdefect(Eŝ::AbstractMatrix{NT}, nϵ) where NT<:Real
12101208
else # Z̃ = Z (only hard constraints)
12111209
Ẽŝ = Eŝ
12121210
end
1213-
A_Ŝ = Ẽŝ
1214-
return A_Ŝ, Ẽŝ
1211+
Aeq = Ẽŝ
1212+
return Aeq, Ẽŝ
12151213
end
12161214

12171215
@doc raw"""

src/controller/execute.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ function setmodel_controller!(mpc::PredictiveController, uop_old, x̂op_old)
720720
con.bx̂ .= bx̂
721721
# --- defect matrices ---
722722
Eŝ, Gŝ, Jŝ, Kŝ, Vŝ, Bŝ = init_defectmat(model, estim, transcription, Hp, Hc, nb)
723-
A_Ŝ, Ẽŝ = augmentdefect(Eŝ, mpc.nϵ)
723+
Aeq, Ẽŝ = augmentdefect(Eŝ, mpc.nϵ)
724724
con.Ẽŝ .= Ẽŝ
725725
con.Gŝ .= Gŝ
726726
con.Jŝ .= Jŝ
@@ -747,8 +747,7 @@ function setmodel_controller!(mpc::PredictiveController, uop_old, x̂op_old)
747747
con.A_x̂max
748748
]
749749
# --- linear equality constraints ---
750-
con.A_Ŝ .= A_Ŝ
751-
con.Aeq .= A_Ŝ
750+
con.Aeq .= Aeq
752751
# --- operating points ---
753752
con.U0min .+= mpc.Uop # convert U0 to U with the old operating point
754753
con.U0max .+= mpc.Uop # convert U0 to U with the old operating point

src/controller/transcription.jl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ The argument `nc` is the number of custom nonlinear inequality constraints in
786786
finite numbers. `i_g` is a similar vector but for the indices of ``\mathbf{g}``. The method
787787
also returns the ``\mathbf{A, A_{eq}}`` matrices and `neq` if `args` is provided. In such a
788788
case, `args` needs to contain all the inequality and equality constraint matrices:
789-
`A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, A_Ymin, A_Ymax, A_Wmin, A_Wmax, A_x̂min, A_x̂max, A_Ŝ`.
789+
`A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, A_Ymin, A_Ymax, A_Wmin, A_Wmax, A_x̂min, A_x̂max, Aeq`.
790790
The integer `neq` is the number of nonlinear equality constraints in ``\mathbf{g_{eq}}``.
791791
"""
792792
function init_matconstraint_mpc(
@@ -803,7 +803,7 @@ function init_matconstraint_mpc(
803803
A_Ymin, A_Ymax,
804804
A_Wmin, A_Wmax,
805805
A_x̂min, A_x̂max,
806-
A_Ŝ
806+
Aeq
807807
) = args
808808
A = [
809809
A_Umin; A_Umax;
@@ -812,7 +812,6 @@ function init_matconstraint_mpc(
812812
A_Wmin; A_Wmax
813813
A_x̂min; A_x̂max;
814814
]
815-
Aeq = A_Ŝ
816815
neq = 0
817816
end
818817
i_b = [i_Umin; i_Umax; i_ΔŨmin; i_ΔŨmax; i_Ymin; i_Ymax; i_Wmin; i_Wmax; i_x̂min; i_x̂max]
@@ -829,9 +828,8 @@ function init_matconstraint_mpc(
829828
if isempty(args)
830829
A, Aeq, neq = nothing, nothing, nothing
831830
else
832-
A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, _ , _ , A_Wmin, A_Wmax, _ , _ , A_Ŝ = args
831+
A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, _ , _ , A_Wmin, A_Wmax, _ , _ , Aeq = args
833832
A = [A_Umin; A_Umax; A_ΔŨmin; A_ΔŨmax; A_Wmin; A_Wmax]
834-
Aeq = A_Ŝ
835833
neq = 0
836834
end
837835
i_b = [i_Umin; i_Umax; i_ΔŨmin; i_ΔŨmax; i_Wmin; i_Wmax]
@@ -848,9 +846,8 @@ function init_matconstraint_mpc(
848846
if isempty(args)
849847
A, Aeq, neq = nothing, nothing, nothing
850848
else
851-
A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, _ , _ , A_Wmin, A_Wmax, A_x̂min, A_x̂max, A_Ŝ = args
849+
A_Umin, A_Umax, A_ΔŨmin, A_ΔŨmax, _ , _ , A_Wmin, A_Wmax, A_x̂min, A_x̂max, Aeq = args
852850
A = [A_Umin; A_Umax; A_ΔŨmin; A_ΔŨmax; A_Wmin; A_Wmax; A_x̂min; A_x̂max]
853-
Aeq = A_Ŝ
854851
nΔŨ, nZ̃ = size(A_ΔŨmin)
855852
neq = nZ̃ - nΔŨ
856853
end

0 commit comments

Comments
 (0)