From 26b11cd90a747a3e6df7ae783a85ed4f7c24e384 Mon Sep 17 00:00:00 2001
From: Olivier Cots <olivier.cots@enseeiht.fr>
Date: Tue, 30 Mar 2021 16:51:43 +0200
Subject: [PATCH] update ex3

---
 .../ex3_cor_multiple_shooting_bsb.ipynb       | 13 ++++++---
 .../exercices/ex3_multiple_shooting_bsb.ipynb | 27 ++++++++++---------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/course/corrections/ex3_cor_multiple_shooting_bsb.ipynb b/course/corrections/ex3_cor_multiple_shooting_bsb.ipynb
index 6520695..f947744 100644
--- a/course/corrections/ex3_cor_multiple_shooting_bsb.ipynb
+++ b/course/corrections/ex3_cor_multiple_shooting_bsb.ipynb
@@ -333,7 +333,7 @@
     "\n",
     "**_Question 3:_**\n",
     "    \n",
-    "Complete the code of the shooting function and its derivative with respect to $p_0$ against the vector $dp_0$.\n",
+    "Complete the code of the shooting function.\n",
     "    \n",
     "</div>"
    ]
@@ -355,8 +355,15 @@
     "#    s = 0  ### TO COMPLETE: use the flow f, the parameters t0, x0 and xf_target\n",
     "    xf, _ = f(t0, x0, p0, tf, e)  # We use the flow to get z(tf, x0, p0)\n",
     "    s = xf - xf_target  # x(tf, x0, p0) - xf_target\n",
-    "    return s\n",
-    "\n",
+    "    return s"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
     "def dshoot(p0, dp0, e, tf):\n",
     "#    ds = 0  ### TO COMPLETE\n",
     "    (xf, dxf), _ = f(t0, x0, (p0, dp0), tf, e)\n",
diff --git a/course/exercices/ex3_multiple_shooting_bsb.ipynb b/course/exercices/ex3_multiple_shooting_bsb.ipynb
index 6493ec5..5c51de7 100644
--- a/course/exercices/ex3_multiple_shooting_bsb.ipynb
+++ b/course/exercices/ex3_multiple_shooting_bsb.ipynb
@@ -330,7 +330,7 @@
     "\n",
     "**_Question 3:_**\n",
     "    \n",
-    "Complete the code of the shooting function and its derivative with respect to $p_0$ against the vector $dp_0$.\n",
+    "Complete the code of the shooting function.\n",
     "    \n",
     "</div>"
    ]
@@ -349,10 +349,18 @@
     "#\n",
     "def shoot(p0, e, tf):\n",
     "    s = 0  ### TO COMPLETE: use the flow f, the parameters t0, x0 and xf_target\n",
-    "    return s\n",
-    "\n",
+    "    return s"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
     "def dshoot(p0, dp0, e, tf):\n",
-    "    ds = 0  ### TO COMPLETE\n",
+    "    (xf, dxf), _ = f(t0, x0, (p0, dp0), tf, e)\n",
+    "    ds = dxf\n",
     "    return ds\n",
     "\n",
     "shoot = nt.tools.tensorize(dshoot, tvars=(1,))(shoot)"
@@ -602,22 +610,17 @@
     "#\n",
     "def dhfunplus(t, x, dx, p, dp):\n",
     "    # dh = dh_x dx + dh_p dp\n",
-    "#    hd = 0 ### TO COMPLETE: use uplus\n",
-    "    u  = uplus(t, x, p)\n",
-    "    hd = u*dp - 2.0*x*dx\n",
+    "    hd = 0 ### TO COMPLETE: use uplus\n",
     "    return hd\n",
     "    \n",
     "def d2hfunplus(t, x, dx, d2x, p, dp, d2p):\n",
     "    # d2h = dh_xx dx d2x + dh_xp dp d2x + dh_px dx d2p + dh_pp dp d2p\n",
-    "#    hdd = 0 ### TO COMPLETE\n",
-    "    hdd    = -2.0 * d2x * dx\n",
+    "    hdd = 0 ### TO COMPLETE\n",
     "    return hdd\n",
     "\n",
     "@tools.tensorize(dhfunplus, d2hfunplus, tvars=(2, 3))\n",
     "def hfunplus(t, x, p):\n",
-    "#    h = 0 ### TO COMPLETE: use uplus\n",
-    "    u = uplus(t, x, p)\n",
-    "    h = p*u - x**2\n",
+    "    h = 0 ### TO COMPLETE: use uplus\n",
     "    return h\n",
     "\n",
     "hplus = ocp.Hamiltonian(hfunplus)\n",
-- 
GitLab