@@ -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}
1010end
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)
3333end
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)
526526end
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
531531Init the quadratic programming Hessian `H̃` for MPC.
532532
@@ -537,16 +537,16 @@ The matrix appear in the quadratic general form:
537537The Hessian matrix is constant if the model and weights are linear and time invariant (LTI):
538538```math
539539 \m athbf{H̃} = 2 ( \m athbf{Ẽ}' \m athbf{M}_{H_p} \m athbf{Ẽ}
540- + \m athbf{P̃_{ΔU }}' \m athbf{Ñ}_{H_c} \m athbf{P̃_{ΔU }}
541- + \m athbf{P̃_{U }}' \m athbf{L}_{H_p} \m athbf{P̃_{U }} )
540+ + \m athbf{P̃_{Δu }}' \m athbf{Ñ}_{H_c} \m athbf{P̃_{Δu }}
541+ + \m athbf{P̃_{u }}' \m athbf{L}_{H_p} \m athbf{P̃_{u }} )
542542```
543543The vector ``\m athbf{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
545545optimization 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- H̃ = Hermitian (2 * (Ẽ' * M_Hp* Ẽ + P̃ΔU ' * Ñ_Hc* P̃ΔU + P̃U ' * L_Hp* P̃U ), :L )
549+ H̃ = Hermitian (2 * (Ẽ' * M_Hp* Ẽ + P̃Δu ' * Ñ_Hc* P̃Δu + P̃u ' * L_Hp* P̃u ), :L )
550550 return H̃
551551end
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
568568Init `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"""
572572function 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 , Ẽ, Ẽŝ
624624end
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)
635635end
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
640640Augment manipulated inputs constraints with slack variable ϵ for softening.
641641
642642Denoting the decision variables augmented with the slack variable
643643``\m athbf{Z̃} = [\b egin{smallmatrix} \m athbf{Z} \\ ϵ \e nd{smallmatrix}]``, it returns the
644- augmented conversion matrix ``\m athbf{P̃U }``, similar to the one described at
644+ augmented conversion matrix ``\m athbf{P̃u }``, similar to the one described at
645645[`init_ZtoU`](@ref). It also returns the ``\m athbf{A}`` matrices for the inequality
646646constraints:
647647```math
@@ -650,36 +650,36 @@ constraints:
650650 \m athbf{A_{U_{max}}}
651651\e nd{bmatrix} \m athbf{Z̃} ≤
652652\b egin{bmatrix}
653- - \m athbf{U_{min} + T_U u}(k-1) \\
654- + \m athbf{U_{max} - T_U u}(k-1)
653+ - \m athbf{U_{min} + T_u u}(k-1) \\
654+ + \m athbf{U_{max} - T_u u}(k-1)
655655\e nd{bmatrix}
656656```
657657in which ``\m athbf{U_{min}}`` and ``\m athbf{U_{max}}`` vectors respectively contains
658658``\m athbf{u_{min}}`` and ``\m athbf{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 nϵ == 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
671671end
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
676676Augment input increments constraints with slack variable ϵ for softening.
677677
678678Denoting the decision variables augmented with the slack variable
679679``\m athbf{Z̃} = [\b egin{smallmatrix} \m athbf{Z} \\ ϵ \e nd{smallmatrix}]``, it returns the
680- augmented conversion matrix ``\m athbf{P̃_{ΔU }}``, similar to the one described at
680+ augmented conversion matrix ``\m athbf{P̃_{Δu }}``, similar to the one described at
681681[`init_ZtoΔU`](@ref), but extracting the input increments augmented with the slack variable
682- ``\m athbf{ΔŨ} = [\b egin{smallmatrix} \m athbf{ΔU} \\ ϵ \e nd{smallmatrix}] = \m athbf{P̃_{ΔU } Z̃}``.
682+ ``\m athbf{ΔŨ} = [\b egin{smallmatrix} \m athbf{ΔU} \\ ϵ \e nd{smallmatrix}] = \m athbf{P̃_{Δu } Z̃}``.
683683Also, knowing that ``0 ≤ ϵ ≤ ∞``, it also returns the augmented bounds
684684``\m athbf{ΔŨ_{min}} = [\b egin{smallmatrix} \m athbf{ΔU_{min}} \\ 0 \e nd{smallmatrix}]`` and
685685``\m athbf{ΔŨ_{max}} = [\b egin{smallmatrix} \m athbf{ΔU_{min}} \\ ∞ \e nd{smallmatrix}]``,
@@ -699,19 +699,19 @@ bound, which is more precise than a linear inequality constraint. However, it is
699699convenient to treat it as a linear inequality constraint since the optimizer `OSQP.jl` does
700700not 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 nϵ == 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
715715end
716716
717717@doc raw """
0 commit comments