Skip to content

Commit 7dfd65a

Browse files
committed
doc: update jldoctests
1 parent 8096bae commit 7dfd65a

File tree

12 files changed

+201
-146
lines changed

12 files changed

+201
-146
lines changed

src/controller/construct.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,20 @@ constraints are all soft by default. See Extended Help for time-varying constrai
221221
julia> mpc = LinMPC(setop!(LinModel(tf(3, [30, 1]), 4), uop=[50], yop=[25]));
222222
223223
julia> mpc = setconstraint!(mpc, umin=[0], umax=[100], Δumin=[-10], Δumax=[+10])
224-
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SingleShooting transcription, SteadyKalmanFilter estimator and:
225-
10 prediction steps Hp
226-
2 control steps Hc
227-
1 slack variable ϵ (control constraints)
228-
1 manipulated inputs u (0 integrating states)
229-
2 estimated states x̂
230-
1 measured outputs ym (1 integrating states)
231-
0 unmeasured outputs yu
232-
0 measured disturbances d
224+
LinMPC controller with a sample time Ts = 4.0 s:
225+
├ estimator: SteadyKalmanFilter
226+
├ model: LinModel
227+
├ optimizer: OSQP
228+
├ transcription: SingleShooting
229+
└ dimensions:
230+
├ 10 prediction steps Hp
231+
├ 2 control steps Hc
232+
├ 1 slack variable ϵ (control constraints)
233+
├ 1 manipulated inputs u (0 integrating states)
234+
├ 2 estimated states x̂
235+
├ 1 measured outputs ym (1 integrating states)
236+
├ 0 unmeasured outputs yu
237+
└ 0 measured disturbances d
233238
```
234239
235240
# Extended Help

src/controller/explicitmpc.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,15 @@ arguments.
117117
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 4);
118118
119119
julia> mpc = ExplicitMPC(model, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
120-
ExplicitMPC controller with a sample time Ts = 4.0 s, SteadyKalmanFilter estimator and:
121-
30 prediction steps Hp
122-
1 control steps Hc
123-
1 manipulated inputs u (0 integrating states)
124-
4 estimated states x̂
125-
2 measured outputs ym (2 integrating states)
126-
0 unmeasured outputs yu
127-
0 measured disturbances d
120+
ExplicitMPC controller with a sample time Ts = 4.0 s:
121+
├ estimator: SteadyKalmanFilter
122+
├ model: LinModel
123+
└ dimensions:
124+
├ 1 manipulated inputs u (0 integrating states)
125+
├ 4 estimated states x̂
126+
├ 2 measured outputs ym (2 integrating states)
127+
├ 0 unmeasured outputs yu
128+
└ 0 measured disturbances d
128129
```
129130
130131
"""

src/controller/linmpc.jl

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,20 @@ arguments. This controller allocates memory at each time step for the optimizati
168168
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 4);
169169
170170
julia> mpc = LinMPC(model, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
171-
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SingleShooting transcription, SteadyKalmanFilter estimator and:
172-
30 prediction steps Hp
173-
1 control steps Hc
174-
1 slack variable ϵ (control constraints)
175-
1 manipulated inputs u (0 integrating states)
176-
4 estimated states x̂
177-
2 measured outputs ym (2 integrating states)
178-
0 unmeasured outputs yu
179-
0 measured disturbances d
171+
LinMPC controller with a sample time Ts = 4.0 s:
172+
├ estimator: SteadyKalmanFilter
173+
├ model: LinModel
174+
├ optimizer: OSQP
175+
├ transcription: SingleShooting
176+
└ dimensions:
177+
├ 30 prediction steps Hp
178+
├ 1 control steps Hc
179+
├ 1 slack variable ϵ (control constraints)
180+
├ 1 manipulated inputs u (0 integrating states)
181+
├ 4 estimated states x̂
182+
├ 2 measured outputs ym (2 integrating states)
183+
├ 0 unmeasured outputs yu
184+
└ 0 measured disturbances d
180185
```
181186
182187
# Extended Help
@@ -238,15 +243,20 @@ Use custom state estimator `estim` to construct `LinMPC`.
238243
julia> estim = KalmanFilter(LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 4), i_ym=[2]);
239244
240245
julia> mpc = LinMPC(estim, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
241-
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SingleShooting transcription, KalmanFilter estimator and:
242-
30 prediction steps Hp
243-
1 control steps Hc
244-
1 slack variable ϵ (control constraints)
245-
1 manipulated inputs u (0 integrating states)
246-
3 estimated states x̂
247-
1 measured outputs ym (1 integrating states)
248-
1 unmeasured outputs yu
249-
0 measured disturbances d
246+
LinMPC controller with a sample time Ts = 4.0 s:
247+
├ estimator: KalmanFilter
248+
├ model: LinModel
249+
├ optimizer: OSQP
250+
├ transcription: SingleShooting
251+
└ dimensions:
252+
├ 30 prediction steps Hp
253+
├ 1 control steps Hc
254+
├ 1 slack variable ϵ (control constraints)
255+
├ 1 manipulated inputs u (0 integrating states)
256+
├ 3 estimated states x̂
257+
├ 1 measured outputs ym (1 integrating states)
258+
├ 1 unmeasured outputs yu
259+
└ 0 measured disturbances d
250260
```
251261
"""
252262
function LinMPC(

src/controller/nonlinmpc.jl

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,20 @@ This controller allocates memory at each time step for the optimization.
224224
julia> model = NonLinModel((x,u,_,_)->0.5x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver=nothing);
225225
226226
julia> mpc = NonLinMPC(model, Hp=20, Hc=1, Cwt=1e6)
227-
NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, SingleShooting transcription, UnscentedKalmanFilter estimator and:
228-
20 prediction steps Hp
229-
1 control steps Hc
230-
1 slack variable ϵ (control constraints)
231-
1 manipulated inputs u (0 integrating states)
232-
2 estimated states x̂
233-
1 measured outputs ym (1 integrating states)
234-
0 unmeasured outputs yu
235-
0 measured disturbances d
227+
NonLinMPC controller with a sample time Ts = 10.0 s:
228+
├ estimator: UnscentedKalmanFilter
229+
├ model: NonLinModel
230+
├ optimizer: Ipopt
231+
├ transcription: SingleShooting
232+
└ dimensions:
233+
├ 20 prediction steps Hp
234+
├ 1 control steps Hc
235+
├ 1 slack variable ϵ (control constraints)
236+
├ 1 manipulated inputs u (0 integrating states)
237+
├ 2 estimated states x̂
238+
├ 1 measured outputs ym (1 integrating states)
239+
├ 0 unmeasured outputs yu
240+
└ 0 measured disturbances d
236241
```
237242
238243
# Extended Help
@@ -328,15 +333,20 @@ julia> model = NonLinModel((x,u,_,_)->0.5x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver
328333
julia> estim = UnscentedKalmanFilter(model, σQint_ym=[0.05]);
329334
330335
julia> mpc = NonLinMPC(estim, Hp=20, Hc=1, Cwt=1e6)
331-
NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, SingleShooting transcription, UnscentedKalmanFilter estimator and:
332-
20 prediction steps Hp
333-
1 control steps Hc
334-
1 slack variable ϵ (control constraints)
335-
1 manipulated inputs u (0 integrating states)
336-
2 estimated states x̂
337-
1 measured outputs ym (1 integrating states)
338-
0 unmeasured outputs yu
339-
0 measured disturbances d
336+
NonLinMPC controller with a sample time Ts = 10.0 s:
337+
├ estimator: UnscentedKalmanFilter
338+
├ model: NonLinModel
339+
├ optimizer: Ipopt
340+
├ transcription: SingleShooting
341+
└ dimensions:
342+
├ 20 prediction steps Hp
343+
├ 1 control steps Hc
344+
├ 1 slack variable ϵ (control constraints)
345+
├ 1 manipulated inputs u (0 integrating states)
346+
├ 2 estimated states x̂
347+
├ 1 measured outputs ym (1 integrating states)
348+
├ 0 unmeasured outputs yu
349+
└ 0 measured disturbances d
340350
```
341351
"""
342352
function NonLinMPC(

src/estimator/internal_model.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ estimator is allocation-free if `model` simulations do not allocate.
8080
# Examples
8181
```jldoctest
8282
julia> estim = InternalModel(LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5), i_ym=[2])
83-
InternalModel estimator with a sample time Ts = 0.5 s, LinModel and:
84-
1 manipulated inputs u
85-
2 estimated states x̂
86-
1 measured outputs ym
87-
1 unmeasured outputs yu
88-
0 measured disturbances d
83+
InternalModel estimator with a sample time Ts = 0.5 s:
84+
├ model: LinModel
85+
└ dimensions:
86+
├ 1 manipulated inputs u
87+
├ 2 estimated states x̂
88+
├ 1 measured outputs ym
89+
├ 1 unmeasured outputs yu
90+
└ 0 measured disturbances d
8991
```
9092
9193
# Extended Help

src/estimator/kalman.jl

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@ state of the next time step ``\mathbf{x̂}_k(k+1)``. This estimator is allocatio
130130
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
131131
132132
julia> estim = SteadyKalmanFilter(model, i_ym=[2], σR=[1], σQint_ym=[0.01])
133-
SteadyKalmanFilter estimator with a sample time Ts = 0.5 s, LinModel and:
134-
1 manipulated inputs u (0 integrating states)
135-
3 estimated states x̂
136-
1 measured outputs ym (1 integrating states)
137-
1 unmeasured outputs yu
138-
0 measured disturbances d
133+
SteadyKalmanFilter estimator with a sample time Ts = 0.5 s:
134+
├ model: LinModel
135+
└ dimensions:
136+
├ 1 manipulated inputs u (0 integrating states)
137+
├ 3 estimated states x̂
138+
├ 1 measured outputs ym (1 integrating states)
139+
├ 1 unmeasured outputs yu
140+
└ 0 measured disturbances d
139141
```
140142
141143
# Extended Help
@@ -395,12 +397,14 @@ This estimator is allocation-free.
395397
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
396398
397399
julia> estim = KalmanFilter(model, i_ym=[2], σR=[1], σP_0=[100, 100], σQint_ym=[0.01])
398-
KalmanFilter estimator with a sample time Ts = 0.5 s, LinModel and:
399-
1 manipulated inputs u (0 integrating states)
400-
3 estimated states x̂
401-
1 measured outputs ym (1 integrating states)
402-
1 unmeasured outputs yu
403-
0 measured disturbances d
400+
KalmanFilter estimator with a sample time Ts = 0.5 s:
401+
├ model: LinModel
402+
└ dimensions:
403+
├ 1 manipulated inputs u (0 integrating states)
404+
├ 3 estimated states x̂
405+
├ 1 measured outputs ym (1 integrating states)
406+
├ 1 unmeasured outputs yu
407+
└ 0 measured disturbances d
404408
```
405409
"""
406410
function KalmanFilter(
@@ -639,12 +643,14 @@ This estimator is allocation-free if `model` simulations do not allocate.
639643
julia> model = NonLinModel((x,u,_,_)->0.1x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver=nothing);
640644
641645
julia> estim = UnscentedKalmanFilter(model, σR=[1], nint_ym=[2], σPint_ym_0=[1, 1])
642-
UnscentedKalmanFilter estimator with a sample time Ts = 10.0 s, NonLinModel and:
643-
1 manipulated inputs u (0 integrating states)
644-
3 estimated states x̂
645-
1 measured outputs ym (2 integrating states)
646-
0 unmeasured outputs yu
647-
0 measured disturbances d
646+
UnscentedKalmanFilter estimator with a sample time Ts = 10.0 s:
647+
├ model: NonLinModel
648+
└ dimensions:
649+
├ 1 manipulated inputs u (0 integrating states)
650+
├ 3 estimated states x̂
651+
├ 1 measured outputs ym (2 integrating states)
652+
├ 0 unmeasured outputs yu
653+
└ 0 measured disturbances d
648654
```
649655
650656
# Extended Help
@@ -1002,12 +1008,14 @@ differentiation. This estimator is allocation-free if `model` simulations do not
10021008
julia> model = NonLinModel((x,u,_,_)->0.2x+u, (x,_,_)->-3x, 5.0, 1, 1, 1, solver=nothing);
10031009
10041010
julia> estim = ExtendedKalmanFilter(model, σQ=[2], σQint_ym=[2], σP_0=[0.1], σPint_ym_0=[0.1])
1005-
ExtendedKalmanFilter estimator with a sample time Ts = 5.0 s, NonLinModel and:
1006-
1 manipulated inputs u (0 integrating states)
1007-
2 estimated states x̂
1008-
1 measured outputs ym (1 integrating states)
1009-
0 unmeasured outputs yu
1010-
0 measured disturbances d
1011+
ExtendedKalmanFilter estimator with a sample time Ts = 5.0 s:
1012+
├ model: NonLinModel
1013+
└ dimensions:
1014+
├ 1 manipulated inputs u (0 integrating states)
1015+
├ 2 estimated states x̂
1016+
├ 1 measured outputs ym (1 integrating states)
1017+
├ 0 unmeasured outputs yu
1018+
└ 0 measured disturbances d
10111019
```
10121020
"""
10131021
function ExtendedKalmanFilter(

src/estimator/luenberger.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,14 @@ is allocation-free.
8383
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
8484
8585
julia> estim = Luenberger(model, nint_ym=[1, 1], poles=[0.61, 0.62, 0.63, 0.64])
86-
Luenberger estimator with a sample time Ts = 0.5 s, LinModel and:
87-
1 manipulated inputs u (0 integrating states)
88-
4 estimated states x̂
89-
2 measured outputs ym (2 integrating states)
90-
0 unmeasured outputs yu
91-
0 measured disturbances d
86+
Luenberger estimator with a sample time Ts = 0.5 s:
87+
├ model: LinModel
88+
└ dimensions:
89+
├ 1 manipulated inputs u (0 integrating states)
90+
├ 4 estimated states x̂
91+
├ 2 measured outputs ym (2 integrating states)
92+
├ 0 unmeasured outputs yu
93+
└ 0 measured disturbances d
9294
```
9395
"""
9496
function Luenberger(

src/estimator/manual.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ examples.
7777
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
7878
7979
julia> estim = ManualEstimator(model, nint_ym=0) # disable augmentation with integrators
80-
ManualEstimator estimator with a sample time Ts = 0.5 s, LinModel and:
81-
1 manipulated inputs u (0 integrating states)
82-
2 estimated states x̂
83-
2 measured outputs ym (0 integrating states)
84-
0 unmeasured outputs yu
85-
0 measured disturbances d
80+
ManualEstimator estimator with a sample time Ts = 0.5 s:
81+
├ model: LinModel
82+
└ dimensions:
83+
├ 1 manipulated inputs u (0 integrating states)
84+
├ 2 estimated states x̂
85+
├ 2 measured outputs ym (0 integrating states)
86+
├ 0 unmeasured outputs yu
87+
└ 0 measured disturbances d
8688
```
8789
8890
# Extended Help

src/estimator/mhe/construct.jl

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,17 @@ transcription for now.
275275
julia> model = NonLinModel((x,u,_,_)->0.1x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver=nothing);
276276
277277
julia> estim = MovingHorizonEstimator(model, He=5, σR=[1], σP_0=[0.01])
278-
MovingHorizonEstimator estimator with a sample time Ts = 10.0 s, Ipopt optimizer, NonLinModel and:
279-
5 estimation steps He
280-
0 slack variable ϵ (estimation constraints)
281-
1 manipulated inputs u (0 integrating states)
282-
2 estimated states x̂
283-
1 measured outputs ym (1 integrating states)
284-
0 unmeasured outputs yu
285-
0 measured disturbances d
278+
MovingHorizonEstimator estimator with a sample time Ts = 10.0 s:
279+
├ model: NonLinModel
280+
├ optimizer: Ipopt
281+
└ dimensions:
282+
├ 5 estimation steps He
283+
├ 0 slack variable ϵ (estimation constraints)
284+
├ 1 manipulated inputs u (0 integrating states)
285+
├ 2 estimated states x̂
286+
├ 1 measured outputs ym (1 integrating states)
287+
├ 0 unmeasured outputs yu
288+
└ 0 measured disturbances d
286289
```
287290
288291
# Extended Help
@@ -490,14 +493,17 @@ the constant ``p``, on model augmentation and on time-varying constraints.
490493
julia> estim = MovingHorizonEstimator(LinModel(ss(0.5,1,1,0,1)), He=3);
491494
492495
julia> estim = setconstraint!(estim, x̂min=[-50, -50], x̂max=[50, 50])
493-
MovingHorizonEstimator estimator with a sample time Ts = 1.0 s, OSQP optimizer, LinModel and:
494-
3 estimation steps He
495-
0 slack variable ϵ (estimation constraints)
496-
1 manipulated inputs u (0 integrating states)
497-
2 estimated states x̂
498-
1 measured outputs ym (1 integrating states)
499-
0 unmeasured outputs yu
500-
0 measured disturbances d
496+
MovingHorizonEstimator estimator with a sample time Ts = 1.0 s:
497+
├ model: LinModel
498+
├ optimizer: OSQP
499+
└ dimensions:
500+
├ 3 estimation steps He
501+
├ 0 slack variable ϵ (estimation constraints)
502+
├ 1 manipulated inputs u (0 integrating states)
503+
├ 2 estimated states x̂
504+
├ 1 measured outputs ym (1 integrating states)
505+
├ 0 unmeasured outputs yu
506+
└ 0 measured disturbances d
501507
```
502508
503509
# Extended Help

0 commit comments

Comments
 (0)