Skip to content

Commit 6ab650a

Browse files
authored
Merge pull request #477 from JuliaControl/doc_cleanup
doc: various cleanup in the manual + removed `CompatHelper`
2 parents 76b41ae + 32e086c commit 6ab650a

6 files changed

Lines changed: 69 additions & 75 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
22
version: 2
33
updates:
4-
- package-ecosystem: "github-actions"
5-
directory: "/" # Location of package manifests
6-
schedule:
7-
interval: "weekly"
84
- package-ecosystem: "julia"
9-
directory: "/"
5+
directories: # Location of Julia projects
6+
- "/"
7+
- "/docs"
8+
- "/test"
9+
- "/benchmark"
1010
schedule:
11-
interval: "weekly"
12-
# groups: # uncomment to group all julia package updates into a single PR
13-
# all-julia-packages:
14-
# patterns:
15-
# - "*"
11+
interval: "weekly"

‎.github/workflows/CompatHelper.yml‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ModelPredictiveControl"
22
uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c"
3-
version = "2.15.0"
3+
version = "2.15.1"
44
authors = ["Francis Gagnon"]
55

66
[deps]

‎docs/src/manual/mtk.md‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
Pages = ["mtk.md"]
55
```
66

7-
```@setup 1
8-
using Logging; errlogger = ConsoleLogger(stderr, Error);
9-
old_logger = global_logger(); global_logger(errlogger);
10-
```
11-
127
## Pendulum Model
138

149
This example integrates the simple pendulum model of the [penultimate section](@ref man_nonlin)
@@ -150,27 +145,30 @@ The 180° setpoint response is identical:
150145
using Plots
151146
N = 35
152147
using JuMP; unset_time_limit_sec(nmpc.optim) # hide
148+
using Logging # hide
149+
res_ry = with_logger(ConsoleLogger(stderr, Error)) do # hide
153150
res_ry = sim!(nmpc, N, [180.0], plant=plant, x_0=[0, 0], x̂_0=[0, 0, 0])
154-
plot(res_ry)
155-
savefig("plot1_MTK.svg"); nothing # hide
151+
end #
152+
p = plot(res_ry)
153+
savefig(p, "plot1_MTK.svg") # hide
154+
display(p) # hide
156155
```
157156

158157
![plot1_MTK](plot1_MTK.svg)
159158

160159
and also the output disturbance rejection:
161160

162161
```@example 1
162+
res_yd = with_logger(ConsoleLogger(stderr, Error)) do # hide
163163
res_yd = sim!(nmpc, N, [180.0], plant=plant, x_0=[0, π], x̂_0=[0, π, 0], y_step=[10])
164-
plot(res_yd)
165-
savefig("plot2_MTK.svg"); nothing # hide
164+
end # hide
165+
p = plot(res_yd)
166+
savefig(p, "plot2_MTK.svg") # hide
167+
display(p) # hide
166168
```
167169

168170
![plot2_MTK](plot2_MTK.svg)
169171

170172
## Acknowledgement
171173

172174
Authored by `1-Bart-1` and `baggepinnen`, thanks for the contribution.
173-
174-
```@setup 1
175-
global_logger(old_logger);
176-
```

‎docs/src/manual/nonlinmpc1.md‎

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ using Plots
7373
u = [0.5]
7474
N = 35
7575
res = sim!(model, N, u)
76-
plot(res, plotu=false)
77-
savefig("plot1_NonLinMPC.svg"); nothing # hide
76+
p = plot(res, plotu=false)
77+
savefig(p, "plot1_NonLinMPC.svg") # hide
78+
display(p) # hide
7879
```
7980

8081
![plot1_NonLinMPC](plot1_NonLinMPC.svg)
@@ -103,9 +104,11 @@ estimator tuning is tested on a plant with a 25 % larger friction coefficient ``
103104
p_plant = copy(p_model)
104105
p_plant[3] = 1.25*p_model[3]
105106
plant = setname!(NonLinModel(f, h, Ts, nu, nx, ny; p=p_plant); u=vu, x=vx, y=vy)
107+
using Random; Random.seed!(2944) # hide
106108
res = sim!(estim, N, [0.5], plant=plant, y_noise=[0.5])
107-
plot(res, plotu=false, plotxwithx̂=true)
108-
savefig("plot2_NonLinMPC.svg"); nothing # hide
109+
p = plot(res, plotu=false, plotxwithx̂=true)
110+
savefig(p, "plot2_NonLinMPC.svg") # hide
111+
display(p) # hide
109112
```
110113

