You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/controller/nonlinmpc.jl
+59-52
Original file line number
Diff line number
Diff line change
@@ -197,12 +197,14 @@ This controller allocates memory at each time step for the optimization.
197
197
controller, provided as a [`JuMP.Model`](https://jump.dev/JuMP.jl/stable/api/JuMP/#JuMP.Model)
198
198
(default to [`Ipopt`](https://github.com/jump-dev/Ipopt.jl) optimizer).
199
199
- `gradient=AutoForwardDiff()` : an `AbstractADType` backend for the gradient of the objective
200
-
function, see [`DifferentiationInterface`](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/explanation/backends/#List).
200
+
function, see [`DifferentiationInterface`][1].
201
201
- `jacobian=default_jacobian(transcription)` : an `AbstractADType` backend for the Jacobian
202
202
of the nonlinear constraints, see `gradient` above for the options (default in Extended Help).
203
203
- additional keyword arguments are passed to [`UnscentedKalmanFilter`](@ref) constructor
204
204
(or [`SteadyKalmanFilter`](@ref), for [`LinModel`](@ref)).
julia> model = NonLinModel((x,u,_,_)->0.5x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver=nothing);
@@ -248,14 +250,26 @@ NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedK
248
250
The keyword argument `nc` is the number of elements in `LHS`, and `gc!`, an alias for
249
251
the `gc` argument (both `gc` and `gc!` accepts non-mutating and mutating functions).
250
252
251
-
The optimization relies on [`JuMP`](https://github.com/jump-dev/JuMP.jl) automatic
252
-
differentiation (AD) to compute the objective and constraint derivatives. Optimizers
253
-
generally benefit from exact derivatives like AD. However, the [`NonLinModel`](@ref)
254
-
state-space functions must be compatible with this feature. See [Automatic differentiation](https://jump.dev/JuMP.jl/stable/manual/nlp/#Automatic-differentiation)
253
+
By default, the optimization relies on dense [`ForwardDiff`](https://github.com/JuliaDiff/ForwardDiff.jl)
254
+
automatic differentiation (AD) to compute the objective and constraint derivatives. One
255
+
exception: if `transcription` is not a [`SingleShooting`](@ref), the `jacobian` argument
256
+
defaults to this [sparse backend][2]:
257
+
```julia
258
+
AutoSparse(
259
+
AutoForwardDiff();
260
+
sparsity_detector = TracerSparsityDetector(),
261
+
coloring_algorithm = GreedyColoringAlgorithm()
262
+
)
263
+
```
264
+
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]
255
266
for common mistakes when writing these functions.
256
267
257
268
Note that if `Cwt≠Inf`, the attribute `nlp_scaling_max_gradient` of `Ipopt` is set to
258
269
`10/Cwt` (if not already set), to scale the small values of ``ϵ``.
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 0.5);
@@ -160,9 +161,11 @@ SteadyKalmanFilter estimator with a sample time Ts = 0.5 s, LinModel and:
160
161
!!! tip
161
162
Increasing `σQint_u` and `σQint_ym` values increases the integral action "gain".
162
163
163
-
The constructor pre-compute the steady-state Kalman gain `K̂` with the [`kalman`](https://juliacontrol.github.io/ControlSystems.jl/stable/lib/synthesis/#ControlSystemsBase.kalman-Tuple{Any,%20Any,%20Any,%20Any,%20Any,%20Vararg{Any}})
164
+
The constructor pre-compute the steady-state Kalman gain `K̂` with the [`kalman`][2]
164
165
function. It can sometimes fail, for example when `model` matrices are ill-conditioned.
165
166
In such a case, you can try the alternative time-varying [`KalmanFilter`](@ref).
Copy file name to clipboardexpand all lines: src/estimator/mhe/construct.jl
+6-2
Original file line number
Diff line number
Diff line change
@@ -261,12 +261,14 @@ transcription for now.
261
261
with a quadratic/nonlinear optimizer for solving (default to [`Ipopt`](https://github.com/jump-dev/Ipopt.jl),
262
262
or [`OSQP`](https://osqp.org/docs/parsers/jump.html) if `model` is a [`LinModel`](@ref)).
263
263
- `gradient=AutoForwardDiff()` : an `AbstractADType` backend for the gradient of the objective
264
-
function if `model` is not a [`LinModel`](@ref), see [`DifferentiationInterface`](https://juliadiff.org/DifferentiationInterface.jl/DifferentiationInterface/stable/explanation/backends/#List).
264
+
function if `model` is not a [`LinModel`](@ref), see [`DifferentiationInterface`][1].
265
265
- `jacobian=AutoForwardDiff()` : an `AbstractADType` backend for the Jacobian of the
266
266
constraints if `model` is not a [`LinModel`](@ref), see `gradient` above for the options.
267
267
- `direct=true`: construct with a direct transmission from ``\mathbf{y^m}`` (a.k.a. current
268
268
estimator, in opposition to the delayed/predictor form).
Copy file name to clipboardexpand all lines: src/model/linearization.jl
+3-1
Original file line number
Diff line number
Diff line change
@@ -131,8 +131,10 @@ julia> linmodel.A
131
131
equations are similar if the nonlinear model has nonzero operating points.
132
132
133
133
Automatic differentiation (AD) allows exact Jacobians. The [`NonLinModel`](@ref) `f` and
134
-
`h` functions must be compatible with this feature though. See [Automatic differentiation](https://jump.dev/JuMP.jl/stable/manual/nlp/#Automatic-differentiation)
134
+
`h` functions must be compatible with this feature though. See `JuMP` [documentation][3]
Continuous dynamics are internally discretized using [`c2d`](https://juliacontrol.github.io/ControlSystems.jl/stable/lib/constructors/#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.
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.
119
119
120
-
Note that the constructor transforms the system to its minimal realization using [`minreal`](https://juliacontrol.github.io/ControlSystems.jl/stable/lib/constructors/#ControlSystemsBase.minreal)
120
+
Note that the constructor transforms the system to its minimal realization using [`minreal`][2]
121
121
for controllability/observability. As a consequence, the final state-space
122
122
representation may be different from the one provided in `sys`. It is also converted
123
123
into a more practical form (``\mathbf{D_u=0}`` because of the zero-order hold):
@@ -129,6 +129,9 @@ LinModel with a sample time Ts = 0.1 s and:
129
129
```
130
130
Use the syntax [`LinModel{NT}(A, Bu, C, Bd, Dd, Ts)`](@ref) to force a specific
0 commit comments