From a99fc49b54d28e74be384dd1531f9e9afd63df7a Mon Sep 17 00:00:00 2001
From: Olivier Cots <61-ocots@users.noreply.022e47118ec0>
Date: Fri, 26 Mar 2021 10:26:54 +0000
Subject: [PATCH] Update lecture.md

---
 course/lecture/lecture.md | 156 ++++++++++++++++++++++++++++++++------
 1 file changed, 132 insertions(+), 24 deletions(-)

diff --git a/course/lecture/lecture.md b/course/lecture/lecture.md
index 44ac66c..e9aba13 100644
--- a/course/lecture/lecture.md
+++ b/course/lecture/lecture.md
@@ -23,25 +23,6 @@ The goal of this presentation is that at the end, you will be able to implement
 **_Contents_**
 
 [[_TOC_]]
-
-* I) Statement of the optimal control problem and necessary conditions of optimality
-    * a) Definition of the optimal control problem - [Video](https://youtu.be/QUbeyLNZR8A)
-    * b) Application of the Pontryagin Maximum Principle - [Video](https://youtu.be/xedLNn08Kn4)
-    * c) The hidden true Hamiltonian - [Video](https://youtu.be/inCRJZWT3Ng)
-    * d) Illustration of the resolution of the necessary conditions of optimality - [Video](https://youtu.be/oRm8_Grs2Aw)
-* II) Examples and boundary value problems
-    * a) Simple 1D example - [Video](https://youtu.be/r4oYTkF76TA)
-    * b) Calculus of variations - [Video](https://youtu.be/Ud16jTQbsQ0)
-    * c) An energy min navigation problem
-* III) Indirect simple shooting
-    * a) The shooting equation - [Video](https://youtu.be/YVG2Z_TEkBQ)
-    * b) The iteration of the Newton solver and the Jacobian of the shooting function - 
-    [Video](https://youtu.be/hVbi9kShR90)
-    * c) A word on the Lagrange multiplier - [Video](https://youtu.be/3VEi-UHAS6w)
-* IV) Numerical resolution of the shooting equations with the nutopy package
-    * a) Simple 1D example
-    * b) Calculus of variations
-    * c) An energy min navigation problem - exercice
     
 ## I) Statement of the optimal control problem and necessary conditions of optimality
 
@@ -194,13 +175,13 @@ where $`[t] := (x(t),p(t),u(t))`$.  If $`p^0 = 0`$, then $`p = 0`$ by the third
 **_Remark:_** We do not consider the transversality condition when the target $`x_f`$ is fixed. We can retrieve simply the Lagrange multiplier by the relation $`p(t_f)=\lambda`$. 
 
 **_Remark:_** The maximization condition,
-```math
+$`
 H[t] = \max_{w \in \mathrm{R}} H(x(t), p(t), w),
-```
+`$
 is equivalent here to the condition 
-```math
+$`
 \nabla_u H[t] = 0
-```
+`$
  by concavity.
 
 Solving $`\nabla_u H[t] = 0`$, the control satisfies $`u(t) = u[x(t), p(t)] := p(t)`$ where we have introduced the smooth function on $`\mathrm{R} \times \mathrm{R}`$:
@@ -266,6 +247,133 @@ Solving $`x(t_f, x_0, p_0) = x_f`$, we obtain
 
 with $`\pi_x(x,p) := x`$.  Solving $`S(p_0) = 0`$ is what we call the *indirect simple shooting method*.
 
