From f65873c548083d2f95f6d87578bcbb4a8d1ccb5c Mon Sep 17 00:00:00 2001 From: franckgaga Date: Thu, 28 May 2026 09:17:15 -0400 Subject: [PATCH] debug: adequate padding for MHE dimensions printing --- src/estimator/mhe.jl | 3 +++ src/predictive_control.jl | 3 ++- src/state_estim.jl | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/estimator/mhe.jl b/src/estimator/mhe.jl index 00585365d..5066f48d5 100644 --- a/src/estimator/mhe.jl +++ b/src/estimator/mhe.jl @@ -1,6 +1,9 @@ include("mhe/construct.jl") include("mhe/execute.jl") +"Return estimation horizon He and slack variables length nε for `MovingHorizonEstimator`." +get_other_dims(estim::MovingHorizonEstimator) = (estim.He, estim.nε) + "Print optimizer and other information for `MovingHorizonEstimator`." function print_details(io::IO, estim::MovingHorizonEstimator) println(io, "├ optimizer: $(JuMP.solver_name(estim.optim)) ") diff --git a/src/predictive_control.jl b/src/predictive_control.jl index 2cbeffa37..11691b1e5 100644 --- a/src/predictive_control.jl +++ b/src/predictive_control.jl @@ -31,7 +31,8 @@ function Base.show(io::IO, mpc::PredictiveController) Hp, Hc, nϵ = mpc.Hp, mpc.Hc, mpc.nϵ nu, nd = model.nu, model.nd nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu - n = maximum(ndigits.((Hp, Hc, nu, nx̂, nym, nyu, nd))) + 1 + other_dims = get_other_dims(estim) + n = maximum(ndigits.((Hp, Hc, nu, nx̂, nym, nyu, nd, other_dims...))) + 1 println(io, "$(nameof(typeof(mpc))) controller with a sample time Ts = $(model.Ts) s:") println(io, "├ estimator: $(nameof(typeof(mpc.estim)))") println(io, "├ model: $(nameof(typeof(model)))") diff --git a/src/state_estim.jl b/src/state_estim.jl index 778c96406..7c8644fd1 100644 --- a/src/state_estim.jl +++ b/src/state_estim.jl @@ -32,7 +32,8 @@ function Base.show(io::IO, estim::StateEstimator) model = estim.model nu, nd = model.nu, model.nd nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu - n = maximum(ndigits.((nu, nx̂, nym, nyu, nd))) + 1 + other_dims = get_other_dims(estim) + n = maximum(ndigits.((nu, nx̂, nym, nyu, nd, other_dims...))) + 1 println(io, "$(nameof(typeof(estim))) estimator with a sample time Ts = $(model.Ts) s:") println(io, "├ model: $(nameof(typeof(estim.model)))") print_details(io, estim) @@ -40,6 +41,9 @@ function Base.show(io::IO, estim::StateEstimator) print_estim_dim(io, estim, n) end +"Return additional dimensions on `estim` if any, for adequate padding with spaces." +get_other_dims(::StateEstimator) = tuple() + "Print additional details of `estim` if any (no details by default)." print_details(::IO, ::StateEstimator) = nothing