111114
![plot2_NonLinMPC](plot2_NonLinMPC.svg)
@@ -132,8 +135,9 @@ The option `Cwt=Inf` disables the slack variable `ϵ` for constraint softening.
132135
using JuMP; unset_time_limit_sec(nmpc.optim) # hide
133136
ry = [180.0]
134137
res_ry = sim!(nmpc, N, ry, plant=plant, x_0=[0, 0], x̂_0=[0, 0, 0])
135-
plot(res_ry)
136-
savefig("plot3_NonLinMPC.svg"); nothing # hide
138+
p = plot(res_ry)
139+
savefig(p, "plot3_NonLinMPC.svg") # hide
140+
display(p) # hide
137141
```
138142

139143
![plot3_NonLinMPC](plot3_NonLinMPC.svg)
@@ -144,8 +148,9 @@ satisfactory:
144148

145149
```@example man_nonlin
146150
res_yd = sim!(nmpc, N, ry, plant=plant, x_0=[π, 0], x̂_0=[π, 0, 0], y_step=[10])
147-
plot(res_yd)
148-
savefig("plot4_NonLinMPC.svg"); nothing # hide
151+
p = plot(res_yd)
152+
savefig(p, "plot4_NonLinMPC.svg") # hide
153+
display(p) # hide
149154
```
150155

151156
![plot4_NonLinMPC](plot4_NonLinMPC.svg)
@@ -217,8 +222,9 @@ setpoint is similar:
217222
unset_time_limit_sec(empc.optim) # hide
218223
ry = [180.0, 0]
219224
res2_ry = sim!(empc, N, ry, plant=plant2, x_0=[0, 0], x̂_0=[0, 0, 0])
220-
plot(res2_ry, ploty=[1])
221-
savefig("plot5_NonLinMPC.svg"); nothing # hide
225+
p = plot(res2_ry, ploty=[1])
226+
savefig(p, "plot5_NonLinMPC.svg") # hide
227+
display(p) # hide
222228
```
223229

224230
![plot5_NonLinMPC](plot5_NonLinMPC.svg)
@@ -237,8 +243,9 @@ Also, for a 10° step disturbance:
237243

238244
```@example man_nonlin
239245
res2_yd = sim!(empc, N, ry; plant=plant2, x_0=[π, 0], x̂_0=[π, 0, 0], y_step=[10, 0])
240-
plot(res2_yd, ploty=[1])
241-
savefig("plot6_NonLinMPC.svg"); nothing # hide
246+
p = plot(res2_yd, ploty=[1])
247+
savefig(p, "plot6_NonLinMPC.svg") # hide
248+
display(p) # hide
242249
```
243250

