Skip to content

Commit 36deef6

Browse files
authored
Merge pull request #245 from JuliaControl/doc_manual_ms
doc: using `MultipleShooting` in the manual for the unstable pendulum system
2 parents 77163a7 + adf25bb commit 36deef6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

docs/src/manual/nonlinmpc.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,26 @@ savefig("plot10_NonLinMPC.svg"); nothing # hide
396396

397397
![plot10_NonLinMPC](plot10_NonLinMPC.svg)
398398

399-
The closed-loop performance is still lower than the nonlinear controller, as expected, but
399+
Additionally, similar results are obtained by using a sparse [`MultipleShooting`](@ref)
400+
transcription, which is known to be more robust for unstable systems, with a solver that can
401+
explicilty handle sparsity like the default `OSQP`:
402+
403+
```@example man_nonlin
404+
mpc_ms = LinMPC(skf; Hp, Hc, Mwt, Nwt, Cwt=Inf, transcription=MultipleShooting())
405+
mpc_ms = setconstraint!(mpc_ms, umin=[-1.5], umax=[+1.5])
406+
```
407+
408+
Superimposing the previous disturbance rejection plot shows almost identical results:
409+
410+
```@example man_nonlin
411+
res_ms = sim!(mpc_ms, N, [180.0]; plant, x_0=[π, 0], y_step=[10])
412+
plot!(res_ms)
413+
savefig("plot10b_NonLinMPC.svg"); nothing # hide
414+
```
415+
416+
![plot10b_NonLinMPC](plot10b_NonLinMPC.svg)
417+
418+
The closed-loop performances are still lower than the nonlinear controller, as expected, but
400419
computations are about 210 times faster (0.000071 s versus 0.015 s per time steps, on
401420
average). However, remember that `linmodel` is only valid for angular positions near 180°.
402421
For example, the 180° setpoint response from 0° is unsatisfactory since the predictions are

0 commit comments

Comments
 (0)