Skip to content

Commit d92771c

Browse files
authored
Merge pull request #236 from JuliaControl/print_transcription
added: show `TranscriptionMethod` when printing `PredictiveController`
2 parents 9e50689 + c34531f commit d92771c

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

docs/src/manual/linmpc.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ mpc = setconstraint!(mpc, ymin=[48, -Inf])
7878

7979
in which `Hp` and `Hc` keyword arguments are respectively the predictive and control
8080
horizons, and `Mwt` and `Nwt`, the output setpoint tracking and move suppression weights. By
81-
default, [`LinMPC`](@ref) controllers use [`OSQP`](https://osqp.org/) to solve the problem,
82-
soft constraints on output predictions ``\mathbf{ŷ}`` to ensure feasibility, and a
81+
default, [`LinMPC`](@ref) controllers use [`OSQP`](https://osqp.org/) and a direct
82+
[`SingleShooting`](@ref) transcription method to solve the optimal control problem, soft
83+
constraints on output predictions ``\mathbf{ŷ}`` to ensure feasibility, and a
8384
[`SteadyKalmanFilter`](@ref) to estimate the plant states[^1]. An attentive reader will also
8485
notice that the Kalman filter estimates two additional states compared to the plant model.
8586
These are the integrating states for the unmeasured plant disturbances, and they are

docs/src/manual/nonlinmpc.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,10 @@ umin, umax = [-1.5], [+1.5]
119119
nmpc = setconstraint!(nmpc; umin, umax)
120120
```
121121

122-
The option `Cwt=Inf` disables the slack variable `ϵ` for constraint softening. We test `mpc`
123-
performance on `plant` by imposing an angular setpoint of 180° (inverted position):
122+
The option `Cwt=Inf` disables the slack variable `ϵ` for constraint softening. By default,
123+
[`NonLinMPC`](@ref) controllers use [`Ipopt`](https://coin-or.github.io/Ipopt/) and a direct
124+
[`SingleShooting`](@ref) transcription method to solve the optimal control problem. We test
125+
`mpc` performance on `plant` by imposing an angular setpoint of 180° (inverted position):
124126

125127
```@example man_nonlin
126128
using JuMP; unset_time_limit_sec(nmpc.optim) # hide

src/controller/construct.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ constraints are all soft by default. See Extended Help for time-varying constrai
221221
julia> mpc = LinMPC(setop!(LinModel(tf(3, [30, 1]), 4), uop=[50], yop=[25]));
222222
223223
julia> mpc = setconstraint!(mpc, umin=[0], umax=[100], Δumin=[-10], Δumax=[+10])
224-
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SteadyKalmanFilter estimator and:
224+
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SingleShooting transcription, SteadyKalmanFilter estimator and:
225225
10 prediction steps Hp
226226
2 control steps Hc
227227
1 slack variable ϵ (control constraints)

src/controller/linmpc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ arguments. This controller allocates memory at each time step for the optimizati
167167
julia> model = LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 4);
168168
169169
julia> mpc = LinMPC(model, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
170-
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SteadyKalmanFilter estimator and:
170+
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SingleShooting transcription, SteadyKalmanFilter estimator and:
171171
30 prediction steps Hp
172172
1 control steps Hc
173173
1 slack variable ϵ (control constraints)
@@ -237,7 +237,7 @@ Use custom state estimator `estim` to construct `LinMPC`.
237237
julia> estim = KalmanFilter(LinModel([tf(3, [30, 1]); tf(-2, [5, 1])], 4), i_ym=[2]);
238238
239239
julia> mpc = LinMPC(estim, Mwt=[0, 1], Nwt=[0.5], Hp=30, Hc=1)
240-
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, KalmanFilter estimator and:
240+
LinMPC controller with a sample time Ts = 4.0 s, OSQP optimizer, SingleShooting transcription, KalmanFilter estimator and:
241241
30 prediction steps Hp
242242
1 control steps Hc
243243
1 slack variable ϵ (control constraints)

src/controller/nonlinmpc.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ This controller allocates memory at each time step for the optimization.
223223
julia> model = NonLinModel((x,u,_,_)->0.5x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver=nothing);
224224
225225
julia> mpc = NonLinMPC(model, Hp=20, Hc=1, Cwt=1e6)
226-
NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedKalmanFilter estimator and:
226+
NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, SingleShooting transcription, UnscentedKalmanFilter estimator and:
227227
20 prediction steps Hp
228228
1 control steps Hc
229229
1 slack variable ϵ (control constraints)
@@ -327,7 +327,7 @@ julia> model = NonLinModel((x,u,_,_)->0.5x+u, (x,_,_)->2x, 10.0, 1, 1, 1, solver
327327
julia> estim = UnscentedKalmanFilter(model, σQint_ym=[0.05]);
328328
329329
julia> mpc = NonLinMPC(estim, Hp=20, Hc=1, Cwt=1e6)
330-
NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, UnscentedKalmanFilter estimator and:
330+
NonLinMPC controller with a sample time Ts = 10.0 s, Ipopt optimizer, SingleShooting transcription, UnscentedKalmanFilter estimator and:
331331
20 prediction steps Hp
332332
1 control steps Hc
333333
1 slack variable ϵ (control constraints)

src/predictive_control.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function Base.show(io::IO, mpc::PredictiveController)
3333
n = maximum(ndigits.((Hp, Hc, nu, nx̂, nym, nyu, nd))) + 1
3434
println(io, "$(typeof(mpc).name.name) controller with a sample time Ts = "*
3535
"$(mpc.estim.model.Ts) s, $(JuMP.solver_name(mpc.optim)) optimizer, "*
36+
"$(typeof(mpc.transcription).name.name) transcription, "*
3637
"$(typeof(mpc.estim).name.name) estimator and:")
3738
println(io, "$(lpad(Hp, n)) prediction steps Hp")
3839
println(io, "$(lpad(Hc, n)) control steps Hc")

0 commit comments

Comments
 (0)