From 0d2a5ae87ee95da59fb3674c0b02cd91092499ea Mon Sep 17 00:00:00 2001 From: franckgaga Date: Thu, 18 Dec 2025 12:48:09 -0500 Subject: [PATCH 1/3] debug: terminal constraint softness to `1.0` by default This is what is written in the documentation and the logical default, since a terminal constraint can lead to infeasibility. --- src/controller/construct.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controller/construct.jl b/src/controller/construct.jl index 3cc4880d8..008443f53 100644 --- a/src/controller/construct.jl +++ b/src/controller/construct.jl @@ -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 = From c7efa1c787b3c47e2b58684c53774a4515a27de1 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Thu, 18 Dec 2025 13:18:51 -0500 Subject: [PATCH 2/3] test: verifying default constraint parameters --- test/3_test_predictive_control.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/3_test_predictive_control.jl b/test/3_test_predictive_control.jl index 447cdee57..f94890174 100644 --- a/test/3_test_predictive_control.jl +++ b/test/3_test_predictive_control.jl @@ -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]) From f0186d7ba57a8c4f85e74db764a0d20d0a131097 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Thu, 18 Dec 2025 13:19:10 -0500 Subject: [PATCH 3/3] bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7c2239310..b4bb5276f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ModelPredictiveControl" uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c" -version = "1.14.2" +version = "1.14.3" authors = ["Francis Gagnon"] [deps]