diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3db320924..1b9e119b0 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,15 +1,11 @@ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" # Location of package manifests - schedule: - interval: "weekly" - package-ecosystem: "julia" - directory: "/" + directories: # Location of Julia projects + - "/" + - "/docs" + - "/test" + - "/benchmark" schedule: - interval: "weekly" - # groups: # uncomment to group all julia package updates into a single PR - # all-julia-packages: - # patterns: - # - "*" \ No newline at end of file + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml deleted file mode 100644 index cba9134c6..000000000 --- a/.github/workflows/CompatHelper.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: CompatHelper -on: - schedule: - - cron: 0 0 * * * - workflow_dispatch: -jobs: - CompatHelper: - runs-on: ubuntu-latest - steps: - - name: Pkg.add("CompatHelper") - run: julia -e 'using Pkg; Pkg.add("CompatHelper")' - - name: CompatHelper.main() - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} - run: julia -e 'using CompatHelper; CompatHelper.main()' diff --git a/Project.toml b/Project.toml index 3157d3759..458c2d761 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ModelPredictiveControl" uuid = "61f9bdb8-6ae4-484a-811f-bbf86720c31c" -version = "2.15.0" +version = "2.15.1" authors = ["Francis Gagnon"] [deps] diff --git a/docs/src/manual/mtk.md b/docs/src/manual/mtk.md index 1f942cf2a..4508a65b6 100644 --- a/docs/src/manual/mtk.md +++ b/docs/src/manual/mtk.md @@ -4,11 +4,6 @@ Pages = ["mtk.md"] ``` -```@setup 1 -using Logging; errlogger = ConsoleLogger(stderr, Error); -old_logger = global_logger(); global_logger(errlogger); -``` - ## Pendulum Model This example integrates the simple pendulum model of the [penultimate section](@ref man_nonlin) @@ -150,9 +145,13 @@ The 180° setpoint response is identical: using Plots N = 35 using JuMP; unset_time_limit_sec(nmpc.optim) # hide +using Logging # hide +res_ry = with_logger(ConsoleLogger(stderr, Error)) do # hide res_ry = sim!(nmpc, N, [180.0], plant=plant, x_0=[0, 0], x̂_0=[0, 0, 0]) -plot(res_ry) -savefig("plot1_MTK.svg"); nothing # hide +end # +p = plot(res_ry) +savefig(p, "plot1_MTK.svg") # hide +display(p) # hide ``` ![plot1_MTK](plot1_MTK.svg) @@ -160,9 +159,12 @@ savefig("plot1_MTK.svg"); nothing # hide and also the output disturbance rejection: ```@example 1 +res_yd = with_logger(ConsoleLogger(stderr, Error)) do # hide res_yd = sim!(nmpc, N, [180.0], plant=plant, x_0=[0, π], x̂_0=[0, π, 0], y_step=[10]) -plot(res_yd) -savefig("plot2_MTK.svg"); nothing # hide +end # hide +p = plot(res_yd) +savefig(p, "plot2_MTK.svg") # hide +display(p) # hide ``` ![plot2_MTK](plot2_MTK.svg) @@ -170,7 +172,3 @@ savefig("plot2_MTK.svg"); nothing # hide ## Acknowledgement Authored by `1-Bart-1` and `baggepinnen`, thanks for the contribution. - -```@setup 1 -global_logger(old_logger); -``` diff --git a/docs/src/manual/nonlinmpc1.md b/docs/src/manual/nonlinmpc1.md index 730164fae..89c0bef5b 100644 --- a/docs/src/manual/nonlinmpc1.md +++ b/docs/src/manual/nonlinmpc1.md @@ -73,8 +73,9 @@ using Plots u = [0.5] N = 35 res = sim!(model, N, u) -plot(res, plotu=false) -savefig("plot1_NonLinMPC.svg"); nothing # hide +p = plot(res, plotu=false) +savefig(p, "plot1_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot1_NonLinMPC](plot1_NonLinMPC.svg) @@ -103,9 +104,11 @@ estimator tuning is tested on a plant with a 25 % larger friction coefficient `` p_plant = copy(p_model) p_plant[3] = 1.25*p_model[3] plant = setname!(NonLinModel(f, h, Ts, nu, nx, ny; p=p_plant); u=vu, x=vx, y=vy) +using Random; Random.seed!(2944) # hide res = sim!(estim, N, [0.5], plant=plant, y_noise=[0.5]) -plot(res, plotu=false, plotxwithx̂=true) -savefig("plot2_NonLinMPC.svg"); nothing # hide +p = plot(res, plotu=false, plotxwithx̂=true) +savefig(p, "plot2_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot2_NonLinMPC](plot2_NonLinMPC.svg) @@ -132,8 +135,9 @@ The option `Cwt=Inf` disables the slack variable `ϵ` for constraint softening. using JuMP; unset_time_limit_sec(nmpc.optim) # hide ry = [180.0] res_ry = sim!(nmpc, N, ry, plant=plant, x_0=[0, 0], x̂_0=[0, 0, 0]) -plot(res_ry) -savefig("plot3_NonLinMPC.svg"); nothing # hide +p = plot(res_ry) +savefig(p, "plot3_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot3_NonLinMPC](plot3_NonLinMPC.svg) @@ -144,8 +148,9 @@ satisfactory: ```@example man_nonlin res_yd = sim!(nmpc, N, ry, plant=plant, x_0=[π, 0], x̂_0=[π, 0, 0], y_step=[10]) -plot(res_yd) -savefig("plot4_NonLinMPC.svg"); nothing # hide +p = plot(res_yd) +savefig(p, "plot4_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot4_NonLinMPC](plot4_NonLinMPC.svg) @@ -217,8 +222,9 @@ setpoint is similar: unset_time_limit_sec(empc.optim) # hide ry = [180.0, 0] res2_ry = sim!(empc, N, ry, plant=plant2, x_0=[0, 0], x̂_0=[0, 0, 0]) -plot(res2_ry, ploty=[1]) -savefig("plot5_NonLinMPC.svg"); nothing # hide +p = plot(res2_ry, ploty=[1]) +savefig(p, "plot5_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot5_NonLinMPC](plot5_NonLinMPC.svg) @@ -237,8 +243,9 @@ Also, for a 10° step disturbance: ```@example man_nonlin res2_yd = sim!(empc, N, ry; plant=plant2, x_0=[π, 0], x̂_0=[π, 0, 0], y_step=[10, 0]) -plot(res2_yd, ploty=[1]) -savefig("plot6_NonLinMPC.svg"); nothing # hide +p = plot(res2_yd, ploty=[1]) +savefig(p, "plot6_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot6_NonLinMPC](plot6_NonLinMPC.svg) @@ -324,8 +331,9 @@ function plotWithPower(res, Pmax) plot!(plt2, t, Pmax, label=raw"$P_\mathrm{max}$", linestyle=:dot, linewidth=1.5) return plot(plt1, plt2, layout=(2,1)) end -plotWithPower(res3_ry, Pmax) -savefig("plot7_NonLinMPC.svg"); nothing # hide +p = plotWithPower(res3_ry, Pmax) +savefig(p, "plot7_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot7_NonLinMPC](plot7_NonLinMPC.svg) @@ -359,8 +367,9 @@ The linear controller satisfactorily rejects the 10° step disturbance: ```@example man_nonlin ry = [180.0] res_lin = sim!(mpc, N, ry; plant, x_0=[π, 0], y_step=[10]) -plot(res_lin) -savefig("plot9_NonLinMPC.svg"); nothing # hide +p = plot(res_lin) +savefig(p, "plot9_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot9_NonLinMPC](plot9_NonLinMPC.svg) @@ -398,8 +407,9 @@ does slightly improve the rejection of the step disturbance: ```@example man_nonlin res_lin2 = sim!(mpc2, N, ry; plant, x_0=[π, 0], y_step=[10]) -plot(res_lin2) -savefig("plot10_NonLinMPC.svg"); nothing # hide +p = plot(res_lin2) +savefig(p, "plot10_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot10_NonLinMPC](plot10_NonLinMPC.svg) @@ -418,8 +428,9 @@ results: ```@example man_nonlin res_ms = sim!(mpc_ms, N, ry; plant, x_0=[π, 0], y_step=[10]) -plot!(res_ms) -savefig("plot10b_NonLinMPC.svg"); nothing # hide +plot!(p, res_ms) +savefig(p, "plot10b_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot10b_NonLinMPC](plot10b_NonLinMPC.svg) @@ -490,8 +501,9 @@ operating point. The [`SimResult`](@ref) object is for plotting purposes only. T ```@example man_nonlin x_0 = [0, 0]; x̂_0 = [0, 0, 0]; res_slin = sim_adapt!(mpc3, model, N, ry, plant, x_0, x̂_0) -plot(res_slin) -savefig("plot12_NonLinMPC.svg"); nothing # hide +p = plot(res_slin) +savefig(p, "plot12_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot12_NonLinMPC](plot12_NonLinMPC.svg) @@ -501,8 +513,9 @@ and the 10° step disturbance: ```@example man_nonlin x_0 = [π, 0]; x̂_0 = [π, 0, 0]; y_step = [10] res_slin = sim_adapt!(mpc3, model, N, ry, plant, x_0, x̂_0, y_step) -plot(res_slin) -savefig("plot13_NonLinMPC.svg"); nothing # hide +p = plot(res_slin) +savefig(p, "plot13_NonLinMPC.svg") # hide +display(p) # hide ``` ![plot13_NonLinMPC](plot13_NonLinMPC.svg) diff --git a/docs/src/manual/nonlinmpc2.md b/docs/src/manual/nonlinmpc2.md index a48e7d8e9..413e8a8b8 100644 --- a/docs/src/manual/nonlinmpc2.md +++ b/docs/src/manual/nonlinmpc2.md @@ -240,8 +240,9 @@ We can now plot the result: ```@example 1 using Plots -plot(res, plotu=true, plotd=true) -savefig("plot1_DAEpH.svg"); nothing # hide +p = plot(res, plotu=true, plotd=true) +savefig(p, "plot1_DAEpH.svg") # hide +display(p) # hide ``` ![plot1_DAEpH](plot1_DAEpH.svg) @@ -314,6 +315,7 @@ performs under pH and flow rate measurement noise: ```@example 1 using Random +Random.seed!(1123) # hide function simMHE(mhe, plant, N; x_0, x̂_0) ny, ny, nd, nx, nx̂ = plant.ny, plant.ny, plant.nd, plant.nx, mhe.nx̂ Y_data, U_data, D_data = zeros(ny, N), zeros(nu, N), zeros(nd, N) @@ -349,7 +351,7 @@ end x̂_0 = [0.025, 0.025, c_Ain] res = simMHE(mhe, plant, N; x_0, x̂_0) p = plot(res, plotd=false, plotu=false, plotxwithx̂=true, plotx̂min=false) -savefig(p, "plot2_DAEpH.svg"); nothing # hide +savefig(p, "plot2_DAEpH.svg") # hide display(p) # hide ``` @@ -424,11 +426,11 @@ function simNMPC(nmpc, plant, N, ry; x_0, x̂_0, noise=false) end N2, ry = 61, [7.0] using Logging # hide -res2 = with_logger(ConsoleLogger(stderr, Error)) do # hide -res2 = simNMPC(nmpc, plant, N2, ry; x_0=[0.07, 0.04], x̂_0) +res = with_logger(ConsoleLogger(stderr, Error)) do # hide +res = simNMPC(nmpc, plant, N2, ry; x_0=[0.07, 0.04], x̂_0) end # hide -p = plot(res2, plotd=false, plotxwithx̂=true, plotx̂min=false, plotŷ=true) -savefig(p, "plot3_DAEpH.svg"); nothing # hide +p = plot(res, plotd=false, plotxwithx̂=true, plotx̂min=false, plotŷ=true) +savefig(p, "plot3_DAEpH.svg") # hide display(p) # hide ``` @@ -440,11 +442,12 @@ measurement noise, the pH constraints are occasionally violated briefly, but the law responds quickly and returns the effluent pH to the specified range: ```@example 1 -res3 = with_logger(ConsoleLogger(stderr, Error)) do # hide -res3 = simNMPC(nmpc, plant, N2, ry; x_0=[0.07, 0.04], x̂_0, noise=true) +res = with_logger(ConsoleLogger(stderr, Error)) do # hide +Random.seed!(5379) # hide +res = simNMPC(nmpc, plant, N2, ry; x_0=[0.07, 0.04], x̂_0, noise=true) end # hide -p = plot(res3, plotd=false, plotxwithx̂=true, plotx̂min=false, plotŷ=true) -savefig(p, "plot4_DAEpH.svg"); nothing # hide +p = plot(res, plotd=false, plotxwithx̂=true, plotx̂min=false, plotŷ=true) +savefig(p, "plot4_DAEpH.svg") # hide display(p) # hide ```