Skip to content

Commit 9c8612f

Browse files
authored
Merge pull request #183 from control-toolbox/180-dev-up-compat
Update compat and more
2 parents 5917f9f + 36628fc commit 9c8612f

13 files changed

Lines changed: 1440 additions & 49 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ docs/site/
2525
# committed for packages, but should be committed for applications that require a static
2626
# environment.
2727
Manifest.toml
28+
29+
#
30+
reports/

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CTParser"
22
uuid = "32681960-a1b1-40db-9bff-a1ca817385d1"
3+
version = "0.8.0"
34
authors = ["Jean-Baptiste Caillau <jean-baptiste.caillau@univ-cotedazur.fr>"]
4-
version = "0.7.2"
55

66
[deps]
77
CTBase = "54762871-cc72-4466-b8e8-f6c8b58076cd"
@@ -12,10 +12,10 @@ Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
1212
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
1313

1414
[compat]
15-
CTBase = "0.16"
15+
CTBase = "0.17"
1616
DocStringExtensions = "0.9"
1717
MLStyle = "0.4"
18-
OrderedCollections = "1.8"
18+
OrderedCollections = "1"
1919
Parameters = "0.12"
2020
Unicode = "1"
2121
julia = "1.10"

docs/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
[deps]
2+
CTBase = "54762871-cc72-4466-b8e8-f6c8b58076cd"
23
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4+
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
5+
MarkdownAST = "d0879d2d-cac2-40c8-9cee-1863dc0c7391"
36

47
[compat]
8+
CTBase = "0.17"
59
Documenter = "1"

docs/make.jl

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,97 @@
11
using Documenter
22
using CTParser
3-
4-
# to add docstrings from external packages
5-
#Modules = [Plots]
6-
#for Module in Modules
7-
# isnothing(DocMeta.getdocmeta(Module, :DocTestSetup)) &&
8-
# DocMeta.setdocmeta!(Module, :DocTestSetup, :(using $Module); recursive=true)
9-
#end
3+
using CTBase
4+
using Markdown
5+
using MarkdownAST: MarkdownAST
106

117
repo_url = "github.com/control-toolbox/CTParser.jl"
128

