Skip to content

Commit ca50f3b

Browse files
committed
small doc corrections
1 parent 52b1262 commit ca50f3b

File tree

4 files changed

+52
-52
lines changed

4 files changed

+52
-52
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@
5050
"OSQP",
5151
"Penrose",
5252
"Plamondon",
53+
"plotry",
54+
"plotu",
55+
"plotx",
56+
"plotx̂",
57+
"plotŷ",
58+
"plotŷmin",
5359
"predictstoch",
5460
"quadprog",
5561
"repeatdiag",

src/controller/linmpc.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ arguments.
120120
- `model::LinModel` : model used for controller predictions and state estimations.
121121
- `Hp=10+nk`: prediction horizon ``H_p``, `nk` is the number of delays in `model`.
122122
- `Hc=2` : control horizon ``H_c``.
123-
- `Mwt=fill(1.0,model.ny)` : main diagonal of ``\mathbf{M}`` weight matrix (vector)
124-
- `Nwt=fill(0.1,model.nu)` : main diagonal of ``\mathbf{N}`` weight matrix (vector)
125-
- `Lwt=fill(0.0,model.nu)` : main diagonal of ``\mathbf{L}`` weight matrix (vector)
126-
- `Cwt=1e5` : slack variable weight ``C`` (scalar), use `Cwt=Inf` for hard constraints only
127-
- `ru=model.uop` : manipulated input setpoints ``\mathbf{r_u}`` (vector)
123+
- `Mwt=fill(1.0,model.ny)` : main diagonal of ``\mathbf{M}`` weight matrix (vector).
124+
- `Nwt=fill(0.1,model.nu)` : main diagonal of ``\mathbf{N}`` weight matrix (vector).
125+
- `Lwt=fill(0.0,model.nu)` : main diagonal of ``\mathbf{L}`` weight matrix (vector).
126+
- `Cwt=1e5` : slack variable weight ``C`` (scalar), use `Cwt=Inf` for hard constraints only.
127+
- `ru=model.uop` : manipulated input setpoints ``\mathbf{r_u}`` (vector).
128128
- `optim=JuMP.Model(OSQP.MathOptInterfaceOSQP.Optimizer)` : quadratic optimizer used in
129129
the predictive controller, provided as a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/reference/models/#JuMP.Model)
130-
(default to [`OSQP.jl`](https://osqp.org/docs/parsers/jump.html) optimizer)
130+
(default to [`OSQP.jl`](https://osqp.org/docs/parsers/jump.html) optimizer).
131131
132132
# Examples
133133
```jldoctest

src/controller/nonlinmpc.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ This method uses the default state estimator :
118118
- `model::SimModel` : model used for controller predictions and state estimations.
119119
- `Hp=10`: prediction horizon ``H_p``.
120120
- `Hc=2` : control horizon ``H_c``.
121-
- `Mwt=fill(1.0,model.ny)` : main diagonal of ``\mathbf{M}`` weight matrix (vector)
122-
- `Nwt=fill(0.1,model.nu)` : main diagonal of ``\mathbf{N}`` weight matrix (vector)
123-
- `Lwt=fill(0.0,model.nu)` : main diagonal of ``\mathbf{L}`` weight matrix (vector)
124-
- `Cwt=1e5` : slack variable weight ``C`` (scalar), use `Cwt=Inf` for hard constraints only
121+
- `Mwt=fill(1.0,model.ny)` : main diagonal of ``\mathbf{M}`` weight matrix (vector).
122+
- `Nwt=fill(0.1,model.nu)` : main diagonal of ``\mathbf{N}`` weight matrix (vector).
123+
- `Lwt=fill(0.0,model.nu)` : main diagonal of ``\mathbf{L}`` weight matrix (vector).
124+
- `Cwt=1e5` : slack variable weight ``C`` (scalar), use `Cwt=Inf` for hard constraints only.
125125
- `Ewt=0.0` : economic costs weight ``E`` (scalar).
126126
- `JE=(_,_,_)->0.0` : economic function ``J_E(\mathbf{U}_E, \mathbf{D̂}_E, \mathbf{Ŷ}_E)``.
127-
- `ru=model.uop` : manipulated input setpoints ``\mathbf{r_u}`` (vector)
128-
- `optim=JuMP.Model(Ipopt.Optimizer)` : nonlinear optimizer used in the predictive
127+
- `ru=model.uop` : manipulated input setpoints ``\mathbf{r_u}`` (vector).
128+
- `optim=JuMP.Model(Ipopt.Optimizer)` : nonlinear optimizer used in the predictive
129129
controller, provided as a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/reference/models/#JuMP.Model)
130-
(default to [`Ipopt.jl`](https://github.com/jump-dev/Ipopt.jl) optimizer)
130+
(default to [`Ipopt.jl`](https://github.com/jump-dev/Ipopt.jl) optimizer).
131131
132132
# Examples
133133
```jldoctest

src/plot_sim.jl

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@ struct SimResult{O<:Union{SimModel, StateEstimator, PredictiveController}}
1313
end
1414

1515
@doc raw"""
16-
sim!(
17-
plant::SimModel,
18-
N::Int,
19-
u::Vector{<:Real} = plant.uop .+ 1,
20-
d::Vector{<:Real} = plant.dop;
21-
<keyword arguments>
22-
)
16+
sim!(plant::SimModel, N::Int, u=plant.uop.+1, d=plant.dop; <keyword arguments>)
2317
24-
Open-loop simulation of `plant` model for `N` time steps, default to input bumps.
18+
Open-loop simulation of `plant` for `N` time steps, default to input bumps.
2519
2620
See Arguments for the available options. The noises are provided as standard deviations σ
2721
vectors. The simulated sensor and process noises of `plant` are specified by `y_noise` and
@@ -30,24 +24,24 @@ visualized by calling `plot` from [`Plots.jl`](https://github.com/JuliaPlots/Plo
3024
them (see Examples below).
3125
3226
# Arguments
33-
- `plant::SimModel` : plant model to simulate
34-
- `N::Int` : simulation length in time steps
35-
- `u = estim.model.uop .+ 1` : manipulated input ``\mathbf{u}`` value
36-
- `d = estim.model.dop` : plant measured disturbance ``\mathbf{d}`` value
37-
- `u_step = zeros(plant.nu)` : step disturbance on manipulated input ``\mathbf{u}``
38-
- `u_noise = zeros(plant.nu)` : additive gaussian noise on manipulated input ``\mathbf{u}``
39-
- `y_step = zeros(plant.ny)` : step disturbance on plant outputs ``\mathbf{y}``
40-
- `y_noise = zeros(plant.ny)` : additive gaussian noise on plant outputs ``\mathbf{y}``
41-
- `d_step = zeros(plant.nd)` : step on measured disturbances ``\mathbf{d}``
42-
- `d_noise = zeros(plant.nd)` : additive gaussian noise on measured dist. ``\mathbf{d}``
43-
- `x_noise = zeros(plant.nx)` : additive gaussian noise on plant states ``\mathbf{x}``
44-
- `x0 = zeros(plant.nx)` : plant initial state ``\mathbf{x}(0)``
27+
- `plant::SimModel` : plant model to simulate.
28+
- `N::Int` : simulation length in time steps.
29+
- `u = estim.model.uop .+ 1` : manipulated input ``\mathbf{u}`` value.
30+
- `d = estim.model.dop` : plant measured disturbance ``\mathbf{d}`` value.
31+
- `u_step = zeros(plant.nu)` : step load disturbance on plant inputs ``\mathbf{u}``.
32+
- `u_noise = zeros(plant.nu)` : additive gaussian noise on plant inputs ``\mathbf{u}``.
33+
- `y_step = zeros(plant.ny)` : step disturbance on plant outputs ``\mathbf{y}``.
34+
- `y_noise = zeros(plant.ny)` : additive gaussian noise on plant outputs ``\mathbf{y}``.
35+
- `d_step = zeros(plant.nd)` : step on measured disturbances ``\mathbf{d}``.
36+
- `d_noise = zeros(plant.nd)` : additive gaussian noise on measured dist. ``\mathbf{d}``.
37+
- `x_noise = zeros(plant.nx)` : additive gaussian noise on plant states ``\mathbf{x}``.
38+
- `x0 = zeros(plant.nx)` : plant initial state ``\mathbf{x}(0)``.
4539
4640
# Examples
4741
```julia-repl
48-
julia> plant = NonLinModel((x,u,d)->0.1x+u+d, (x,_)->2x, 10, 1, 1, 1);
42+
julia> plant = NonLinModel((x,u,d)->0.1x+u+d, (x,_)->2x, 10, 1, 1, 1, 1);
4943
50-
julia> res = sim!(plant, 5, [0], [0], x0=[1]);
44+
julia> res = sim!(plant, 15, [0], [0], x0=[1]);
5145
5246
julia> using Plots; plot(res, plotu=false, plotd=false, plotx=true)
5347
```
@@ -93,10 +87,10 @@ end
9387

9488
@doc raw"""
9589
sim!(
96-
estim::StateEstimator,
97-
N::Int,
98-
u = estim.model.uop .+ 1,
99-
d = estim.model.dop;
90+
estim::StateEstimator,
91+
N::Int,
92+
u = estim.model.uop .+ 1,
93+
d = estim.model.dop;
10094
<keyword arguments>
10195
)
10296
@@ -105,15 +99,15 @@ Closed-loop simulation of `estim` estimator for `N` time steps, default to input
10599
See Arguments for the available options.
106100
107101
# Arguments
108-
- `estim::StateEstimator` : state estimator to simulate
109-
- `N::Int` : simulation length in time steps
110-
- `u = estim.model.uop .+ 1` : manipulated input ``\mathbf{u}`` value
111-
- `d = estim.model.dop` : plant measured disturbance ``\mathbf{d}`` value
112-
- `plant::SimModel = estim.model` : simulated plant model
102+
- `estim::StateEstimator` : state estimator to simulate.
103+
- `N::Int` : simulation length in time steps.
104+
- `u = estim.model.uop .+ 1` : manipulated input ``\mathbf{u}`` value.
105+
- `d = estim.model.dop` : plant measured disturbance ``\mathbf{d}`` value.
106+
- `plant::SimModel = estim.model` : simulated plant model.
113107
- `x̂0 = nothing` : `mpc.estim` state estimator initial state ``\mathbf{x̂}(0)``, if `nothing`
114-
then ``\mathbf{x̂}`` is initialized with [`initstate!`](@ref)
115-
- `lastu = plant.uop` : last plant input ``\mathbf{u}`` for ``\mathbf{x̂}`` initialization
116-
- `<keyword arguments>` of [`sim!(::SimModel)`](@ref)
108+
then ``\mathbf{x̂}`` is initialized with [`initstate!`](@ref).
109+
- `lastu = plant.uop` : last plant input ``\mathbf{u}`` for ``\mathbf{x̂}`` initialization.
110+
- `<keyword arguments>` of [`sim!(::SimModel, ::Int)`](@ref).
117111
118112
# Examples
119113
```julia-repl
@@ -140,26 +134,26 @@ end
140134
@doc raw"""
141135
sim!(
142136
mpc::PredictiveController,
143-
N::Int,
137+
N::Int,
144138
ry = mpc.estim.model.yop .+ 1,
145139
d = mpc.estim.model.dop;
146140
<keyword arguments>
147141
)
148142
149143
Closed-loop simulation of `mpc` controller for `N` time steps, default to setpoint bumps.
150144
151-
`ry` is the output setpoint value applied at ``t = 0`` second. The keyword arguments are
152-
identical to [`sim!(::StateEstimator)`](@ref).
145+
The argument `ry` is output setpoint ``\mathbf{r_y}`` value applied at ``t = 0``. The
146+
keyword arguments are identical to [`sim!(::StateEstimator, ::Int)`](@ref).
153147
154148
# Examples
155149
```julia-repl
156150
julia> model = LinModel([tf(3, [30, 1]); tf(2, [5, 1])], 4);
157151
158152
julia> mpc = setconstraint!(LinMPC(model, Mwt=[0, 1], Nwt=[0.01], Hp=30), ŷmin=[0, -Inf]);
159153
160-
julia> res = sim!(mpc, 25, [0; 0], y_noise=[0.1], y_step=[-10,0]);
154+
julia> res = sim!(mpc, 25, [0, 0], y_noise=[0.1], y_step=[-10, 0]);
161155
162-
julia> using Plots; plot(res, plotRy=true, plotŷ=true, plotŷmin=true, plotu=true)
156+
julia> using Plots; plot(res, plotry=true, plotŷ=true, plotŷmin=true, plotu=true)
163157
```
164158
"""
165159
function sim!(

0 commit comments

Comments
 (0)