Skip to content

Commit 571362a

Browse files
authored
Merge pull request #363 from JuliaControl/debug_print
debug: adequate padding for MHE dimensions printing
2 parents 93cf9d9 + f65873c commit 571362a

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/estimator/mhe.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
include("mhe/construct.jl")
22
include("mhe/execute.jl")
33

4+
"Return estimation horizon He and slack variables length nε for `MovingHorizonEstimator`."
5+
get_other_dims(estim::MovingHorizonEstimator) = (estim.He, estim.nε)
6+
47
"Print optimizer and other information for `MovingHorizonEstimator`."
58
function print_details(io::IO, estim::MovingHorizonEstimator)
69
println(io, "├ optimizer: $(JuMP.solver_name(estim.optim)) ")

src/predictive_control.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function Base.show(io::IO, mpc::PredictiveController)
3131
Hp, Hc, nϵ = mpc.Hp, mpc.Hc, mpc.
3232
nu, nd = model.nu, model.nd
3333
nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu
34-
n = maximum(ndigits.((Hp, Hc, nu, nx̂, nym, nyu, nd))) + 1
34+
other_dims = get_other_dims(estim)
35+
n = maximum(ndigits.((Hp, Hc, nu, nx̂, nym, nyu, nd, other_dims...))) + 1
3536
println(io, "$(nameof(typeof(mpc))) controller with a sample time Ts = $(model.Ts) s:")
3637
println(io, "├ estimator: $(nameof(typeof(mpc.estim)))")
3738
println(io, "├ model: $(nameof(typeof(model)))")

src/state_estim.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@ function Base.show(io::IO, estim::StateEstimator)
3232
model = estim.model
3333
nu, nd = model.nu, model.nd
3434
nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu
35-
n = maximum(ndigits.((nu, nx̂, nym, nyu, nd))) + 1
35+
other_dims = get_other_dims(estim)
36+
n = maximum(ndigits.((nu, nx̂, nym, nyu, nd, other_dims...))) + 1
3637
println(io, "$(nameof(typeof(estim))) estimator with a sample time Ts = $(model.Ts) s:")
3738
println(io, "├ model: $(nameof(typeof(estim.model)))")
3839
print_details(io, estim)
3940
println(io, "└ dimensions:")
4041
print_estim_dim(io, estim, n)
4142
end
4243

44+
"Return additional dimensions on `estim` if any, for adequate padding with spaces."
45+
get_other_dims(::StateEstimator) = tuple()
46+
4347
"Print additional details of `estim` if any (no details by default)."
4448
print_details(::IO, ::StateEstimator) = nothing
4549

0 commit comments

Comments
 (0)