Skip to content

Commit 81b2f31

Browse files
authored
Merge pull request #299 from JuliaControl/debug_terminal_softness
debug: default terminal constraint softness parameters `c_x̂min`/`max` equal to 1
2 parents 51cc8ad + f0186d7 commit 81b2f31

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ModelPredictiveControl"
22
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
3-
version = "1.14.2"
3+
version = "1.14.3"
44
authors = ["Francis Gagnon"]
55

66
[deps]

src/controller/construct.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,8 @@ function init_defaultcon_mpc(
661661
x̂0min, x̂0max = fill(convert(NT,-Inf), nx̂), fill(convert(NT,+Inf), nx̂)
662662
c_umin, c_umax = fill(zero(NT), nu), fill(zero(NT), nu)
663663
c_Δumin, c_Δumax = fill(zero(NT), nu), fill(zero(NT), nu)
664-
c_ymin, c_ymax = fill(one(NT), ny), fill(one(NT), ny)
665-
c_x̂min, c_x̂max = fill(zero(NT), nx̂), fill(zero(NT), nx̂)
664+
c_ymin, c_ymax = fill(one(NT), ny), fill(one(NT), ny)
665+
c_x̂min, c_x̂max = fill(one(NT), nx̂), fill(one(NT), nx̂)
666666
U0min, U0max, ΔUmin, ΔUmax, Y0min, Y0max =
667667
repeat_constraints(Hp, Hc, u0min, u0max, Δumin, Δumax, y0min, y0max)
668668
C_umin, C_umax, C_Δumin, C_Δumax, C_ymin, C_ymax =

test/3_test_predictive_control.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ end
244244
model = LinModel(sys, Ts, i_d=[3])
245245
mpc = LinMPC(model, Hp=1, Hc=1)
246246

247+
# test default constraints before modifying any:
248+
@test all((mpc.con.U0min, mpc.con.U0max) .≈ (fill(-Inf, model.nu), fill(Inf, model.nu)))
249+
@test all((mpc.con.ΔŨmin, mpc.con.ΔŨmax) .≈ (vcat(fill(-Inf, model.nu), 0), vcat(fill(Inf, model.nu), Inf)))
250+
@test all((mpc.con.Y0min, mpc.con.Y0max) .≈ (fill(-Inf, model.ny), fill(Inf, model.ny)))
251+
@test all((mpc.con.x̂0min, mpc.con.x̂0max) .≈ (fill(-Inf, mpc.estim.nx̂), fill(Inf, mpc.estim.nx̂)))
252+
@test all((-mpc.con.A_Umin[:, end], -mpc.con.A_Umax[:, end]) .≈ (fill(0.0, model.nu), fill(0.0, model.nu)))
253+
@test all((-mpc.con.A_ΔŨmin[1:end-1, end], -mpc.con.A_ΔŨmax[1:end-1, end]) .≈ (fill(0.0, model.nu), fill(0.0, model.nu)))
254+
@test all((-mpc.con.A_Ymin[:, end], -mpc.con.A_Ymax[:, end]) .≈ (fill(1.0, model.ny), fill(1.0, model.ny)))
255+
@test all((-mpc.con.A_x̂min[:, end], -mpc.con.A_x̂max[:, end]) .≈ (fill(1.0, mpc.estim.nx̂), fill(1.0, mpc.estim.nx̂)))
256+
247257
setconstraint!(mpc, umin=[-5, -9.9], umax=[100,99])
248258
@test all((mpc.con.U0min, mpc.con.U0max) .≈ ([-5, -9.9], [100,99]))
249259
setconstraint!(mpc, Δumin=[-5,-10], Δumax=[6,11])

0 commit comments

Comments
 (0)