Skip to content

Commit 725ec21

Browse files
committed
doc: added internal function optim_objective
1 parent 0779d34 commit 725ec21

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

docs/src/internals/predictive_control.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ ModelPredictiveControl.init_matconstraint_mpc
2929
ModelPredictiveControl.initpred!(::PredictiveController, ::LinModel, ::Any, ::Any, ::Any, ::Any, ::Any)
3030
ModelPredictiveControl.linconstraint!(::PredictiveController, ::LinModel)
3131
```
32+
33+
## Solve Optimization Problem
34+
35+
```@docs
36+
ModelPredictiveControl.optim_objective!
37+
```

src/controller/execute.jl

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,27 @@ function obj_nonlinprog(
359359
return JR̂y + JΔŨ + JR̂u + E_JE
360360
end
361361

362-
"""
363-
optim_objective!(mpc::PredictiveController)
362+
@doc raw"""
363+
optim_objective!(mpc::PredictiveController) -> ΔŨ
364+
365+
Optimize the objective function of `mpc` [`PredictiveController`](@ref) and return the solution `ΔŨ`.
364366
365-
Optimize the objective function ``J`` of `mpc` controller and return the solution `ΔŨ`.
367+
If supported by `mpc.optim`, it warm-starts the solver at:
368+
```math
369+
\mathbf{ΔŨ} =
370+
\begin{bmatrix}
371+
\mathbf{Δu}_{k-1}(k+0) \\
372+
\mathbf{Δu}_{k-1}(k+1) \\
373+
\vdots \\
374+
\mathbf{Δu}_{k-1}(k+H_c-2) \\
375+
\mathbf{0} \\
376+
ϵ_{k-1}
377+
\end{bmatrix}
378+
```
379+
where ``\mathbf{Δu}_{k-1}(k+j)`` is the input increment for time ``k+j`` computed at the
380+
last control period ``k-1``. It then calls `JuMP.optimize!(mpc.optim)` and extract the
381+
solution. A failed optimization prints an `@error` log in the REPL and returns the
382+
warm-start value.
366383
"""
367384
function optim_objective!(mpc::PredictiveController{NT}) where {NT<:Real}
368385
optim = mpc.optim

src/controller/explicitmpc.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ end
186186
linconstraint!(::ExplicitMPC, ::LinModel) = nothing
187187

188188
@doc raw"""
189+
optim_objective!(mpc::ExplicitMPC) -> ΔŨ
190+
189191
Analytically solve the optimization problem for [`ExplicitMPC`](@ref).
190192
191193
The solution is ``\mathbf{ΔŨ = - H̃^{-1} q̃}``, see [`init_quadprog`](@ref).

0 commit comments

Comments
 (0)