244251
![plot6_NonLinMPC](plot6_NonLinMPC.svg)
@@ -324,8 +331,9 @@ function plotWithPower(res, Pmax)
324331
plot!(plt2, t, Pmax, label=raw"$P_\mathrm{max}$", linestyle=:dot, linewidth=1.5)
325332
return plot(plt1, plt2, layout=(2,1))
326333
end
327-
plotWithPower(res3_ry, Pmax)
328-
savefig("plot7_NonLinMPC.svg"); nothing # hide
334+
p = plotWithPower(res3_ry, Pmax)
335+
savefig(p, "plot7_NonLinMPC.svg") # hide
336+
display(p) # hide
329337
```
330338

331339
![plot7_NonLinMPC](plot7_NonLinMPC.svg)
@@ -359,8 +367,9 @@ The linear controller satisfactorily rejects the 10° step disturbance:
359367
```@example man_nonlin
360368
ry = [180.0]
361369
res_lin = sim!(mpc, N, ry; plant, x_0=[π, 0], y_step=[10])
362-
plot(res_lin)
363-
savefig("plot9_NonLinMPC.svg"); nothing # hide
370+
p = plot(res_lin)
371+
savefig(p, "plot9_NonLinMPC.svg") # hide
372+
display(p) # hide
364373
```
365374

366375
![plot9_NonLinMPC](plot9_NonLinMPC.svg)
@@ -398,8 +407,9 @@ does slightly improve the rejection of the step disturbance:
398407

399408
```@example man_nonlin
400409
res_lin2 = sim!(mpc2, N, ry; plant, x_0=[π, 0], y_step=[10])
401-
plot(res_lin2)
402-
savefig("plot10_NonLinMPC.svg"); nothing # hide
410+
p = plot(res_lin2)
411+
savefig(p, "plot10_NonLinMPC.svg") # hide
412+
display(p) # hide
403413
```
404414

405415
![plot10_NonLinMPC](plot10_NonLinMPC.svg)
@@ -418,8 +428,9 @@ results:
418428

419429
```@example man_nonlin
420430
res_ms = sim!(mpc_ms, N, ry; plant, x_0=[π, 0], y_step=[10])
421-
plot!(res_ms)
422-
savefig("plot10b_NonLinMPC.svg"); nothing # hide
431+
plot!(p, res_ms)
432+
savefig(p, "plot10b_NonLinMPC.svg") # hide
433+
display(p) # hide
423434
```
424435

425436
![plot10b_NonLinMPC](plot10b_NonLinMPC.svg)
@@ -490,8 +501,9 @@ operating point. The [`SimResult`](@ref) object is for plotting purposes only. T
490501
```@example man_nonlin
491502
x_0 = [0, 0]; x̂_0 = [0, 0, 0];
492503
res_slin = sim_adapt!(mpc3, model, N, ry, plant, x_0, x̂_0)
493-
plot(res_slin)
494-
savefig("plot12_NonLinMPC.svg"); nothing # hide
504+
p = plot(res_slin)
505+
savefig(p, "plot12_NonLinMPC.svg") # hide
506+
display(p) # hide
495507
```
496508

497509
![plot12_NonLinMPC](plot12_NonLinMPC.svg)
@@ -501,8 +513,9 @@ and the 10° step disturbance:
501513
```@example man_nonlin
502514
x_0 = [π, 0]; x̂_0 = [π, 0, 0]; y_step = [10]
503515
res_slin = sim_adapt!(mpc3, model, N, ry, plant, x_0, x̂_0, y_step)
504-
plot(res_slin)
505-
savefig("plot13_NonLinMPC.svg"); nothing # hide
516+
p = plot(res_slin)
517+
savefig(p, "plot13_NonLinMPC.svg") # hide
518+
display(p) # hide
506519
```
507520

508521
![plot13_NonLinMPC](plot13_NonLinMPC.svg)

‎docs/src/manual/nonlinmpc2.md‎

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,9 @@ We can now plot the result:
240240

241241
```@example 1
242242
using Plots
243-
plot(res, plotu=true, plotd=true)
244-
savefig("plot1_DAEpH.svg"); nothing # hide
243+
p = plot(res, plotu=true, plotd=true)
244+
savefig(p, "plot1_DAEpH.svg") # hide
245+
display(p) # hide
245246
```
246247

247248
![plot1_DAEpH](plot1_DAEpH.svg)
@@ -314,6 +315,7 @@ performs under pH and flow rate measurement noise:
314315

315316
```@example 1
316317
using Random
318+
Random.seed!(1123) # hide
317319
function simMHE(mhe, plant, N; x_0, x̂_0)
318320
ny, ny, nd, nx, nx̂ = plant.ny, plant.ny, plant.nd, plant.nx, mhe.nx̂
319321
Y_data, U_data, D_data = zeros(ny, N), zeros(nu, N), zeros(nd, N)
@@ -349,7 +351,7 @@ end
349351
x̂_0 = [0.025, 0.025, c_Ain]
350352
res = simMHE(mhe, plant, N; x_0, x̂_0)
351353
p = plot(res, plotd=false, plotu=false, plotxwithx̂=true, plotx̂min=false)
352-
savefig(p, "plot2_DAEpH.svg"); nothing # hide
354+
savefig(p, "plot2_DAEpH.svg") # hide
353355
display(p) # hide
354356
```
355357

@@ -424,11 +426,11 @@ function simNMPC(nmpc, plant, N, ry; x_0, x̂_0, noise=false)
424426
end
425427
N2, ry = 61, [7.0]
426428
using Logging # hide
427-
res2 = with_logger(ConsoleLogger(stderr, Error)) do # hide
428-
res2 = simNMPC(nmpc, plant, N2, ry; x_0=[0.07, 0.04], x̂_0)
429+
res = with_logger(ConsoleLogger(stderr, Error)) do # hide
430+
res = simNMPC(nmpc, plant, N2, ry; x_0=[0.07, 0.04], x̂_0)
429431
end # hide
430-
p = plot(res2, plotd=false, plotxwithx̂=true, plotx̂min=false, plotŷ=true)
431-
savefig(p, "plot3_DAEpH.svg"); nothing # hide
432+
p = plot(res, plotd=false, plotxwithx̂=true, plotx̂min=false, plotŷ=true)
433+
savefig(p, "plot3_DAEpH.svg") # hide
432434
display(p) # hide
433435
```
434436

@@ -440,11 +442,12 @@ measurement noise, the pH constraints are occasionally violated briefly, but the
440442
law responds quickly and returns the effluent pH to the specified range:
441443

442444
```@example 1
443-
res3 = with_logger(ConsoleLogger(stderr, Error)) do # hide
444-
res3 = simNMPC(nmpc, plant, N2, ry; x_0=[0.07, 0.04], x̂_0, noise=true)
445+
res = with_logger(ConsoleLogger(stderr, Error)) do # hide
446+
Random.seed!(5379) # hide
447+
res = simNMPC(nmpc, plant, N2, ry; x_0=[0.07, 0.04], x̂_0, noise=true)
445448
end # hide
446-
p = plot(res3, plotd=false, plotxwithx̂=true, plotx̂min=false, plotŷ=true)
447-
savefig(p, "plot4_DAEpH.svg"); nothing # hide
449+
p = plot(res, plotd=false, plotxwithx̂=true, plotx̂min=false, plotŷ=true)
450+
savefig(p, "plot4_DAEpH.svg") # hide
448451
display(p) # hide
449452
```
450453

0 commit comments

Comments
 (0)