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
which is simply the [double integrator](https://en.wikipedia.org/w/index.php?title=Double_integrator&oldid=1071399674) system.
17
-
Let us consider a transfer starting at time $t_0 = 0$ and ending at time $t_f = 1$, for which we want to minimise the transfer energy
16
+
which is simply the [double integrator](https://en.wikipedia.org/w/index.php?title=Double_integrator&oldid=1071399674) system. Let us consider a transfer starting at time $t_0 = 0$ and ending at time $t_f = 1$, for which we want to minimise the transfer energy
18
17
19
18
```math
20
19
\frac{1}{2}\int_{0}^{1} u^2(t) \, \mathrm{d}t
21
20
```
22
21
23
22
starting from $x(0) = (-1, 0)$ and aiming to reach the target $x(1) = (0, 0)$.
24
23
25
-
First, we need to import the [OptimalControl.jl](https://control-toolbox.org/OptimalControl.jl) package to define the
26
-
optimal control problem, [NLPModelsIpopt.jl](https://jso.dev/NLPModelsIpopt.jl) to solve it,
27
-
and [Plots.jl](https://docs.juliaplots.org) to visualise the solution.
24
+
First, we need to import the [OptimalControl.jl](https://control-toolbox.org/OptimalControl.jl) package to define the optimal control problem, [NLPModelsIpopt.jl](https://jso.dev/NLPModelsIpopt.jl) to solve it, and [Plots.jl](https://docs.juliaplots.org) to visualise the solution.
28
25
29
26
```@example main
30
27
using OptimalControl
@@ -36,6 +33,11 @@ using Plots
36
33
37
34
Let us define the problem with the [`@def`](@ref) macro:
For a comprehensive introduction to the syntax used above to define the optimal control problem, see [this abstract syntax tutorial](@ref manual-abstract-syntax). In particular, non-Unicode alternatives are available for derivatives, integrals, *etc.*
@@ -142,12 +166,12 @@ plot(sol)
142
166
143
167
## State constraint
144
168
145
-
### Direct method
169
+
### Direct method: constrained case
146
170
147
171
We add the path constraint
148
172
149
173
```math
150
-
x_2(t) \le 1.2.
174
+
x_2(t) \le 1.2.
151
175
```
152
176
153
177
Let us model, solve and plot the optimal control problem with this constraint.
@@ -175,7 +199,7 @@ sol = solve(ocp)
175
199
plt = plot(sol; label="Direct", size=(800, 600))
176
200
```
177
201
178
-
### Indirect method
202
+
### Indirect method: constrained case
179
203
180
204
The pseudo-Hamiltonian is (considering the normal case):
181
205
@@ -186,13 +210,13 @@ H(x, p, u, \mu) = p_1 x_2 + p_2 u - \frac{u^2}{2} + \mu\, c(x),
186
210
with $c(x) = x_2 - a$. Along a boundary arc we have $c(x(t)) = 0$. Differentiating, we obtain:
Since the adjoint vector is continuous at the entry time $t_1$ and the exit time $t_2$, we have four unknowns: the initial costate $p_0 \in \mathbb{R}^2$ and the times $t_1$ and $t_2$. We need four equations: the target condition provides two, reaching the constraint at time $t_1$ gives $c(x(t_1)) = 0$, and finally $p_2(t_1) = 0$.
0 commit comments