-**_Remark:_** Note that thanks to the PMP, we have replaced the research of u (which is a function of time) by the research of an element of $`\mathrm{R}`$: the covector $`p_0`$.  The prize of such a drastic reduction is to work in the *cotangent space*, that is the trajectory $`x`$ is lifted in a bigger space and adjoined with a covector $`p`$: this makes the simple shooting method to be qualified of *indirect*. It is important to note that in the indirect methods we work with $`z=(x,p)`$ and not only with the trajectory $`x`$. 
+>>>
+**_Summary_**
+
+Note that thanks to the PMP, we have replaced the research of u (which is a function of time) by the research of an element of $`\mathrm{R}`$: the covector $`p_0`$.  The prize of such a drastic reduction is to work in the *cotangent space*, that is the trajectory $`x`$ is lifted in a bigger space and adjoined with a covector $`p`$: this makes the simple shooting method to be qualified of *indirect*. It is important to note that in the indirect methods we work with $`z=(x,p)`$ and not only with the trajectory $`x`$. 
+>>>
 
 [Additional comments (video)](http://www.youtube.com/watch?v=r4oYTkF76TA)
+
+### b) Calculus of variations
+
+**_Remark:_** The interest of this part is to present some particular cases in the context of calculus of variations for which our assumptions are satisfied.
+
+[Additional comments (video)](http://www.youtube.com/watch?v=Ud16jTQbsQ0)
+
+### c) An energy min navigation problem 
+
+**_Remark:_** The interest of this example is to present a case where we have some transversality conditions.
+
+We consider the optimal control problem:
+```math 
+    \left\{ 
+    \begin{array}{l}
+        \displaystyle J(u)  := \displaystyle \frac{1}{2} \int_0^{t_f} u_1^2(t) + u_2^2(t) \, \mathrm{d}t \longrightarrow \min \\[1.0em]
+        \dot{x}(t) =  \displaystyle (1, 0) + u(t), \quad  u(t) \in \mathrm{R}^2, \quad t \in [0, t_f] \text{ a.e.}, \\[1.0em]
+        x(0) = (0, 0) , \quad x_2(t_f) = 1.
+    \end{array}
+    \right. 
+```
+
+The pseudo-Hamiltonian reads
+
+```math
+    H(x,p,u) := p_1 + (p | u) - \frac{1}{2} (u_1^2+u_2^2), \quad p^0 = -1.
+```
+
+The PMP gives:
+
+```math
+\dot{x} = (1,0) + u, \quad \dot{p} = 0, \quad u = p, \quad p(t_f) = (0, \lambda),
+```
+
+and so we have to solve the BVP:
+
+```math
+        \left\{ 
+            \begin{array}{rcl}
+                \dot{x}(t)  &=& (1, 0) + p(t),   \\[0.5em]
+                \dot{p}(t)  &=& 0,         \\[0.5em]
+                x(0) &=& (0,0), \quad x_2(t_f) = 1, \quad p(t_f) = (0, \lambda).
+            \end{array}
+        \right. 
+```
+
+Computing we get,
+
+```math
+    u(t) = p(t) = (0, \frac{1}{t_f}), \quad \lambda = \frac{1}{t_f}, \quad x(t) = (t, \frac{t}{t_f}).
+```
+
+## III) Indirect simple shooting
+
+### a) The shooting equation
+
+>>>
+
+**_Boundary value problem_**
+
+Under our assumptions and thanks to the PMP we have to solve the following boundary value problem with a parameter $\lambda$:
+
+```math
+        \left\{ 
+            \begin{array}{l}
+                \dot{z}(t) = \vec{H}(z(t),u[z(t)]),   \\[0.5em]
+                x(0)       = x_0, \quad c(x(t_f)) = 0, \quad p(t_f) = J_c^T(x(t_f)) \lambda,
+            \end{array}
+        \right.
+```
+
+with $`z=(x,p)`$, with $`u[z]`$ the smooth control law in feedback form given by the maximization condition,
+and where $`\vec{H}(z, u) := (\nabla_p H(z,u), -\nabla_x H(z,u))`$.
+    
+>>>
+
+**_Remark._** We can replace $`\dot{z}(t) = \vec{H}(z(t),u[z(t)])`$ by $`\dot{z}(t) = \vec{h}(z(t))`$,
+where $`h(z) = H(z, u[z])`$ is the maximized Hamiltonian.
+
+>>>
+
+**_Shooting function_**
+ 
+To solve the BVP, we define a set of nonlinear equations, the so-called the *shooting equations*. To do so, we introduce the *shooting function* $`S \colon \mathrm{R}^n \times \mathrm{R}^k \to \mathrm{R}^k \times \mathrm{R}^n`$:
+
+```math
+ S(p_0, \lambda) := 
+ \begin{pmatrix}
+     c\left( \pi_x( z(t_f, x_0, p_0) ) \right) \\
+     \pi_p( z(t_f, x_0, p_0) ) - J_c^T \left( \pi_x( z(t_f, x_0, p_0) ) \right) \lambda
+ \end{pmatrix}
+```
+
+where $`\pi_x(x,p) := x`$ is the canonical projection into the state space, $`\pi_p(x,p) := p`$ is the canonical projection into the co-state space, and where $`z(t_f, x_0, p_0)`$ is the solution at time $`t_f`$ of 
+$`\dot{z}(t) = \vec{H}(z(t), u[z(t)]) = \vec{h}(z(t))`$, $`z(0) = (x_0, p_0)`$.
+    
+>>>
+
+>>>
+
+**_Indirect simple shooting method_**
+ 
+Solving the BVP is equivalent to find a zero of the shooting function, that is to solve 
+
+```math
+    S(p_0, \lambda) = 0.
+```
+
+The *indirect simple shooting method* consists in solving this equation.
+
+>>>
+
+In order to solve the shooting equations, we need to compute the control law $u[\cdot]$, the Hamiltonian system $`\vec{H}`$ (or $`\vec{h}`$), we need an [integrator method](https://en.wikipedia.org/wiki/Numerical_methods_for_ordinary_differential_equations) to compute the *exponential map* $\exp(t \vec{H})$ defined by
+```math
+\exp(t \vec{H})(x_0, p_0) := z(t, x_0, p_0),
+```
+and we need a [Newton-like](https://en.wikipedia.org/wiki/Newton%27s_method) solver to solve $`S=0`$.
+
+**_Remark:_** The notation with the exponential mapping is introduced because it is more explicit and permits to show that we need to define the Hamiltonian system and we need to compute the exponential, in order to compute an extremal solution of the PMP.
+
+**_Remark:_**
+It is important to understand that if $`(p_0^*, \lambda^*)`$ is solution of $`S=0`$, then the control $`u(\cdot) := u[z(\cdot, x_0, p_0^*)]`$ is a candidate as a solution of the optimal control problem. It is only a candidate and not a solution of the OCP since the PMP gives necessary conditions of optimality. We would have to go further to check  whether the control is locally or globally optimal.
+
-- 
GitLab