Skip to content

Commit 7843035

Browse files
committed
added : show integrators info when printing StateEstimator and PredictiveController
1 parent 543102e commit 7843035

File tree

9 files changed

+39
-28
lines changed

9 files changed

+39
-28
lines changed

docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ The objective is to provide a simple and clear framework to quickly design model
1010
controllers (MPCs) in Julia, while preserving the flexibility for advanced real-time
1111
optimization. Modern MPCs based on closed-loop state estimators are the main focus of the
1212
package, but classical approaches that rely on internal models are also possible. The
13-
`JuMP.jl` interface allows to easily test different solvers if the performance of the
14-
default settings is not satisfactory.
13+
`JuMP.jl` interface allows the user to test different solvers easily if the performance of
14+
the default settings is not satisfactory.
1515

1616
The documentation is divided in two parts:
1717

src/controller/explicitmpc.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ julia> mpc = ExplicitMPC(model, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
105105
ExplicitMPC controller with a sample time Ts = 4.0 s, SteadyKalmanFilter estimator and:
106106
30 prediction steps Hp
107107
1 control steps Hc
108-
1 manipulated inputs u
108+
1 manipulated inputs u (0 integrators)
109109
4 states x̂
110-
2 measured outputs ym
110+
2 measured outputs ym (2 integrators)
111111
0 unmeasured outputs yu
112112
0 measured disturbances d
113113
```
@@ -130,9 +130,9 @@ julia> mpc = ExplicitMPC(estim, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
130130
ExplicitMPC controller with a sample time Ts = 4.0 s, KalmanFilter estimator and:
131131
30 prediction steps Hp
132132
1 control steps Hc
133-
1 manipulated inputs u
133+
1 manipulated inputs u (0 integrators)
134134
3 states x̂
135-
1 measured outputs ym
135+
1 measured outputs ym (1 integrators)
136136
1 unmeasured outputs yu
137137
0 measured disturbances d
138138
```

src/controller/linmpc.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ julia> mpc = LinMPC(model, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
121121
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SteadyKalmanFilter estimator and:
122122
30 prediction steps Hp
123123
1 control steps Hc
124-
1 manipulated inputs u
124+
1 manipulated inputs u (0 integrators)
125125
4 states x̂
126-
2 measured outputs ym
126+
2 measured outputs ym (2 integrators)
127127
0 unmeasured outputs yu
128128
0 measured disturbances d
129129
```
@@ -168,9 +168,9 @@ julia> mpc = LinMPC(estim, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
168168
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, KalmanFilter estimator and:
169169
30 prediction steps Hp
170170
1 control steps Hc
171-
1 manipulated inputs u
171+
1 manipulated inputs u (0 integrators)
172172
3 states x̂
173-
1 measured outputs ym
173+
1 measured outputs ym (1 integrators)
174174
1 unmeasured outputs yu
175175
0 measured disturbances d
176176
```

src/controller/nonlinmpc.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ julia> mpc = NonLinMPC(model, Hp=20, Hc=1, Cwt=1e6)
135135
NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedKalmanFilter estimator and:
136136
20 prediction steps Hp
137137
1 control steps Hc
138-
1 manipulated inputs u
138+
1 manipulated inputs u (0 integrators)
139139
2 states x̂
140-
1 measured outputs ym
140+
1 measured outputs ym (1 integrators)
141141
0 unmeasured outputs yu
142142
0 measured disturbances d
143143
```
@@ -172,9 +172,9 @@ julia> mpc = NonLinMPC(estim, Hp=20, Hc=1, Cwt=1e6)
172172
NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedKalmanFilter estimator and:
173173
20 prediction steps Hp
174174
1 control steps Hc
175-
1 manipulated inputs u
175+
1 manipulated inputs u (0 integrators)
176176
2 states x̂
177-
1 measured outputs ym
177+
1 measured outputs ym (1 integrators)
178178
0 unmeasured outputs yu
179179
0 measured disturbances d
180180
```

src/estimator/internal_model.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,5 +236,16 @@ function evaloutput(estim::InternalModel, ym, d=Float64[])
236236
return
237237
end
238238

239+
"Print InternalModel information without i/o integrators."
240+
function print_estim_dim(io::IO, estim::InternalModel, n)
241+
nu, nd = estim.model.nu, estim.model.nd
242+
nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu
243+
println(io, "$(lpad(nu, n)) manipulated inputs u")
244+
println(io, "$(lpad(nx̂, n)) states x̂")
245+
println(io, "$(lpad(nym, n)) measured outputs ym")
246+
println(io, "$(lpad(nyu, n)) unmeasured outputs yu")
247+
print(io, "$(lpad(nd, n)) measured disturbances d")
248+
end
249+
239250
(estim::InternalModel)(ym, d=Float64[]) = evaloutput(estim::InternalModel, ym, d)
240251

src/estimator/kalman.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
108108
109109
julia> estim = SteadyKalmanFilter(model, i_ym=[2], σR=[1], σQint_ym=[0.01])
110110
SteadyKalmanFilter estimator with a sample time Ts = 0.5 s, LinModel and:
111-
1 manipulated inputs u
111+
1 manipulated inputs u (0 integrators)
112112
3 states x̂
113-
1 measured outputs ym
113+
1 measured outputs ym (1 integrators)
114114
1 unmeasured outputs yu
115115
0 measured disturbances d
116116
```
@@ -260,9 +260,9 @@ julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
260260
261261
julia> estim = KalmanFilter(model, i_ym=[2], σR=[1], σP0=[100, 100], σQint_ym=[0.01])
262262
KalmanFilter estimator with a sample time Ts = 0.5 s, LinModel and:
263-
1 manipulated inputs u
263+
1 manipulated inputs u (0 integrators)
264264
3 states x̂
265-
1 measured outputs ym
265+
1 measured outputs ym (1 integrators)
266266
1 unmeasured outputs yu
267267
0 measured disturbances d
268268
```
@@ -418,9 +418,9 @@ julia> model = NonLinModel((x,u,_)->0.1x+u, (x,_)->2x, 10.0, 1, 1, 1);
418418
419419
julia> estim = UnscentedKalmanFilter(model, σR=[1], nint_ym=[2], σP0int_ym=[1, 1])
420420
UnscentedKalmanFilter estimator with a sample time Ts = 10.0 s, NonLinModel and:
421-
1 manipulated inputs u
421+
1 manipulated inputs u (0 integrators)
422422
3 states x̂
423-
1 measured outputs ym
423+
1 measured outputs ym (2 integrators)
424424
0 unmeasured outputs yu
425425
0 measured disturbances d
426426
```
@@ -646,9 +646,9 @@ julia> model = NonLinModel((x,u,_)->0.2x+u, (x,_)->-3x, 5.0, 1, 1, 1);
646646
647647
julia> estim = ExtendedKalmanFilter(model, σQ=[2], σQint_ym=[2], σP0=[0.1], σP0int_ym=[0.1])
648648
ExtendedKalmanFilter estimator with a sample time Ts = 5.0 s, NonLinModel and:
649-
1 manipulated inputs u
649+
1 manipulated inputs u (0 integrators)
650650
2 states x̂
651-
1 measured outputs ym
651+
1 measured outputs ym (1 integrators)
652652
0 unmeasured outputs yu
653653
0 measured disturbances d
654654
```

src/estimator/luenberger.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
7070
7171
julia> estim = Luenberger(model, nint_ym=[1, 1], p̂=[0.61, 0.62, 0.63, 0.64])
7272
Luenberger estimator with a sample time Ts = 0.5 s, LinModel and:
73-
1 manipulated inputs u
73+
1 manipulated inputs u (0 integrators)
7474
4 states x̂
75-
2 measured outputs ym
75+
2 measured outputs ym (2 integrators)
7676
0 unmeasured outputs yu
7777
0 measured disturbances d
7878
```

src/predictive_control.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ julia> mpc = setconstraint!(mpc, Δumin=[-10], Δumax=[+10], c_Δumin=[1.0], c_
9696
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SteadyKalmanFilter estimator and:
9797
10 prediction steps Hp
9898
2 control steps Hc
99-
1 manipulated inputs u
99+
1 manipulated inputs u (0 integrators)
100100
2 states x̂
101-
1 measured outputs ym
101+
1 measured outputs ym (1 integrators)
102102
0 unmeasured outputs yu
103103
0 measured disturbances d
104104
```

src/state_estim.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ end
4646
function print_estim_dim(io::IO, estim::StateEstimator, n)
4747
nu, nd = estim.model.nu, estim.model.nd
4848
nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu
49-
println(io, "$(lpad(nu, n)) manipulated inputs u")
49+
println(io, "$(lpad(nu, n)) manipulated inputs u ($(sum(estim.nint_u)) integrators)")
5050
println(io, "$(lpad(nx̂, n)) states x̂")
51-
println(io, "$(lpad(nym, n)) measured outputs ym")
51+
println(io, "$(lpad(nym, n)) measured outputs ym ($(sum(estim.nint_ym)) integrators)")
5252
println(io, "$(lpad(nyu, n)) unmeasured outputs yu")
5353
print(io, "$(lpad(nd, n)) measured disturbances d")
5454
end

0 commit comments

Comments
 (0)