@@ -472,7 +472,7 @@ function validate_args(mpc::PredictiveController, ry, d, D̂, R̂y, R̂u)
472472end
473473
474474@doc raw """
475- init_quadprog(model::LinModel, weights::ControllerWeights, Ẽ, S ) -> H̃
475+ init_quadprog(model::LinModel, weights::ControllerWeights, Ẽ, P̃, S̃ ) -> H̃
476476
477477Init the quadratic programming Hessian `H̃` for MPC.
478478
@@ -489,9 +489,9 @@ The vector ``\mathbf{q̃}`` and scalar ``r`` need recalculation each control per
489489[`initpred!`](@ref). ``r`` does not impact the minima position. It is thus useless at
490490optimization but required to evaluate the minimal ``J`` value.
491491"""
492- function init_quadprog (:: LinModel , weights:: ControllerWeights , Ẽ, S̃)
492+ function init_quadprog (:: LinModel , weights:: ControllerWeights , Ẽ, P̃, S̃)
493493 M_Hp, Ñ_Hc, L_Hp = weights. M_Hp, weights. Ñ_Hc, weights. L_Hp
494- H̃ = Hermitian (2 * (Ẽ' * M_Hp* Ẽ + Ñ_Hc + S̃' * L_Hp* S̃), :L )
494+ H̃ = Hermitian (2 * (Ẽ' * M_Hp* Ẽ + P̃ ' * Ñ_Hc* P̃ + S̃' * L_Hp* S̃), :L )
495495 return H̃
496496end
497497" Return empty matrix if `model` is not a [`LinModel`](@ref)."
502502
503503"""
504504 init_defaultcon_mpc(
505- estim::StateEstimator,
505+ estim::StateEstimator, transcription::TranscriptionMethod,
506506 Hp, Hc, C,
507507 P, S, E,
508508 ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
@@ -515,7 +515,7 @@ Init `ControllerConstraint` struct with default parameters based on estimator `e
515515Also return `P̃`, `S̃`, `Ẽ` and `Ẽŝ` matrices for the the augmented decision vector `Z̃`.
516516"""
517517function init_defaultcon_mpc (
518- estim:: StateEstimator{NT} ,
518+ estim:: StateEstimator{NT} , transcription :: TranscriptionMethod ,
519519 Hp, Hc, C,
520520 P, S, E,
521521 ex̂, fx̂, gx̂, jx̂, kx̂, vx̂, bx̂,
@@ -538,7 +538,9 @@ function init_defaultcon_mpc(
538538 C_umin, C_umax, C_Δumin, C_Δumax, C_ymin, C_ymax =
539539 repeat_constraints (Hp, Hc, c_umin, c_umax, c_Δumin, c_Δumax, c_ymin, c_ymax)
540540 A_Umin, A_Umax, S̃ = relaxU (model, nϵ, C_umin, C_umax, S)
541- A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃ = relaxΔU (model, nϵ, C_Δumin, C_Δumax, ΔUmin, ΔUmax, P)
541+ A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃ = relaxΔU (
542+ model, transcription, nϵ, C_Δumin, C_Δumax, ΔUmin, ΔUmax, P
543+ )
542544 A_Ymin, A_Ymax, Ẽ = relaxŶ (model, nϵ, C_ymin, C_ymax, E)
543545 A_x̂min, A_x̂max, ẽx̂ = relaxterminal (model, nϵ, c_x̂min, c_x̂max, ex̂)
544546 A_ŝ, Ẽŝ = augmentdefect (model, nϵ, Eŝ)
@@ -619,15 +621,17 @@ end
619621
620622@doc raw """
621623 relaxΔU(
622- model, nϵ, C_Δumin, C_Δumax, ΔUmin, ΔUmax, P
624+ model, transcription, nϵ, C_Δumin, C_Δumax, ΔUmin, ΔUmax, P
623625 ) -> A_ΔŨmin, A_ΔŨmax, ΔŨmin, ΔŨmax, P̃
624626
625627Augment input increments constraints with slack variable ϵ for softening.
626628
627629Denoting the decision variables augmented with the slack variable
628630``\m athbf{Z̃} = [\b egin{smallmatrix} \m athbf{Z} \\ ϵ \e nd{smallmatrix}]``, it returns the
629631augmented conversion matrix ``\m athbf{P̃}``, similar to the one described at
630- [`init_ZtoΔU`](@ref). Knowing that ``0 ≤ ϵ ≤ ∞``, it also returns the augmented bounds
632+ [`init_ZtoΔU`](@ref), but extracting the input increments augmented with the slack variable
633+ ``\m athbf{ΔŨ} = [\b egin{smallmatrix} \m athbf{ΔU} \\ ϵ \e nd{smallmatrix}] = \m athbf{P̃ Z̃}``.
634+ Also, knowing that ``0 ≤ ϵ ≤ ∞``, it also returns the augmented bounds
631635``\m athbf{ΔŨ_{min}} = [\b egin{smallmatrix} \m athbf{ΔU_{min}} \\ 0 \e nd{smallmatrix}]`` and
632636``\m athbf{ΔŨ_{max}} = [\b egin{smallmatrix} \m athbf{ΔU_{min}} \\ ∞ \e nd{smallmatrix}]``,
633637and the ``\m athbf{A}`` matrices for the inequality constraints:
@@ -646,13 +650,16 @@ bound, which is more specific than a linear inequality constraint. However, it i
646650convenient to treat it as a linear inequality constraint since the optimizer `OSQP.jl` does
647651not support pure bounds on the decision variables.
648652"""
649- function relaxΔU (:: SimModel{NT} , nϵ, C_Δumin, C_Δumax, ΔUmin, ΔUmax, P) where NT<: Real
653+ function relaxΔU (
654+ :: SimModel{NT} , transcription:: TranscriptionMethod ,
655+ nϵ, C_Δumin, C_Δumax, ΔUmin, ΔUmax, P
656+ ) where NT<: Real
650657 nZ = size (P, 2 )
651658 if nϵ == 1 # Z̃ = [Z; ϵ]
652659 ΔŨmin, ΔŨmax = [ΔUmin; NT[0.0 ]], [ΔUmax; NT[Inf ]] # 0 ≤ ϵ ≤ ∞
653660 A_ϵ = [zeros (NT, 1 , nZ) NT[1.0 ]]
654661 A_ΔŨmin, A_ΔŨmax = - [P C_Δumin; A_ϵ], [P - C_Δumax; A_ϵ]
655- P̃ = [P zeros (NT, size (P, 1 ), 1 )]
662+ P̃ = [P zeros (NT, size (P, 1 ), 1 ); zeros (NT, 1 , size (P, 2 )) NT[ 1.0 ] ]
656663 else # Z̃ = Z (only hard constraints)
657664 ΔŨmin, ΔŨmax = ΔUmin, ΔUmax
658665 A_ΔŨmin, A_ΔŨmax = - P, P
0 commit comments