Skip to content

Commit ac9a6fe

Browse files
committed
refactor ok
1 parent 11399a4 commit ac9a6fe

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

docs/Project.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[deps]
2+
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
3+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
5+
MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9"
6+
OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
7+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

docs/make.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Documenter
2+
3+
makedocs(
4+
warnonly = :cross_references,
5+
sitename = "Geometric preconditioner",
6+
format = Documenter.HTML(
7+
prettyurls = false,
8+
#size_threshold_ignore = [""],
9+
assets=[
10+
asset("https://control-toolbox.org/assets/css/documentation.css"),
11+
asset("https://control-toolbox.org/assets/js/documentation.js"),
12+
],
13+
),
14+
pages = [
15+
"Introduction" => "index.md",
16+
"2D example" => "2D-example.md",
17+
]
18+
)
19+
20+
deploydocs(
21+
repo = "github.com/control-toolbox/preconditioning.git",
22+
devbranch = "main"
23+
)

docs/src/2D-example.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
### Optimal control problem
2+
3+
We consider the following optimal control problem
4+
5+
```math
6+
\left\{ \begin{array}{ll}
7+
\displaystyle \min_{x,u} \int_{t_0}^{t_f} x(t) ~\mathrm dt \\[1em]
8+
\text{s.c.}~\dot x(t) = u(t), & t\in [t_0, t_f]~\mathrm{a.e.}, \\[0.5em]
9+
\phantom{\mathrm{s.c.}~} u(t) \in [-1,1], & t\in [t_0, t_f], \\[0.5em]
10+
\phantom{\mathrm{s.c.}~} x(t_0) = x_0, \quad x(t_f) = x_f,
11+
\end{array} \right.
12+
```
13+
14+
with $x_0$, $t_0$, $x_f$ and $t_f$ fixed. This problem is simple, and can be analytically solve without the use of numerical method. However, the goal is to solve this problem by indirect shooting.
15+
16+
### Indirect method
17+
18+
We introduce the pseudo-Hamiltonian
19+
20+
```math
21+
h(x,p,p^0,u) = p^0 x + p u.
22+
```
23+
24+
For the sake of simplicity, we consider in this notebook only the normal case, and we fix $p^0 = -1$. According to the Pontryagin maximum principle, the maximizing control is given by $u(x,p) \to \mathrm{sign}(p)$. This function is non-differentiable, and may lead to numerical issues.
25+
26+
Let us import the necessary package and define the studied optimal control problem with some fixed initial and final time and state values.
27+
28+
```@example main
29+
using OptimalControl
30+
using Plots
31+
using ForwardDiff
32+
using DifferentialEquations
33+
using MINPACK
34+
35+
t0 = 0
36+
x0 = 0
37+
tf = 5
38+
xf = 0 # initial and final time and state
39+
40+
@def ocp begin # problem definition
41+
42+
t ∈ [ t0, tf ], time
43+
x ∈ R, state
44+
u ∈ R, control
45+
46+
x(t0) == x0
47+
x(tf) == xf
48+
49+
ẋ(t) == u(t)
50+
51+
∫( x(t) ) → min
52+
53+
end
54+
nothing # hide
55+
```

docs/src/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Geometric preconditioner for indirect shooting
2+
3+
blabla

0 commit comments

Comments
 (0)