From 73f4c059ca43bb814aac8a6a380445f8b62e1e43 Mon Sep 17 00:00:00 2001 From: franckgaga Date: Thu, 6 Aug 2026 13:36:52 -0400 Subject: [PATCH 1/2] debug: update state constraints in MHE for `NonLinModel` and `MultipleShooting` --- src/estimator/mhe/transcription.jl | 33 ++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/estimator/mhe/transcription.jl b/src/estimator/mhe/transcription.jl index 82f1dcc2b..a3bf0235b 100644 --- a/src/estimator/mhe/transcription.jl +++ b/src/estimator/mhe/transcription.jl @@ -780,9 +780,38 @@ function linconstraint!( return nothing end -"Set `b` excluding state and sensor noise bounds if `model` is not a [`LinModel`](@ref)." +"Set `b` excluding sensor noise bounds if for `NonLinModel` and non-`SingleShooting`." function linconstraint!( - estim::MovingHorizonEstimator, ::SimModel, ::TranscriptionMethod + estim::MovingHorizonEstimator, ::NonLinModel, ::TranscriptionMethod +) + nx̂, nŵ = estim.nx̂, estim.nx̂ + # --- truncate vector and matrices if necessary --- + X̂0min, X̂0max = trunc_bounds(estim, estim.con.X̂0min, estim.con.X̂0max, nx̂) + Ŵmin, Ŵmax = trunc_bounds(estim, estim.con.Ŵmin, estim.con.Ŵmax, nŵ) + # --- update b vector for linear inequality constraints --- + nx̂, nŴ_He, nX̂_He = length(estim.con.x̂0min), length(Ŵmin), length(X̂0min) + n = 0 + estim.con.b[(n+1):(n+nx̂)] .= @. -estim.con.x̂0min + n += nx̂ + estim.con.b[(n+1):(n+nx̂)] .= @. +estim.con.x̂0max + n += nx̂ + estim.con.b[(n+1):(n+nX̂_He)] .= @. -X̂0min + estim.con.FX̂ + n += nX̂_He + estim.con.b[(n+1):(n+nX̂_He)] .= @. +X̂0max - estim.con.FX̂ + n += nX̂_He + estim.con.b[(n+1):(n+nŴ_He)] .= @. -Ŵmin + n += nŴ_He + estim.con.b[(n+1):(n+nŴ_He)] .= @. +Ŵmax + if any(estim.con.i_b) + lincon = estim.optim[:linconstraint] + JuMP.set_normalized_rhs(lincon, estim.con.b[estim.con.i_b]) + end + return nothing +end + +"Set `b` excluding state and sensor noise bounds for `NonLinModel` and `SingleShooting`." +function linconstraint!( + estim::MovingHorizonEstimator, ::NonLinModel, ::SingleShooting ) # --- truncate vector and matrices if necessary --- Ŵmin, Ŵmax = trunc_bounds(estim, estim.con.Ŵmin, estim.con.Ŵmax, estim.nx̂) From 3eda37f3e783657dfdaead4f805fa46dc8d8ce2b Mon Sep 17 00:00:00 2001 From: franckgaga Date: Thu, 6 Aug 2026 13:37:36 -0400 Subject: [PATCH 2/2] bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index df7a1d617..a315f656a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ModelPredictiveControl" uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c" -version = "2.10.0" +version = "2.10.1" authors = ["Francis Gagnon"] [deps]