Skip to content

Commit ad644e3

Browse files
authored
Merge pull request #2 from control-toolbox/1-refactoring-to-make-a-doc
first commit
2 parents 0d1fad4 + e048583 commit ad644e3

18 files changed

+221
-9
lines changed

.github/workflows/CI.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# [.github/workflows/CI.yml]
2+
name: CI
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags: '*'
8+
pull_request:
9+
jobs:
10+
test:
11+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
version:
16+
- '1.10'
17+
os:
18+
- ubuntu-latest
19+
arch:
20+
- x64
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: julia-actions/setup-julia@latest
24+
with:
25+
version: ${{ matrix.version }}
26+
arch: ${{ matrix.arch }}
27+
- uses: julia-actions/julia-runtest@latest

.github/workflows/Documentation.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# [.github/workflows/Documentation.yml]
2+
name: Documentation
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
tags: '*'
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: julia-actions/setup-julia@latest
17+
- uses: julia-actions/julia-buildpkg@latest
18+
- name: Install dependencies
19+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
20+
- name: Build and deploy
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
23+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
24+
GKSwstype: 100 # To make GitHub Action work, disable showing a plot window with the GR backend of the Plots package
25+
run: julia --project=docs/ -e 'ENV["GKSwstype"]="nul" ; include("docs/make.jl")'

.github/workflows/coverage.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# [.github/workflows/coverage.yml]
2+
name: coverage
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags: '*'
8+
jobs:
9+
test:
10+
name: coverage
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: julia-actions/setup-julia@latest
15+
- uses: julia-actions/julia-runtest@latest
16+
- uses: julia-actions/julia-processcoverage@latest
17+
- uses: codecov/codecov-action@v4
18+
env:
19+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.vscode
2+
.DS_Store
3+
14
# Files generated by invoking Julia with --code-coverage
25
*.jl.cov
36
*.jl.*.cov

Project.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
[deps]
2-
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
3-
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
4-
MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9"
5-
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
6-
OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
7-
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
8-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
9-
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
1+
name = "GeometricPreconditioner"
2+
uuid = "4fb4c77a-c2a1-4666-8b47-e5158870c0af"
3+
authors = ["Olivier Cots <olivier.cots@irit.fr>"]
4+
version = "0.1.0"

README.md

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

3+
[ci-img]: https://github.com/control-toolbox/preconditioning/actions/workflows/CI.yml/badge.svg?branch=main
4+
[ci-url]: https://github.com/control-toolbox/preconditioning/actions/workflows/CI.yml?query=branch%3Amain
5+
6+
[co-img]: https://codecov.io/gh/control-toolbox/preconditioning/branch/main/graph/badge.svg?token=YM5YQQUSO3
7+
[co-url]: https://codecov.io/gh/control-toolbox/preconditioning
8+
9+
[doc-dev-img]: https://img.shields.io/badge/docs-dev-8A2BE2.svg
10+
[doc-dev-url]: https://control-toolbox.org/preconditioning/dev/
11+
12+
[doc-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg
13+
[doc-stable-url]: https://control-toolbox.org/preconditioning/stable/
14+
15+
Geometric preconditioner for indirect shooting
16+
17+
This repo is part of the [control-toolbox ecosystem](https://github.com/control-toolbox).
18+
The control-toolbox ecosystem gathers `Julia` packages for mathematical control and applications. The root package is [`OptimalControl.jl`](https://github.com/control-toolbox/OptimalControl.jl) which aims to provide tools to modelise and solve optimal control problems by direct and indirect methods. [![doc OptimalControl.jl](https://img.shields.io/badge/doc-OptimalControl.jl-blue)](http://control-toolbox.org/OptimalControl.jl)
19+
20+
| **Documentation** | **Code Status** |
21+
|:-------------------|:-----------------|
22+
| [![Documentation][doc-stable-img]][doc-stable-url] [![Documentation][doc-dev-img]][doc-dev-url] | [![Build Status][ci-img]][ci-url] [![Covering Status][co-img]][co-url] |

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
File renamed without changes.
File renamed without changes.
File renamed without changes.

resources/Project.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[deps]
2+
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
3+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
4+
MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9"
5+
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
6+
OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
7+
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
8+
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
9+
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"

src/GeometricPreconditioner.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module GeometricPreconditioner
2+
3+
greet() = print("Hello World!")
4+
5+
end # module GeometricPreconditioner

test/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

test/runtests.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Test
2+
using GeometricPreconditioner
3+
4+
#
5+
@testset verbose = true showtiming = true "Base" begin
6+
for name (
7+
:default,
8+
)
9+
@testset "$(name)" begin
10+
test_name = Symbol(:test_, name)
11+
include("$(test_name).jl")
12+
@eval $test_name()
13+
end
14+
end
15+
end

test/test_default.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# test_default
2+
function test_default()
3+
@test GeometricPreconditioner.greet() isa Nothing
4+
end

0 commit comments

Comments
 (0)