@@ -70,8 +70,8 @@ struct ControllerConstraint
7070 A :: Matrix{Float64}
7171 b :: Vector{Float64}
7272 i_b :: BitVector
73- c_Ymin :: Vector{Float64}
74- c_Ymax :: Vector{Float64}
73+ C_ymin :: Vector{Float64}
74+ C_ymax :: Vector{Float64}
7575 c_x̂min :: Vector{Float64}
7676 c_x̂max :: Vector{Float64}
7777 i_C :: BitVector
@@ -121,7 +121,7 @@ constraints are all soft by default. See Extended Help for time-varying constrai
121121- `c_x̂min = fill(1.0,nx̂)` : `x̂min` softness weights ``\m athbf{c_{x̂_{min}}}``.
122122- `c_x̂max = fill(1.0,nx̂)` : `x̂max` softness weights ``\m athbf{c_{x̂_{max}}}``.
123123- all the keyword arguments above but with a capital letter, except for the terminal
124- constraints, e.g. `Ymax` or `c_ΔUmin ` : for time-varying constraints (see Extended Help).
124+ constraints, e.g. `Ymax` or `C_Δumin ` : for time-varying constraints (see Extended Help).
125125
126126# Examples
127127```jldoctest
@@ -160,15 +160,15 @@ It is also possible to specify time-varying constraints over ``H_p`` and ``H_c``
160160In such a case, they are defined by:
161161```math
162162\b egin{alignat*}{3}
163- \m athbf{U_{min} - c_{U_ {min}}} ϵ ≤&&\ \m athbf{U} &≤ \m athbf{U_{max} + c_{U_ {max}}} ϵ \\
164- \m athbf{ΔU_{min} - c_{ΔU_ {min}}} ϵ ≤&&\ \m athbf{ΔU} &≤ \m athbf{ΔU_{max} + c_{ΔY_ {max}}} ϵ \\
165- \m athbf{Y_{min} - c_{Y_ {min}}} ϵ ≤&&\ \m athbf{Ŷ} &≤ \m athbf{Y_{max} + c_{Y_ {max}}} ϵ
163+ \m athbf{U_{min} - C_{u_ {min}}} ϵ ≤&&\ \m athbf{U} &≤ \m athbf{U_{max} + C_{u_ {max}}} ϵ \\
164+ \m athbf{ΔU_{min} - C_{Δu_ {min}}} ϵ ≤&&\ \m athbf{ΔU} &≤ \m athbf{ΔU_{max} + C_{Δu_ {max}}} ϵ \\
165+ \m athbf{Y_{min} - C_{y_ {min}}} ϵ ≤&&\ \m athbf{Ŷ} &≤ \m athbf{Y_{max} + C_{y_ {max}}} ϵ
166166\e nd{alignat*}
167167```
168168For this, use the same keyword arguments as above but with a capital letter:
169- - `Umin` / `Umax` / `c_Umin ` / `c_Umax ` : ``\m athbf{U}`` constraints `(nu*Hp,)`.
170- - `ΔUmin` / `ΔUmax` / `c_ΔUmin ` / `c_ΔUmax ` : ``\m athbf{ΔU}`` constraints `(nu*Hc,)`.
171- - `Ymin` / `Ymax` / `c_Ymin ` / `c_Ymax ` : ``\m athbf{Ŷ}`` constraints `(ny*Hp,)`.
169+ - `Umin` / `Umax` / `C_umin ` / `C_umax ` : ``\m athbf{U}`` constraints `(nu*Hp,)`.
170+ - `ΔUmin` / `ΔUmax` / `C_Δumin ` / `C_Δumax ` : ``\m athbf{ΔU}`` constraints `(nu*Hc,)`.
171+ - `Ymin` / `Ymax` / `C_ymin ` / `C_ymax ` : ``\m athbf{Ŷ}`` constraints `(ny*Hp,)`.
172172"""
173173function setconstraint! (
174174 mpc:: PredictiveController ;
@@ -183,9 +183,9 @@ function setconstraint!(
183183 Umin = nothing , Umax = nothing ,
184184 ΔUmin = nothing , ΔUmax = nothing ,
185185 Ymin = nothing , Ymax = nothing ,
186- c_Umax = nothing , c_Umin = nothing ,
187- c_ΔUmax = nothing , c_ΔUmin = nothing ,
188- c_Ymax = nothing , c_Ymin = nothing ,
186+ C_umax = nothing , C_umin = nothing ,
187+ C_Δumax = nothing , C_Δumin = nothing ,
188+ C_ymax = nothing , C_ymin = nothing ,
189189 # ------------ will be deleted in the future ---------------
190190 ŷmin = nothing , ŷmax = nothing ,
191191 c_ŷmin = nothing , c_ŷmax = nothing ,
@@ -219,13 +219,13 @@ function setconstraint!(
219219 isnothing (ΔUmax) && ! isnothing (Δumax) && (ΔUmax = repeat (Δumax, Hc))
220220 isnothing (Ymin) && ! isnothing (ymin) && (Ymin = repeat (ymin, Hp))
221221 isnothing (Ymax) && ! isnothing (ymax) && (Ymax = repeat (ymax, Hp))
222- isnothing (c_Umin ) && ! isnothing (c_umin) && (c_Umin = repeat (c_umin, Hp))
223- isnothing (c_Umax ) && ! isnothing (c_umax) && (c_Umax = repeat (c_umax, Hp))
224- isnothing (c_ΔUmin ) && ! isnothing (c_Δumin) && (c_ΔUmin = repeat (c_Δumin, Hc))
225- isnothing (c_ΔUmax ) && ! isnothing (c_Δumax) && (c_ΔUmax = repeat (c_Δumax, Hc))
226- isnothing (c_Ymin ) && ! isnothing (c_ymin) && (c_Ymin = repeat (c_ymin, Hp))
227- isnothing (c_Ymax ) && ! isnothing (c_ymax) && (c_Ymax = repeat (c_ymax, Hp))
228- if ! all (isnothing .([c_Umin, c_Umax, c_ΔUmin, c_ΔUmax, c_Ymin, c_Ymax , c_x̂min, c_x̂max]))
222+ isnothing (C_umin ) && ! isnothing (c_umin) && (C_umin = repeat (c_umin, Hp))
223+ isnothing (C_umax ) && ! isnothing (c_umax) && (C_umax = repeat (c_umax, Hp))
224+ isnothing (C_Δumin ) && ! isnothing (c_Δumin) && (C_Δumin = repeat (c_Δumin, Hc))
225+ isnothing (C_Δumax ) && ! isnothing (c_Δumax) && (C_Δumax = repeat (c_Δumax, Hc))
226+ isnothing (C_ymin ) && ! isnothing (c_ymin) && (C_ymin = repeat (c_ymin, Hp))
227+ isnothing (C_ymax ) && ! isnothing (c_ymax) && (C_ymax = repeat (c_ymax, Hp))
228+ if ! all (isnothing .([C_umin, C_umax, C_Δumin, C_Δumax, C_ymin, C_ymax , c_x̂min, c_x̂max]))
229229 ! isinf (C) || throw (ArgumentError (" Slack variable weight Cwt must be finite to set softness parameters" ))
230230 notSolvedYet || error (" Cannot set softness parameters after calling moveinput!" )
231231 end
@@ -261,38 +261,38 @@ function setconstraint!(
261261 size (x̂max) == (nx̂,) || throw (ArgumentError (" x̂max size must be $((nx̂,)) " ))
262262 con. x̂max[:] = x̂max
263263 end
264- if ! isnothing (c_Umin )
265- size (c_Umin ) == (nu* Hp,) || throw (ArgumentError (" c_Umin size must be $((nu* Hp,)) " ))
266- any (c_Umin .< 0 ) && error (" c_Umin weights should be non-negative" )
267- con. A_Umin[:, end ] = - c_Umin
264+ if ! isnothing (C_umin )
265+ size (C_umin ) == (nu* Hp,) || throw (ArgumentError (" C_umin size must be $((nu* Hp,)) " ))
266+ any (C_umin .< 0 ) && error (" C_umin weights should be non-negative" )
267+ con. A_Umin[:, end ] = - C_umin
268268 end
269- if ! isnothing (c_Umax )
270- size (c_Umax ) == (nu* Hp,) || throw (ArgumentError (" c_Umax size must be $((nu* Hp,)) " ))
271- any (c_Umax .< 0 ) && error (" c_Umax weights should be non-negative" )
272- con. A_Umax[:, end ] = - c_Umax
269+ if ! isnothing (C_umax )
270+ size (C_umax ) == (nu* Hp,) || throw (ArgumentError (" C_umax size must be $((nu* Hp,)) " ))
271+ any (C_umax .< 0 ) && error (" C_umax weights should be non-negative" )
272+ con. A_Umax[:, end ] = - C_umax
273273 end
274- if ! isnothing (c_ΔUmin )
275- size (c_ΔUmin ) == (nu* Hc,) || throw (ArgumentError (" c_ΔUmin size must be $((nu* Hc,)) " ))
276- any (c_ΔUmin .< 0 ) && error (" c_ΔUmin weights should be non-negative" )
277- con. A_ΔŨmin[1 : end - 1 , end ] = - c_ΔUmin
274+ if ! isnothing (C_Δumin )
275+ size (C_Δumin ) == (nu* Hc,) || throw (ArgumentError (" C_Δumin size must be $((nu* Hc,)) " ))
276+ any (C_Δumin .< 0 ) && error (" C_Δumin weights should be non-negative" )
277+ con. A_ΔŨmin[1 : end - 1 , end ] = - C_Δumin
278278 end
279- if ! isnothing (c_ΔUmax )
280- size (c_ΔUmax ) == (nu* Hc,) || throw (ArgumentError (" c_ΔUmax size must be $((nu* Hc,)) " ))
281- any (c_ΔUmax .< 0 ) && error (" c_ΔUmax weights should be non-negative" )
282- con. A_ΔŨmax[1 : end - 1 , end ] = - c_ΔUmax
279+ if ! isnothing (C_Δumax )
280+ size (C_Δumax ) == (nu* Hc,) || throw (ArgumentError (" C_Δumax size must be $((nu* Hc,)) " ))
281+ any (C_Δumax .< 0 ) && error (" C_Δumax weights should be non-negative" )
282+ con. A_ΔŨmax[1 : end - 1 , end ] = - C_Δumax
283283 end
284- if ! isnothing (c_Ymin )
285- size (c_Ymin ) == (ny* Hp,) || throw (ArgumentError (" c_Ymin size must be $((ny* Hp,)) " ))
286- any (c_Ymin .< 0 ) && error (" c_Ymin weights should be non-negative" )
287- con. c_Ymin [:] = c_Ymin
288- A_Ymin ,_ = relaxŶ (model, C, con. c_Ymin , con. c_Ymax , E)
284+ if ! isnothing (C_ymin )
285+ size (C_ymin ) == (ny* Hp,) || throw (ArgumentError (" C_ymin size must be $((ny* Hp,)) " ))
286+ any (C_ymin .< 0 ) && error (" C_ymin weights should be non-negative" )
287+ con. C_ymin [:] = C_ymin
288+ A_Ymin ,_ = relaxŶ (model, C, con. C_ymin , con. C_ymax , E)
289289 con. A_Ymin[:] = A_Ymin
290290 end
291- if ! isnothing (c_Ymax )
292- size (c_Ymax ) == (ny* Hp,) || throw (ArgumentError (" c_Ymax size must be $((ny* Hp,)) " ))
293- any (c_Ymax .< 0 ) && error (" c_Ymax weights should be non-negative" )
294- con. c_Ymax [:] = c_Ymax
295- _, A_Ymax = relaxŶ (model, C, con. c_Ymin , con. c_Ymax , E)
291+ if ! isnothing (C_ymax )
292+ size (C_ymax ) == (ny* Hp,) || throw (ArgumentError (" C_ymax size must be $((ny* Hp,)) " ))
293+ any (C_ymax .< 0 ) && error (" C_ymax weights should be non-negative" )
294+ con. C_ymax [:] = C_ymax
295+ _, A_Ymax = relaxŶ (model, C, con. C_ymin , con. C_ymax , E)
296296 con. A_Ymax[:] = A_Ymax
297297 end
298298 if ! isnothing (c_x̂min)
@@ -1017,11 +1017,11 @@ function init_defaultcon(estim, Hp, Hc, C, S, N_Hc, E, ex̂, fx̂, gx̂, jx̂, k
10171017 c_x̂min, c_x̂max = fill (0.0 , nx̂), fill (0.0 , nx̂)
10181018 Umin, Umax, ΔUmin, ΔUmax, Ymin, Ymax =
10191019 repeat_constraints (Hp, Hc, umin, umax, Δumin, Δumax, ymin, ymax)
1020- c_Umin, c_Umax, c_ΔUmin, c_ΔUmax, c_Ymin, c_Ymax =
1020+ C_umin, C_umax, C_Δumin, C_Δumax, C_ymin, C_ymax =
10211021 repeat_constraints (Hp, Hc, c_umin, c_umax, c_Δumin, c_Δumax, c_ymin, c_ymax)
1022- A_Umin, A_Umax, S̃ = relaxU (C, c_Umin, c_Umax , S)
1023- A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, Ñ_Hc = relaxΔU (C, c_ΔUmin, c_ΔUmax , ΔUmin, ΔUmax, N_Hc)
1024- A_Ymin, A_Ymax, Ẽ = relaxŶ (model, C, c_Ymin, c_Ymax , E)
1022+ A_Umin, A_Umax, S̃ = relaxU (C, C_umin, C_umax , S)
1023+ A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, Ñ_Hc = relaxΔU (C, C_Δumin, C_Δumax , ΔUmin, ΔUmax, N_Hc)
1024+ A_Ymin, A_Ymax, Ẽ = relaxŶ (model, C, C_ymin, C_ymax , E)
10251025 A_x̂min, A_x̂max, ẽx̂ = relaxterminal (model, C, c_x̂min, c_x̂max, ex̂)
10261026 i_Umin, i_Umax = .! isinf .(Umin), .! isinf .(Umax)
10271027 i_ΔŨmin, i_ΔŨmax = .! isinf .(ΔŨmin), .! isinf .(ΔŨmax)
@@ -1037,7 +1037,7 @@ function init_defaultcon(estim, Hp, Hc, C, S, N_Hc, E, ex̂, fx̂, gx̂, jx̂, k
10371037 ẽx̂ , fx̂ , gx̂ , jx̂ , kx̂ , vx̂ ,
10381038 Umin , Umax , ΔŨmin , ΔŨmax , Ymin , Ymax , x̂min , x̂max,
10391039 A_Umin , A_Umax, A_ΔŨmin, A_ΔŨmax , A_Ymin , A_Ymax , A_x̂min , A_x̂max,
1040- A , b , i_b , c_Ymin , c_Ymax , c_x̂min , c_x̂max , i_C
1040+ A , b , i_b , C_ymin , C_ymax , c_x̂min , c_x̂max , i_C
10411041 )
10421042 return con, S̃, Ñ_Hc, Ẽ
10431043end
@@ -1054,7 +1054,7 @@ function repeat_constraints(Hp, Hc, umin, umax, Δumin, Δumax, ymin, ymax)
10541054end
10551055
10561056@doc raw """
1057- relaxU(C, c_Umin, c_Umax , S) -> A_Umin, A_Umax, S̃
1057+ relaxU(C, C_umin, C_umax , S) -> A_Umin, A_Umax, S̃
10581058
10591059Augment manipulated inputs constraints with slack variable ϵ for softening.
10601060
@@ -1074,10 +1074,10 @@ constraints:
10741074\e nd{bmatrix}
10751075```
10761076"""
1077- function relaxU (C, c_Umin, c_Umax , S)
1077+ function relaxU (C, C_umin, C_umax , S)
10781078 if ! isinf (C) # ΔŨ = [ΔU; ϵ]
10791079 # ϵ impacts ΔU → U conversion for constraint calculations:
1080- A_Umin, A_Umax = - [S c_Umin ], [S - c_Umax ]
1080+ A_Umin, A_Umax = - [S C_umin ], [S - C_umax ]
10811081 # ϵ has no impact on ΔU → U conversion for prediction calculations:
10821082 S̃ = [S falses (size (S, 1 ))]
10831083 else # ΔŨ = ΔU (only hard constraints)
@@ -1088,7 +1088,7 @@ function relaxU(C, c_Umin, c_Umax, S)
10881088end
10891089
10901090@doc raw """
1091- relaxΔU(C, c_ΔUmin, c_ΔUmax , ΔUmin, ΔUmax, N_Hc) -> A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, Ñ_Hc
1091+ relaxΔU(C, C_Δumin, C_Δumax , ΔUmin, ΔUmax, N_Hc) -> A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, Ñ_Hc
10921092
10931093Augment input increments constraints with slack variable ϵ for softening.
10941094
@@ -1108,12 +1108,12 @@ returns the augmented constraints ``\mathbf{ΔŨ_{min}}`` and ``\mathbf{ΔŨ_{
11081108\e nd{bmatrix}
11091109```
11101110"""
1111- function relaxΔU (C, c_ΔUmin, c_ΔUmax , ΔUmin, ΔUmax, N_Hc)
1111+ function relaxΔU (C, C_Δumin, C_Δumax , ΔUmin, ΔUmax, N_Hc)
11121112 if ! isinf (C) # ΔŨ = [ΔU; ϵ]
11131113 # 0 ≤ ϵ ≤ ∞
11141114 ΔŨmin, ΔŨmax = [ΔUmin; 0.0 ], [ΔUmax; Inf ]
11151115 A_ϵ = [zeros (1 , length (ΔUmin)) [1 ]]
1116- A_ΔŨmin, A_ΔŨmax = - [I c_ΔUmin ; A_ϵ], [I - c_ΔUmax ; A_ϵ]
1116+ A_ΔŨmin, A_ΔŨmax = - [I C_Δumin ; A_ϵ], [I - C_Δumax ; A_ϵ]
11171117 Ñ_Hc = Diagonal ([diag (N_Hc); C])
11181118 else # ΔŨ = ΔU (only hard constraints)
11191119 ΔŨmin, ΔŨmax = ΔUmin, ΔUmax
@@ -1125,7 +1125,7 @@ function relaxΔU(C, c_ΔUmin, c_ΔUmax, ΔUmin, ΔUmax, N_Hc)
11251125end
11261126
11271127@doc raw """
1128- relaxŶ(::LinModel, C, c_Ymin, c_Ymax , E) -> A_Ymin, A_Ymax, Ẽ
1128+ relaxŶ(::LinModel, C, C_ymin, C_ymax , E) -> A_Ymin, A_Ymax, Ẽ
11291129
11301130Augment linear output prediction constraints with slack variable ϵ for softening.
11311131
@@ -1144,10 +1144,10 @@ Denoting the input increments augmented with the slack variable
11441144\e nd{bmatrix}
11451145```
11461146"""
1147- function relaxŶ (:: LinModel , C, c_Ymin, c_Ymax , E)
1147+ function relaxŶ (:: LinModel , C, C_ymin, C_ymax , E)
11481148 if ! isinf (C) # ΔŨ = [ΔU; ϵ]
11491149 # ϵ impacts predicted output constraint calculations:
1150- A_Ymin, A_Ymax = - [E c_Ymin ], [E - c_Ymax ]
1150+ A_Ymin, A_Ymax = - [E C_ymin ], [E - C_ymax ]
11511151 # ϵ has no impact on output predictions
11521152 Ẽ = [E zeros (size (E, 1 ), 1 )]
11531153 else # ΔŨ = ΔU (only hard constraints)
@@ -1158,7 +1158,7 @@ function relaxŶ(::LinModel, C, c_Ymin, c_Ymax, E)
11581158end
11591159
11601160" Return empty matrices if model is not a [`LinModel`](@ref)"
1161- function relaxŶ (:: SimModel , C, c_Ymin, c_Ymax , E)
1161+ function relaxŶ (:: SimModel , C, C_ymin, C_ymax , E)
11621162 Ẽ = ! isinf (C) ? [E zeros (0 , 1 )] : E
11631163 A_Ymin, A_Ymax = - Ẽ, Ẽ
11641164 return A_Ymin, A_Ymax, Ẽ
0 commit comments