Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ModelPredictiveControl"
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
version = "1.14.2"
version = "1.14.3"
authors = ["Francis Gagnon"]

[deps]
Expand Down
4 changes: 2 additions & 2 deletions src/controller/construct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ function init_defaultcon_mpc(
x̂0min, x̂0max = fill(convert(NT,-Inf), nx̂), fill(convert(NT,+Inf), nx̂)
c_umin, c_umax = fill(zero(NT), nu), fill(zero(NT), nu)
c_Δumin, c_Δumax = fill(zero(NT), nu), fill(zero(NT), nu)
c_ymin, c_ymax = fill(one(NT), ny), fill(one(NT), ny)
c_x̂min, c_x̂max = fill(zero(NT), nx̂), fill(zero(NT), nx̂)
c_ymin, c_ymax = fill(one(NT), ny), fill(one(NT), ny)
c_x̂min, c_x̂max = fill(one(NT), nx̂), fill(one(NT), nx̂)
U0min, U0max, ΔUmin, ΔUmax, Y0min, Y0max =
repeat_constraints(Hp, Hc, u0min, u0max, Δumin, Δumax, y0min, y0max)
C_umin, C_umax, C_Δumin, C_Δumax, C_ymin, C_ymax =
Expand Down
10 changes: 10 additions & 0 deletions test/3_test_predictive_control.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ end
model = LinModel(sys, Ts, i_d=[3])
mpc = LinMPC(model, Hp=1, Hc=1)

# test default constraints before modifying any:
@test all((mpc.con.U0min, mpc.con.U0max) .≈ (fill(-Inf, model.nu), fill(Inf, model.nu)))
@test all((mpc.con.ΔŨmin, mpc.con.ΔŨmax) .≈ (vcat(fill(-Inf, model.nu), 0), vcat(fill(Inf, model.nu), Inf)))
@test all((mpc.con.Y0min, mpc.con.Y0max) .≈ (fill(-Inf, model.ny), fill(Inf, model.ny)))
@test all((mpc.con.x̂0min, mpc.con.x̂0max) .≈ (fill(-Inf, mpc.estim.nx̂), fill(Inf, mpc.estim.nx̂)))
@test all((-mpc.con.A_Umin[:, end], -mpc.con.A_Umax[:, end]) .≈ (fill(0.0, model.nu), fill(0.0, model.nu)))
@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)))
@test all((-mpc.con.A_Ymin[:, end], -mpc.con.A_Ymax[:, end]) .≈ (fill(1.0, model.ny), fill(1.0, model.ny)))
@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̂)))

setconstraint!(mpc, umin=[-5, -9.9], umax=[100,99])
@test all((mpc.con.U0min, mpc.con.U0max) .≈ ([-5, -9.9], [100,99]))
setconstraint!(mpc, Δumin=[-5,-10], Δumax=[6,11])
Expand Down