Skip to content

Commit fcfc2fe

Browse files
committed
changed: better conversion factor for soft_weight
The "Prioritized Constraints in Optimization-Based Control" paper indicated that the ρ weight is squared, and there is one term for each soft bound. So a `sqrt` relation is more logical here (Cwt is not squared in MPC.jl). And it is indeed a better approximate conversion factor, according to various simulations on a SISO system.
1 parent ca5b230 commit fcfc2fe

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

ext/LinearMPCext.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ function Base.convert(::Type{LinearMPC.MPC}, mpc::ModelPredictiveControl.LinMPC)
4040
# ---- Constraint softening ---
4141
only_hard = weights.isinf_C
4242
if !only_hard
43-
# LinearMPC relies on a different softening mechanism (new implicit slack for each
43+
# LinearMPC relies on a different softening mechanism (new implicit slacks for each
4444
# softened bounds), so we apply an approximate conversion factor on the Cwt weight:
45-
nsoft = sum((mpc.con.A[:,end] .< 0) .& (mpc.con.i_b)) - 1
46-
conversion_factor = 1/2/nsoft
4745
Cwt = weights.Ñ_Hc[end, end]
48-
newmpc.settings.soft_weight = conversion_factor*Cwt
46+
nsoft = sum((mpc.con.A[:,end] .< 0) .& (mpc.con.i_b)) - 1
47+
newmpc.settings.soft_weight = 10*sqrt(nsoft*Cwt)
4948
C_u = -mpc.con.A_Umin[:, end]
5049
C_Δu = -mpc.con.A_ΔŨmin[1:nΔU, end]
5150
C_y = -mpc.con.A_Ymin[:, end]

0 commit comments

Comments
 (0)