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
- Clean up line breaks and spacing in manual-flow-ocp.md
- Remove unnecessary blank lines and improve readability
- Consolidate multiline text for better formatting
Copy file name to clipboardExpand all lines: docs/src/manual-flow-ocp.md
+14-32Lines changed: 14 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,16 +45,14 @@ where $p^0 = -1$ since we are in the normal case. From the Pontryagin maximum pr
45
45
u(x, p) = p_v
46
46
```
47
47
48
-
since $\partial^2_{uu} H = p^0 = - 1 < 0$.
48
+
since $\partial^2_{uu} H = p^0 = - 1 < 0$.
49
49
50
50
```@example main
51
51
u(x, p) = p[2]
52
52
nothing # hide
53
53
```
54
54
55
-
Actually, if $(x, u)$ is a solution of the optimal control problem,
56
-
then, the Pontryagin maximum principle tells us that there exists a costate $p$ such that $u(t) = u(x(t), p(t))$
57
-
and such that the pair $(x, p)$ satisfies:
55
+
Actually, if $(x, u)$ is a solution of the optimal control problem, then, the Pontryagin maximum principle tells us that there exists a costate $p$ such that $u(t) = u(x(t), p(t))$ and such that the pair $(x, p)$ satisfies:
As you can see, an error occurred since we need the package [OrdinaryDiffEq.jl](https://docs.sciml.ai/DiffEqDocs).
85
-
This package provides numerical integrators to compute solutions of the ordinary differential equation
86
-
$\dot{z}(t) = \vec{\mathbf{H}}(z(t))$.
82
+
As you can see, an error occurred since we need the package [OrdinaryDiffEq.jl](https://docs.sciml.ai/DiffEqDocs). This package provides numerical integrators to compute solutions of the ordinary differential equation $\dot{z}(t) = \vec{\mathbf{H}}(z(t))$.
87
83
88
84
!!! note "OrdinaryDiffEq.jl"
89
85
@@ -110,9 +106,7 @@ sol = f((t0, tf), x0, p0)
110
106
nothing # hide
111
107
```
112
108
113
-
In this case, you obtain a data that you can plot exactly like when solving the optimal control problem
114
-
with the function [`solve`](@ref). See for instance the [basic example](@ref example-double-integrator-energy-solve-plot) or the
115
-
[plot tutorial](@ref manual-plot).
109
+
In this case, you obtain a data that you can plot exactly like when solving the optimal control problem with the function [`solve`](@ref). See for instance the [basic example](@ref example-double-integrator-energy-solve-plot) or the [plot tutorial](@ref manual-plot).
The argument `saveat` is an option from OrdinaryDiffEq.jl. Please check the
140
-
[list of common options](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/#solver_options).
141
-
For instance, one can change the integrator with the keyword argument `alg` or the absolute tolerance with
142
-
`abstol`. Note that you can set an option when declaring the flow or set an option in a particular call of the flow.
143
-
In the following example, the integrator will be `BS5()` and the absolute tolerance will be `abstol=1e-8`.
133
+
The argument `saveat` is an option from OrdinaryDiffEq.jl. Please check the [list of common options](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/#solver_options). For instance, one can change the integrator with the keyword argument `alg` or the absolute tolerance with `abstol`. Note that you can set an option when declaring the flow or set an option in a particular call of the flow. In the following example, the integrator will be `BS5()` and the absolute tolerance will be `abstol=1e-8`.
144
134
145
135
```@example main
146
136
f = Flow(ocp, u; alg=BS5(), abstol=1) # alg=BS5(), abstol=1
@@ -179,7 +169,7 @@ The pseudo-Hamiltonian of this problem is
where $p^0 = -1$ since we are in the normal case. We can notice that the pseudo-Hamiltonian is non-autonomous since it explicitly depends on the time $t$.
172
+
where $p^0 = -1$ since we are in the normal case. We can notice that the pseudo-Hamiltonian is non-autonomous since it explicitly depends on the time $t$.
183
173
184
174
```@example main
185
175
is_autonomous(ocp)
@@ -191,15 +181,14 @@ From the Pontryagin maximum principle, the maximising control is given in feedba
191
181
u(t, x, p) = p\, (1+\tan\, t)
192
182
```
193
183
194
-
since $\partial^2_{uu} H = p^0 = - 1 < 0$.
184
+
since $\partial^2_{uu} H = p^0 = - 1 < 0$.
195
185
196
186
```@example main
197
187
u(t, x, p) = p * (1 + tan(t))
198
188
nothing # hide
199
189
```
200
190
201
-
As before, the `Flow` function aims to compute $(x, p)$ from the optimal control problem `ocp` and the control in feedback form `u(t, x, p)`.
202
-
Since the problem is non-autonomous, we must provide a control law that depends on time.
191
+
As before, the `Flow` function aims to compute $(x, p)$ from the optimal control problem `ocp` and the control in feedback form `u(t, x, p)`. Since the problem is non-autonomous, we must provide a control law that depends on time.
203
192
204
193
```@example main
205
194
f = Flow(ocp, u)
@@ -239,8 +228,7 @@ end
239
228
nothing # hide
240
229
```
241
230
242
-
As you can see, the variable is the final time `tf`. Note that the dynamics depends on `tf`.
243
-
From the Pontryagin maximum principle, the solution is given by:
231
+
As you can see, the variable is the final time `tf`. Note that the dynamics depends on `tf`. From the Pontryagin maximum principle, the solution is given by:
244
232
245
233
```@example main
246
234
tf = (3/2)^(1/4)
@@ -262,8 +250,7 @@ f = Flow(ocp, u)
262
250
xf, pf = f(t0, x0, p0, tf, tf)
263
251
```
264
252
265
-
The usage of the flow `f` is the following: `f(t0, x0, p0, tf, v)` where `v` is the variable. If one wants
266
-
to compute the state at time `t1 = 0.5`, then, one must write:
253
+
The usage of the flow `f` is the following: `f(t0, x0, p0, tf, v)` where `v` is the variable. If one wants to compute the state at time `t1 = 0.5`, then, one must write:
In the [Goddard problem](https://control-toolbox.org/Tutorials.jl/stable/tutorial-goddard.html#tutorial-goddard-structure), you may find other constructions of flows, especially for singular and boundary arcs.
336
322
337
-
338
323
## Concatenation of arcs
339
324
340
325
In this part, we present how to concatenate several flows. Let us consider the following problem.
@@ -362,8 +347,7 @@ end
362
347
nothing # hide
363
348
```
364
349
365
-
From the Pontryagin maximum principle, the optimal control is a concatenation of an off arc ($u=0$) followed by a
366
-
positive bang arc ($u=1$). The initial costate is
350
+
From the Pontryagin maximum principle, the optimal control is a concatenation of an off arc ($u=0$) followed by a positive bang arc ($u=1$). The initial costate is
We consider an optimal control problem with a state constraints of order 1.[^1]
407
+
We consider an optimal control problem with a state constraints of order 1.[^1]
424
408
425
409
[^1]: B. Bonnard, L. Faubourg, G. Launay & E. Trélat, Optimal Control With State Constraints And The Space Shuttle Re-entry Problem, J. Dyn. Control Syst., 9 (2003), no. 2, 155–199.
426
410
@@ -457,7 +441,6 @@ The pseudo-Hamiltonian of this problem is
457
441
458
442
where $ p^0 = -1 $ since we are in the normal case, and where $c(x) = x - l_b$. Along a boundary arc, when $c(x(t)) = 0$, we have $x(t) = l_b$, so $ x(\cdot) $ is constant. Differentiating, we obtain $\dot{x}(t) = u(t) = 0$. Hence, along a boundary arc, the control in feedback form is:
459
443
460
-
461
444
```math
462
445
u(x) = 0.
463
446
```
@@ -534,7 +517,6 @@ The pseudo-Hamiltonian of this problem is
534
517
535
518
where $ p^0 = -1 $ since we are in the normal case, and where the constraint is $c(x) = l - x_1 \ge 0$. Along a boundary arc, when $c(x(t)) = 0$, we have $x_1(t) = l$, so $\dot{x}_1(t) = x_2(t) = 0$. Differentiating again, we obtain $\dot{x}_2(t) = u(t) = 0$ (the constraint is of order 2). Hence, along a boundary arc, the control in feedback form is:
0 commit comments