Skip to content

Commit 9ce0a56

Browse files
committed
docs: making use of DocumenterInterLink
1 parent 7c41bc5 commit 9ce0a56

File tree

9 files changed

+43
-55
lines changed

9 files changed

+43
-55
lines changed

docs/Project.toml

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
[deps]
2-
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3-
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
42
ControlSystemsBase = "aaaaaaaa-a6ca-5380-bf3e-84a91bcd477e"
53
DAQP = "c47d62df-3981-49c8-9651-128b1cd08617"
64
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
5+
DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656"
76
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
7+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
8+
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
89
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
910
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1011

1112
[compat]
12-
LinearAlgebra = "1.10"
13-
Logging = "1.10"
1413
ControlSystemsBase = "1"
14+
DAQP = "0.6"
1515
Documenter = "1"
1616
JuMP = "1"
17-
DAQP = "0.6"
18-
Plots = "1"
17+
LinearAlgebra = "1.10"
18+
Logging = "1.10"
1919
ModelingToolkit = "9.50"
20+
Plots = "1"

docs/make.jl

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ ENV["PLOTS_TEST"] = "true"
33
ENV["GKSwstype"] = "nul"
44
push!(LOAD_PATH,"../src/")
55

6-
using Documenter
6+
using Documenter, DocumenterInterLinks
77
using ModelPredictiveControl
88

