Skip to content

Commit 6ba9cd3

Browse files
committed
foo
1 parent 02441ff commit 6ba9cd3

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

docs/Project.toml

-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ CTProblems = "45d9ea3f-a92f-411f-833f-222dd4fb9cd8"
66
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
88
MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9"
9-
OptimalControl = "5f98b655-cc9a-415a-b60e-744165666948"
109
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
1110
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"

docs/src/tutorial-basic-example-f.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ starting from the condition $x(0) = (-1, 0)$ and with the goal to reach the targ
3131
```@setup main
3232
using Plots
3333
using Plots.PlotMeasures
34-
plot(args...; kwargs...) = Plots.plot(args...; kwargs..., leftmargin=20px)
34+
plot(args...; kwargs...) = Plots.plot(args...; kwargs..., leftmargin=25px)
3535
```
3636

3737
First, we need to import the `OptimalControl.jl` package:

docs/src/tutorial-basic-example.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ starting from the condition $x(0) = (-1, 0)$ and with the goal to reach the targ
3131
```@setup main
3232
using Plots
3333
using Plots.PlotMeasures
34-
plot(args...; kwargs...) = Plots.plot(args...; kwargs..., leftmargin=20px)
34+
plot(args...; kwargs...) = Plots.plot(args...; kwargs..., leftmargin=25px)
3535
```
3636

3737
First, we need to import the `OptimalControl.jl` package:

docs/src/tutorial-goddard.md

+31-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [Advanced example: the Goddard problem](@id goddard)
1+
# [Advanced example](@id goddard)
22

33
## Introduction
44

@@ -38,7 +38,7 @@ $v(t) \leq v_{\max}$. The initial state is fixed while only the final mass is pr
3838
```@setup main
3939
using Plots
4040
using Plots.PlotMeasures
41-
plot(args...; kwargs...) = Plots.plot(args...; kwargs..., leftmargin=20px)
41+
plot(args...; kwargs...) = Plots.plot(args...; kwargs..., leftmargin=25px)
4242
using Suppressor # to suppress warnings
4343
```
4444

@@ -141,35 +141,57 @@ We are now in position to solve the problem by an indirect shooting method. We f
141141
the four control laws in feedback form and their associated flows. For this we need to
142142
compute some Lie derivatives,
143143
namely [Poisson brackets](https://en.wikipedia.org/wiki/Poisson_bracket) of Hamiltonians
144-
(themselves obtained as lifts to the cotangent bundle of vector fields), or
144+
(themselves obtained as lifts to the cotangent bundle of vector fields), or
145145
derivatives of functions along a vector field. For instance, the control along the
146146
*minimal order* singular arcs is obtained as the quotient
147+
147148
```math
148149
u_s = -\frac{H_{001}}{H_{101}}
149150
```
151+
150152
of length three Poisson brackets:
153+
151154
```math
152-
H_{001} = \{H_0,\{H_0,H_1\}\}
155+
H_{001} = \{H_0,\{H_0,H_1\}\}, \quad H_{101} = \{H_1,\{H_0,H_1\}\}
153156
```
157+
154158
where, for two Hamiltonians $H$ and $G$,
159+
155160
```math
156161
\{H,G\} := (\nabla_p H|\nabla_x G) - (\nabla_x H|\nabla_p G).
157162
```
163+
158164
While the Lie derivative of a function $f$ *wrt.* a vector field $X$ is simply obtained as
165+
159166
```math
160167
(X \cdot f)(x) := f'(x) \cdot X(x),
161168
```
162-
and is used to the compute the control along the boundary arc,
169+
170+
and is used to the compute the control along the boundary arc,
171+
163172
```math
164173
u_b(x) = -(F_0 \cdot g)(x) / (F_1 \cdot g)(x),
165174
```
175+
166176
as well as the associated multiplier for the *order one* state constraint on the velocity:
177+
167178
```math
168179
\mu(x, p) = H_{01}(x, p) / (F_1 \cdot g)(x).
169180
```
170181

182+
!!! note
183+
184+
The Poisson bracket $\{H,G\}$ is also given by the Lie derivative of $G$ along the
185+
Hamiltonian vector field $X_H = (\nabla_p H, -\nabla_x H)$ of $H$, that is
186+
187+
```math
188+
\{H,G\} = X_H \cdot G
189+
```
190+
191+
which is the reason why we use the `@Lie` macro to compute Poisson brackets below.
192+
171193
With the help of the [differential geometry primitives](https://control-toolbox.org/CTBase.jl/stable/api-diffgeom.html)
172-
form [CTBase.jl](https://control-toolbox.org/CTBase.jl/stable/index.html),
194+
from [CTBase.jl](https://control-toolbox.org/docs/ctbase),
173195
these expressions are straightforwardly translated into Julia code:
174196

175197
```@example main
@@ -198,7 +220,7 @@ Then, we define the shooting function according to the optimal structure we have
198220
that is a concatenation of four arcs.
199221

200222
```@example main
201-
x0 = [ r0, v0, m0 ] # initial state
223+
x0 = [ r0, v0, m0 ] # initial state
202224
203225
function shoot!(s, p0, t1, t2, t3, tf)
204226
@@ -252,8 +274,8 @@ Finally, we can solve the shooting equations thanks to the [MINPACK](https://doc
252274
```@example main
253275
using MINPACK # NLE solver
254276
255-
nle = (s, ξ) -> shoot!(s, ξ[1:3], ξ[4], ξ[5], ξ[6], ξ[7]) # auxiliary function with aggregated inputs
256-
277+
nle = (s, ξ) -> shoot!(s, ξ[1:3], ξ[4], ξ[5], ξ[6], ξ[7]) # auxiliary function
278+
# with aggregated inputs
257279
ξ = [ p0 ; t1 ; t2 ; t3 ; tf ] # initial guess
258280
indirect_sol = @suppress_err begin # hide
259281
fsolve(nle, ξ)

src/OptimalControl.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ export variable!, time!, constraint!, dynamics!, objective!, state!, control!, r
5151
export is_time_independent, is_time_dependent, is_min, is_max, is_variable_dependent, is_variable_independent
5252
export Lie, @Lie, Poisson, Lift, , ∂ₜ
5353
export @def
54-
export ctrepl
54+
export ct_repl
5555

5656
# CTProblems
5757
export ProblemsDescriptions, Problem, Problems, @ProblemsDescriptions, @Problems
5858

59-
6059
# repl
61-
isdefined(Base, :active_repl) && ctrepl()
60+
isdefined(Base, :active_repl) && ct_repl()
6261

6362
end

0 commit comments

Comments
 (0)