13-
makedocs(;
9+
# Paths to source files
10+
src_dir = abspath(joinpath(@__DIR__, "..", "src"))
11+
12+
src(files...) = [abspath(joinpath(src_dir, f)) for f in files]
13+
14+
# Symbols to exclude from automatic reference docs (generated helpers, etc.)
15+
const EXCLUDE_SYMBOLS = Symbol[
16+
:include,
17+
:eval,
18+
]
19+
20+
makedocs(
21+
draft=false,
1422
remotes=nothing,
15-
warnonly=[:cross_references, :autodocs_block],
23+
warnonly=true,
1624
sitename="CTParser.jl",
1725
format=Documenter.HTML(;
1826
repolink="https://" * repo_url,
1927
prettyurls=false,
20-
size_threshold_ignore=["dev.md"],
2128
assets=[
2229
asset("https://control-toolbox.org/assets/css/documentation.css"),
2330
asset("https://control-toolbox.org/assets/js/documentation.js"),
2431
],
2532
),
26-
pages=["Introduction" => "index.md", "API" => "dev.md"],
2733
checkdocs=:none,
34+
pages=[
35+
"Introduction" => "index.md",
36+
"API Reference" => [
37+
CTBase.automatic_reference_documentation(
38+
subdirectory=".",
39+
primary_modules=[
40+
CTParser => src(
41+
"defaults.jl",
42+
),
43+
],
44+
exclude=EXCLUDE_SYMBOLS,
45+
public=false,
46+
private=true,
47+
title="Defaults",
48+
title_in_menu="Defaults",
49+
filename="defaults",
50+
),
51+
CTBase.automatic_reference_documentation(
52+
subdirectory=".",
53+
primary_modules=[
54+
CTParser => src(
55+
"utils.jl",
56+
),
57+
],
58+
exclude=EXCLUDE_SYMBOLS,
59+
public=false,
60+
private=true,
61+
title="Utils",
62+
title_in_menu="Utils",
63+
filename="utils",
64+
),
65+
CTBase.automatic_reference_documentation(
66+
subdirectory=".",
67+
primary_modules=[
68+
CTParser => src(
69+
"onepass.jl",
70+
),
71+
],
72+
exclude=EXCLUDE_SYMBOLS,
73+
public=false,
74+
private=true,
75+
title="Onepass",
76+
title_in_menu="Onepass",
77+
filename="onepass",
78+
),
79+
CTBase.automatic_reference_documentation(
80+
subdirectory=".",
81+
primary_modules=[
82+
CTParser => src(
83+
"initial_guess.jl",
84+
),
85+
],
86+
exclude=EXCLUDE_SYMBOLS,
87+
public=false,
88+
private=true,
89+
title="Initial Guess",
90+
title_in_menu="Initial Guess",
91+
filename="initial_guess",
92+
),
93+
],
94+
],
2895
)
2996

3097
deploydocs(; repo=repo_url * ".git", devbranch="main")

docs/src/dev.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/src/index.md

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,109 @@
22

33
The `CTParser.jl` package is part of the [control-toolbox ecosystem](https://github.com/control-toolbox).
44

5-
The root package is [OptimalControl.jl](https://github.com/control-toolbox/OptimalControl.jl) which aims to provide tools to model and solve optimal control problems with ordinary differential equations by direct and indirect methods, both on CPU and GPU.
5+
!!! note
6+
7+
The root package is [OptimalControl.jl](https://github.com/control-toolbox/OptimalControl.jl) which aims
8+
to provide tools to model and solve optimal control problems with ordinary differential equations
9+
by direct and indirect methods, both on CPU and GPU.
10+
11+
!!! warning
12+
13+
In some examples in the documentation, private methods are shown without the module prefix.
14+
This is done for the sake of clarity and readability.
15+
16+
```julia-repl
17+
julia> using CTParser
18+
julia> x = 1
19+
julia> private_fun(x) # throws an error
20+
```
21+
22+
This should instead be written as:
23+
24+
```julia-repl
25+
julia> using CTParser
26+
julia> x = 1
27+
julia> CTParser.private_fun(x)
28+
```
29+
30+
If the method is re-exported by another package,
31+
32+
```julia
33+
module OptimalControl
34+
import CTParser: private_fun
35+
export private_fun
36+
end
37+
```
38+
39+
then there is no need to prefix it with the original module name:
40+
41+
```julia-repl
42+
julia> using OptimalControl
43+
julia> x = 1
44+
julia> private_fun(x)
45+
```
46+
47+
## What CTParser provides
48+
49+
At a high level, `CTParser.jl` is responsible for turning a compact,
50+
mathematical DSL into executable Julia code for the rest of the
51+
ecosystem (in particular `CTModels.jl` and `ExaModels.jl`). It does not
52+
solve optimal control problems by itself; instead, it focuses on
53+
parsing and code generation.
54+
55+
The two main entry points are:
56+
57+
- **`@def` macro** – define an optimal control problem from a
58+
human-readable specification.
59+
- **`@init` macro** – define an initial guess for state, control and
60+
variables using a small initialisation DSL.
61+
62+
### The `@def` macro and its backends
63+
64+
The macro
65+
66+
```julia
67+
ocp = @def begin
68+
# symbolic definition of an OCP
69+
end
70+
```
71+
72+
parses the block and builds an intermediate representation of the
73+
optimal control problem. Internally, `@def` can target different
74+
*backends*:
75+
76+
- the **functional backend** `:fun` (default), where the OCP is
77+
represented by a `CTModels.Model` and evaluated through Julia
78+
functions;
79+
- the **ExaModels backend** `:exa`, where the same symbolic description
80+
is lowered to an `ExaModels.ExaModel` suitable for large-scale NLP
81+
solvers.
82+
83+
The active backends and their prefixes are controlled by
84+
`prefix_fun()`, `prefix_exa()` and the corresponding setters. This
85+
allows other packages (such as `OptimalControl.jl`) to plug in custom
86+
model types while reusing the same parsing layer.
87+
88+
### The `@init` macro for initial guesses
89+
90+
The macro
91+
92+
```julia
93+
ig = @init ocp begin
94+
# initialisation DSL
95+
end
96+
```
97+
98+
provides a compact way of building initial guesses for an OCP. The
99+
block can mix:
100+
101+
- **time-dependent functions**, e.g. `u(t) := t` or `x(t) := [sin(t), 1]`;
102+
- **time grids**, e.g. `x(T) := X` where `T` is a vector of times and
103+
`X` samples along the trajectory;
104+
- **constants and aliases**, e.g. `a = 1.0; v(t) := a` or `tf := 1.0`.
105+
106+
`@init` itself only rewrites this DSL into a `NamedTuple` of symbolic
107+
specifications. The actual construction and validation of a
108+
backend-specific initial guess object is delegated to the module
109+
selected by `init_prefix()` (by défaut `CTModels`), via
110+
`build_initial_guess` et `validate_initial_guess`.

src/CTParser.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ using Unicode
2323
include("defaults.jl")
2424
include("utils.jl")
2525
include("onepass.jl")
26+
include("initial_guess.jl")
2627

2728
end

0 commit comments

Comments
 (0)