9+
links = InterLinks(
10+
"Julia" => "https://docs.julialang.org/en/v1/objects.inv",
11+
"ControlSystemsBase" => "https://juliacontrol.github.io/ControlSystems.jl/stable/objects.inv",
12+
"JuMP" => "https://jump.dev/JuMP.jl/stable/objects.inv",
13+
"DifferentiationInterface" => "https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/objects.inv",
14+
)
15+
916
DocMeta.setdocmeta!(
1017
ModelPredictiveControl,
1118
:DocTestSetup,
@@ -16,6 +23,7 @@ makedocs(
1623
sitename = "ModelPredictiveControl.jl",
1724
#format = Documenter.LaTeX(platform = "none"),
1825
doctest = true,
26+
plugins = [links],
1927
format = Documenter.HTML(
2028
prettyurls = get(ENV, "CI", nothing) == "true",
2129
edit_link = "main"

src/controller/linmpc.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ arguments. This controller allocates memory at each time step for the optimizati
146146
- `Cwt=1e5` : slack variable weight ``C`` (scalar), use `Cwt=Inf` for hard constraints only.
147147
- `transcription=SingleShooting()` : a [`TranscriptionMethod`](@ref) for the optimization.
148148
- `optim=JuMP.Model(OSQP.MathOptInterfaceOSQP.Optimizer)` : quadratic optimizer used in
149-
the predictive controller, provided as a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/api/JuMP/#JuMP.Model)
150-
(default to [`OSQP`](https://osqp.org/docs/parsers/jump.html) optimizer).
149+
the predictive controller, provided as a [`JuMP.Model`](@extref) object (default to
150+
[`OSQP`](https://osqp.org/docs/parsers/jump.html) optimizer).
151151
- additional keyword arguments are passed to [`SteadyKalmanFilter`](@ref) constructor.
152152
153153
# Examples

src/controller/nonlinmpc.jl

+8-17
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,14 @@ This controller allocates memory at each time step for the optimization.
194194
- `p=model.p` : ``J_E`` and ``\mathbf{g_c}`` functions parameter ``\mathbf{p}`` (any type).
195195
- `transcription=SingleShooting()` : a [`TranscriptionMethod`](@ref) for the optimization.
196196
- `optim=JuMP.Model(Ipopt.Optimizer)` : nonlinear optimizer used in the predictive
197-
controller, provided as a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/api/JuMP/#JuMP.Model)
198-
(default to [`Ipopt`](https://github.com/jump-dev/Ipopt.jl) optimizer).
197+
controller, provided as a [`JuMP.Model`](@extref) object (default to [`Ipopt`](https://github.com/jump-dev/Ipopt.jl) optimizer).
199198
- `gradient=AutoForwardDiff()` : an `AbstractADType` backend for the gradient of the objective
200-
function, see [`DifferentiationInterface`][1].
199+
function, see [`DifferentiationInterface`](@extref DifferentiationInterface List).
201200
- `jacobian=default_jacobian(transcription)` : an `AbstractADType` backend for the Jacobian
202201
of the nonlinear constraints, see `gradient` above for the options (default in Extended Help).
203202
- additional keyword arguments are passed to [`UnscentedKalmanFilter`](@ref) constructor
204203
(or [`SteadyKalmanFilter`](@ref), for [`LinModel`](@ref)).
205204
206-
[1]: https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/explanation/backends/#List
207-
208205
# Examples
209206
```jldoctest
210207
julia> model = NonLinModel((x,u,_,_)->0.5x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver=nothing);
@@ -253,7 +250,7 @@ NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedK
253250
By default, the optimization relies on dense [`ForwardDiff`](https://github.com/JuliaDiff/ForwardDiff.jl)
254251
automatic differentiation (AD) to compute the objective and constraint derivatives. One
255252
exception: if `transcription` is not a [`SingleShooting`](@ref), the `jacobian` argument
256-
defaults to this [sparse backend][2]:
253+
defaults to this [sparse backend](@extref DifferentiationInterface Sparsity):
257254
```julia
258255
AutoSparse(
259256
AutoForwardDiff();
@@ -262,14 +259,11 @@ NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedK
262259
)
263260
```
264261
Optimizers generally benefit from exact derivatives like AD. However, the [`NonLinModel`](@ref)
265-
state-space functions must be compatible with this feature. See `JuMP` [documentation][3]
262+
state-space functions must be compatible with this feature. See [`JuMP` documentation](@extref JuMP Common-mistakes-when-writing-a-user-defined-operator)
266263
for common mistakes when writing these functions.
267264
268265
Note that if `Cwt≠Inf`, the attribute `nlp_scaling_max_gradient` of `Ipopt` is set to
269266
`10/Cwt` (if not already set), to scale the small values of ``ϵ``.
270-
271-
[2]: https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/explanation/advanced/#Sparsity
272-
[3]: https://jump.dev/JuMP.jl/stable/manual/nonlinear/#Common-mistakes-when-writing-a-user-defined-operator
273267
"""
274268
function NonLinMPC(
275269
model::SimModel;
@@ -581,16 +575,13 @@ This method is really intricate and I'm not proud of it. That's because of 3 ele
581575
- These functions are used inside the nonlinear optimization, so they must be type-stable
582576
and as efficient as possible.
583577
- The `JuMP` NLP syntax forces splatting for the decision variable, which implies use
584-
of `Vararg{T,N}` (see the [performance tip][1]) and memoization to avoid redundant
585-
computations. This is already complex, but it's even worse knowing that most automatic
586-
differentiation tools do not support splatting.
578+
of `Vararg{T,N}` (see the [performance tip][@extref Julia Be-aware-of-when-Julia-avoids-specializing]
579+
) and memoization to avoid redundant computations. This is already complex, but it's even
580+
worse knowing that most automatic differentiation tools do not support splatting.
587581
- The signature of gradient and hessian functions is not the same for univariate (`nZ̃ == 1`)
588582
and multivariate (`nZ̃ > 1`) operators in `JuMP`. Both must be defined.
589583
590-
Inspired from: [User-defined operators with vector outputs][2]
591-
592-
[1]: https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing
593-
[2]: https://jump.dev/JuMP.jl/stable/tutorials/nonlinear/tips_and_tricks/#User-defined-operators-with-vector-outputs
584+
Inspired from: [User-defined operators with vector outputs](@extref JuMP User-defined-operators-with-vector-outputs)
594585
"""
595586
function get_optim_functions(
596587
mpc::NonLinMPC,

src/estimator/kalman.jl

+3-6
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ end
8080
8181
Construct a steady-state Kalman Filter with the [`LinModel`](@ref) `model`.
8282
83-
The steady-state (or [asymptotic][1]) Kalman filter is based on the process model :
83+
The steady-state (or [asymptotic](https://en.wikipedia.org/wiki/Kalman_filter#Asymptotic_form))
84+
Kalman filter is based on the process model:
8485
```math
8586
\begin{aligned}
8687
\mathbf{x}(k+1) &=
@@ -124,8 +125,6 @@ state of the next time step ``\mathbf{x̂}_k(k+1)``. This estimator is allocatio
124125
- `direct=true`: construct with a direct transmission from ``\mathbf{y^m}`` (a.k.a. current
125126
estimator, in opposition to the delayed/predictor form).
126127
127-
[1]: https://en.wikipedia.org/wiki/Kalman_filter#Asymptotic_form
128-
129128
# Examples
130129
```jldoctest
131130
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
@@ -161,11 +160,9 @@ SteadyKalmanFilter estimator with a sample time Ts = 0.5 s, LinModel and:
161160
!!! tip
162161
Increasing `σQint_u` and `σQint_ym` values increases the integral action "gain".
163162
164-
The constructor pre-compute the steady-state Kalman gain `K̂` with the [`kalman`][2]
163+
The constructor pre-compute the steady-state Kalman gain `K̂` with the [`kalman`](@extref ControlSystemsBase.kalman)
165164
function. It can sometimes fail, for example when `model` matrices are ill-conditioned.
166165
In such a case, you can try the alternative time-varying [`KalmanFilter`](@ref).
167-
168-
[2]: https://juliacontrol.github.io/ControlSystems.jl/stable/lib/synthesis/#ControlSystemsBase.kalman-Tuple{Any,%20Any,%20Any,%20Any,%20Any,%20Vararg{Any}}
169166
"""
170167
function SteadyKalmanFilter(
171168
model::SM;

src/estimator/luenberger.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ Extended Help). The argument `poles` is a vector of `model.nx + sum(nint_u) + su
7777
elements specifying the observer poles/eigenvalues (near ``z=0.5`` by default). The observer
7878
is constructed with a direct transmission from ``\mathbf{y^m}`` if `direct=true` (a.k.a.
7979
current observers, in opposition to the delayed/prediction form). The method computes the
80-
observer gain `K̂` with [`place`](https://juliacontrol.github.io/ControlSystems.jl/stable/lib/synthesis/#ControlSystemsBase.place).
81-
This estimator is allocation-free.
80+
observer gain `K̂` with [`place`](@extref ControlSystemsBase.place) function. This estimator
81+
is allocation-free.
8282
8383
# Examples
8484
```jldoctest

src/estimator/mhe/construct.jl

+4-8
Original file line numberDiff line numberDiff line change
@@ -257,18 +257,16 @@ transcription for now.
257257
- `σPint_ym_0=fill(1,sum(nint_ym))` or *`sigmaPint_ym_0`* : same than `σP_0` but for the unmeasured
258258
disturbances at measured outputs ``\mathbf{P_{int_{ym}}}(0)`` (composed of integrators).
259259
- `Cwt=Inf` : slack variable weight ``C``, default to `Inf` meaning hard constraints only.
260-
- `optim=default_optim_mhe(model)` : a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/api/JuMP/#JuMP.Model)
261-
with a quadratic/nonlinear optimizer for solving (default to [`Ipopt`](https://github.com/jump-dev/Ipopt.jl),
260+
- `optim=default_optim_mhe(model)` : a [`JuMP.Model`](@extref) object with a quadratic or
261+
nonlinear optimizer for solving (default to [`Ipopt`](https://github.com/jump-dev/Ipopt.jl),
262262
or [`OSQP`](https://osqp.org/docs/parsers/jump.html) if `model` is a [`LinModel`](@ref)).
263263
- `gradient=AutoForwardDiff()` : an `AbstractADType` backend for the gradient of the objective
264-
function if `model` is not a [`LinModel`](@ref), see [`DifferentiationInterface`][1].
264+
function if `model` is not a [`LinModel`](@ref), see [`DifferentiationInterface`][@extref DifferentiationInterface List].
265265
- `jacobian=AutoForwardDiff()` : an `AbstractADType` backend for the Jacobian of the
266266
constraints if `model` is not a [`LinModel`](@ref), see `gradient` above for the options.
267267
- `direct=true`: construct with a direct transmission from ``\mathbf{y^m}`` (a.k.a. current
268268
estimator, in opposition to the delayed/predictor form).
269269
270-
[1]: https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/explanation/backends/#List
271-
272270
# Examples
273271
```jldoctest
274272
julia> model = NonLinModel((x,u,_,_)->0.1x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver=nothing);
@@ -348,11 +346,9 @@ MovingHorizonEstimator estimator with a sample time Ts = 10.0 s, Ipopt optimizer
348346
default, a [`KalmanFilter`](@ref) estimates the arrival covariance (customizable).
349347
- Else, a nonlinear program with automatic differentiation (AD) solves the optimization.
350348
Optimizers generally benefit from exact derivatives like AD. However, the `f` and `h`
351-
functions must be compatible with this feature. See the `JuMP` [documentation][3]
349+
functions must be compatible with this feature. See the [`JuMP` documentation](@extref JuMP Common-mistakes-when-writing-a-user-defined-operator)
352350
for common mistakes when writing these functions. An [`UnscentedKalmanFilter`](@ref)
353351
estimates the arrival covariance by default.
354-
355-
[3]: https://jump.dev/JuMP.jl/stable/manual/nonlinear/#Common-mistakes-when-writing-a-user-defined-operator
356352
357353
The slack variable ``ϵ`` relaxes the constraints if enabled, see [`setconstraint!`](@ref).
358354
It is disabled by default for the MHE (from `Cwt=Inf`) but it should be activated for

src/model/linearization.jl

+1-3
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ julia> linmodel.A
131131
equations are similar if the nonlinear model has nonzero operating points.
132132
133133
Automatic differentiation (AD) allows exact Jacobians. The [`NonLinModel`](@ref) `f` and
134-
`h` functions must be compatible with this feature though. See `JuMP` [documentation][3]
134+
`h` functions must be compatible with this feature though. See [`JuMP` documentation][@extref JuMP Common-mistakes-when-writing-a-user-defined-operator]
135135
for common mistakes when writing these functions.
136-
137-
[3]: https://jump.dev/JuMP.jl/stable/manual/nonlinear/#Common-mistakes-when-writing-a-user-defined-operator
138136
"""
139137
function linearize(model::SimModel{NT}; kwargs...) where NT<:Real
140138
nu, nx, ny, nd = model.nu, model.nx, model.ny, model.nd

src/model/linmodel.jl

+7-10
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ resamples discrete ones if `Ts ≠ sys.Ts`, computes a new realization if not mi
8484
separates the ``\mathbf{z}`` terms in two parts (details in Extended Help). The rest of the
8585
documentation assumes discrete dynamics since all systems end up in this form.
8686
87-
See also [`ss`](https://juliacontrol.github.io/ControlSystems.jl/stable/lib/constructors/#ControlSystemsBase.ss)
87+
See also [`ss`](@extref ControlSystemsBase.ss)
8888
8989
# Examples
9090
```jldoctest
@@ -112,12 +112,12 @@ LinModel with a sample time Ts = 0.1 s and:
112112
\mathbf{y}(k) &= \mathbf{C x}(k) + \mathbf{D z}(k)
113113
\end{aligned}
114114
```
115-
Continuous dynamics are internally discretized using [`c2d`][1] and `:zoh` for
116-
manipulated inputs, and `:tustin`, for measured disturbances. Lastly, if `sys` is
117-
discrete and the provided argument `Ts ≠ sys.Ts`, the system is resampled by using the
118-
aforementioned discretization methods.
115+
Continuous dynamics are internally discretized using [`c2d`](@extref ControlSystemsBase.c2d)
116+
and `:zoh` for manipulated inputs, and `:tustin`, for measured disturbances. Lastly, if
117+
`sys` is discrete and the provided argument `Ts ≠ sys.Ts`, the system is resampled by
118+
using the aforementioned discretization methods.
119119
120-
Note that the constructor transforms the system to its minimal realization using [`minreal`][2]
120+
Note that the constructor transforms the system to its minimal realization using [`minreal`](@extref ControlSystemsBase.minreal)
121121
for controllability/observability. As a consequence, the final state-space
122122
representation may be different from the one provided in `sys`. It is also converted
123123
into a more practical form (``\mathbf{D_u=0}`` because of the zero-order hold):
@@ -129,9 +129,6 @@ LinModel with a sample time Ts = 0.1 s and:
129129
```
130130
Use the syntax [`LinModel{NT}(A, Bu, C, Bd, Dd, Ts)`](@ref) to force a specific
131131
state-space representation.
132-
133-
[1]: https://juliacontrol.github.io/ControlSystems.jl/stable/lib/constructors/#ControlSystemsBase.c2d
134-
[2]: https://juliacontrol.github.io/ControlSystems.jl/stable/lib/constructors/#ControlSystemsBase.minreal
135132
"""
136133
function LinModel(
137134
sys::StateSpace{E, NT},
@@ -195,7 +192,7 @@ Convert to minimal realization state-space when `sys` is a transfer function.
195192
`sys` is equal to ``\frac{\mathbf{y}(s)}{\mathbf{z}(s)}`` for continuous-time, and
196193
``\frac{\mathbf{y}(z)}{\mathbf{z}(z)}``, for discrete-time.
197194
198-
See also [`tf`](https://juliacontrol.github.io/ControlSystems.jl/stable/lib/constructors/#ControlSystemsBase.tf)
195+
See also [`tf`](@extref ControlSystemsBase.tf)
199196
200197
# Examples
201198
```jldoctest

0 commit comments

Comments
 (0)