diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 19d3226..b37e57b 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-06T15:13:16","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-07T08:13:26","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/dev/application-surface-revolution-f7c1f6a8.svg b/dev/application-surface-revolution-3efdb358.svg similarity index 84% rename from dev/application-surface-revolution-f7c1f6a8.svg rename to dev/application-surface-revolution-3efdb358.svg index 28e22d4..bdfa994 100644 --- a/dev/application-surface-revolution-f7c1f6a8.svg +++ b/dev/application-surface-revolution-3efdb358.svg @@ -1,149 +1,149 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/application-surface-revolution-2e3f5803.svg b/dev/application-surface-revolution-5d163f27.svg similarity index 83% rename from dev/application-surface-revolution-2e3f5803.svg rename to dev/application-surface-revolution-5d163f27.svg index f0f1ef2..21b1258 100644 --- a/dev/application-surface-revolution-2e3f5803.svg +++ b/dev/application-surface-revolution-5d163f27.svg @@ -1,71 +1,71 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/application-surface-revolution-ac4764e9.svg b/dev/application-surface-revolution-aaad215f.svg similarity index 83% rename from dev/application-surface-revolution-ac4764e9.svg rename to dev/application-surface-revolution-aaad215f.svg index e100b8d..f83ee51 100644 --- a/dev/application-surface-revolution-ac4764e9.svg +++ b/dev/application-surface-revolution-aaad215f.svg @@ -1,70 +1,70 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/application-surface-revolution-76b50bed.svg b/dev/application-surface-revolution-b196740a.svg similarity index 94% rename from dev/application-surface-revolution-76b50bed.svg rename to dev/application-surface-revolution-b196740a.svg index a21d49d..40a9fb5 100644 --- a/dev/application-surface-revolution-76b50bed.svg +++ b/dev/application-surface-revolution-b196740a.svg @@ -1,210 +1,210 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/application-surface-revolution-36c4d774.svg b/dev/application-surface-revolution-dd9b2ed9.svg similarity index 91% rename from dev/application-surface-revolution-36c4d774.svg rename to dev/application-surface-revolution-dd9b2ed9.svg index 5f05e63..6e69892 100644 --- a/dev/application-surface-revolution-36c4d774.svg +++ b/dev/application-surface-revolution-dd9b2ed9.svg @@ -1,95 +1,95 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/application-surface-revolution.html b/dev/application-surface-revolution.html index 7053bea..133c9c4 100644 --- a/dev/application-surface-revolution.html +++ b/dev/application-surface-revolution.html @@ -23,7 +23,34 @@ u(x, p) = sign(x) * p / √(x^2-p^2) -ocp_flow = Flow(ocp, u; reltol=1e-10, abstol=1e-10)

Let us plot some extremals, solutions of this flow. The initial condition $x_0$ is fixed while we compute some extremals for different values of initial covector $p_0$. We compute some specific initial covectors for a nice plot.

+ocp_flow = Flow(ocp, u; reltol=1e-10, abstol=1e-10)
WARNING: Method definition default_nlsolve(Nothing, Base.Val{true}, Any, SciMLBase.NonlinearProblem{uType, isinplace, P, F, K, PT} where PT where K where F where P where isinplace where uType) in module OrdinaryDiffEqCore at /home/runner/.julia/packages/OrdinaryDiffEqCore/rRqPh/src/initialize_dae.jl:123 overwritten in module OrdinaryDiffEqNonlinearSolve at /home/runner/.julia/packages/OrdinaryDiffEqNonlinearSolve/0gbhD/src/initialize_dae.jl:1.
+ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.
+WARNING: Method definition default_nlsolve(Nothing, Base.Val{true}, Any, SciMLBase.NonlinearProblem{uType, isinplace, P, F, K, PT} where PT where K where F where P where isinplace where uType) in module OrdinaryDiffEqCore at /home/runner/.julia/packages/OrdinaryDiffEqCore/rRqPh/src/initialize_dae.jl:123 overwritten in module OrdinaryDiffEqNonlinearSolve at /home/runner/.julia/packages/OrdinaryDiffEqNonlinearSolve/0gbhD/src/initialize_dae.jl:1.
+ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.
+┌ Warning: Module OrdinaryDiffEqNonlinearSolve with build ID ffffffff-ffff-ffff-0000-008ddbad0360 is missing from the cache.
+│ This may mean OrdinaryDiffEqNonlinearSolve [127b3ac7-2247-4354-8eb6-78cf4e7c58e8] does not support precompilation but is imported by a module that does.
+└ @ Base loading.jl:1948
+┌ Warning: Module OrdinaryDiffEqNonlinearSolve with build ID ffffffff-ffff-ffff-0000-008ddbad0360 is missing from the cache.
+│ This may mean OrdinaryDiffEqNonlinearSolve [127b3ac7-2247-4354-8eb6-78cf4e7c58e8] does not support precompilation but is imported by a module that does.
+└ @ Base loading.jl:1948
+┌ Warning: Module OrdinaryDiffEqSDIRK with build ID ffffffff-ffff-ffff-0000-008f70ed8c78 is missing from the cache.
+│ This may mean OrdinaryDiffEqSDIRK [2d112036-d095-4a1e-ab9a-08536f3ecdbf] does not support precompilation but is imported by a module that does.
+└ @ Base loading.jl:1948
+┌ Warning: Module OrdinaryDiffEqBDF with build ID ffffffff-ffff-ffff-0000-008ff8fdd020 is missing from the cache.
+│ This may mean OrdinaryDiffEqBDF [6ad6398a-0878-4a85-9266-38940aa047c8] does not support precompilation but is imported by a module that does.
+└ @ Base loading.jl:1948
+┌ Warning: Module OrdinaryDiffEqNonlinearSolve with build ID ffffffff-ffff-ffff-0000-008ddbad0360 is missing from the cache.
+│ This may mean OrdinaryDiffEqNonlinearSolve [127b3ac7-2247-4354-8eb6-78cf4e7c58e8] does not support precompilation but is imported by a module that does.
+└ @ Base loading.jl:1948
+┌ Warning: Module OrdinaryDiffEqNonlinearSolve with build ID ffffffff-ffff-ffff-0000-008ddbad0360 is missing from the cache.
+│ This may mean OrdinaryDiffEqNonlinearSolve [127b3ac7-2247-4354-8eb6-78cf4e7c58e8] does not support precompilation but is imported by a module that does.
+└ @ Base loading.jl:1948
+┌ Warning: Module OrdinaryDiffEqNonlinearSolve with build ID ffffffff-ffff-ffff-0000-008ddbad0360 is missing from the cache.
+│ This may mean OrdinaryDiffEqNonlinearSolve [127b3ac7-2247-4354-8eb6-78cf4e7c58e8] does not support precompilation but is imported by a module that does.
+└ @ Base loading.jl:1948
+┌ Warning: Module OrdinaryDiffEq with build ID ffffffff-ffff-ffff-0000-008cb1f2f77f is missing from the cache.
+│ This may mean OrdinaryDiffEq [1dea7af3-3e70-54e6-95c3-0bf5283fa5ed] does not support precompilation but is imported by a module that does.
+└ @ Base loading.jl:1948

Let us plot some extremals, solutions of this flow. The initial condition $x_0$ is fixed while we compute some extremals for different values of initial covector $p_0$. We compute some specific initial covectors for a nice plot.

Computation of the initial covectors @@ -125,7 +152,7 @@ plot!(plt_u; xlabel="t", ylabel="u(t,p₀)", legend=false, ylims=(-2.5, 5)) plot!(plt_phase; xlabel="x(t,p₀)", ylabel="p(t,p₀)", legend=false, xlims=(0, 2), ylims=(-1, 2)) -plot(plt_x, plt_p, plt_u, plt_phase; layout=(2, 2), size=(800, 600))Example block output

Here, the shooting equation given by

\[ S({p₀}) = \pi(z(t_f,x_0,{p₀})) - x_f = 0,\]

with $\pi(x, p) = x$, has two solutions: $p₀ = -0.9851$ and $p₀ = 0.5126$.

π((x, p)) = x
+plot(plt_x, plt_p, plt_u, plt_phase; layout=(2, 2), size=(800, 600))
Example block output

Here, the shooting equation given by

\[ S({p₀}) = \pi(z(t_f,x_0,{p₀})) - x_f = 0,\]

with $\pi(x, p) = x$, has two solutions: $p₀ = -0.9851$ and $p₀ = 0.5126$.

π((x, p)) = x
 
 # Shooting function
 S(p0) = (π ∘ ocp_flow)(t0, x0, p0, tf) - xf
@@ -169,7 +196,7 @@
 plot!(plt2_u; xlabel="t", ylabel="u(t,p₀)", legend=false, ylims=(-6, 5))
 plot!(plt2_phase; xlabel="x(t,p₀)", ylabel="p(t,p₀)", legend=false, xlims=(0, 2.5), ylims=(-1, 5))
 
-plot(plt2_x, plt2_p, plt2_u, plt2_phase; layout=(2, 2), size=(800, 600))
Example block output

Now, we can compute the conjugate points along the two extremals. We have to compute the flow $\delta z(t, p₀)$ of the Jacobi equation with the initial condition $\delta z(0) = (0, 1)$. This is given solving

\[ \delta z(t, p₀) = \dfrac{\partial}{\partial p₀}z(t, p₀).\]

Note that to compute the conjugate points, we only need the first component:

\[ \delta z(t, p₀)_1.\]

using ForwardDiff
+plot(plt2_x, plt2_p, plt2_u, plt2_phase; layout=(2, 2), size=(800, 600))
Example block output

Now, we can compute the conjugate points along the two extremals. We have to compute the flow $\delta z(t, p₀)$ of the Jacobi equation with the initial condition $\delta z(0) = (0, 1)$. This is given solving

\[ \delta z(t, p₀) = \dfrac{\partial}{\partial p₀}z(t, p₀).\]

Note that to compute the conjugate points, we only need the first component:

\[ \delta z(t, p₀)_1.\]

using ForwardDiff
 
 function jacobi_flow(t, p0)
     x(t, p0) = (π ∘ ocp_flow)(t0, x0, p0, t)
@@ -198,11 +225,11 @@
 
 #
 plt_conj = plot(plt_conj1, plt_conj2;
-    layout=(1, 2), size=(800, 300), leftmargin=25px, bottommargin=15px)
Example block output

We compute the first conjugate point along the first extremal and add it to the plot.

tau0 = Roots.find_zero(tau -> jacobi_flow(tau, sol1_p0), (0.4, 0.6))
+    layout=(1, 2), size=(800, 300), leftmargin=25px, bottommargin=15px)
Example block output

We compute the first conjugate point along the first extremal and add it to the plot.

tau0 = Roots.find_zero(tau -> jacobi_flow(tau, sol1_p0), (0.4, 0.6))
 
 println("For p0 = ", sol1_p0, " tau_0 = ", tau0)
 
-plot!(plt_conj[1], [tau0], [jacobi_flow(tau0, sol1_p0)]; seriestype=:scatter)
Example block output

To conclude on this example, we compute the conjugate locus by using a path following algorithm. Define $F(\tau,p₀) = \delta x(\tau,p₀)$ and suppose that the partial derivative $\partial_\tau F(\tau,p₀)$ is invertible, then, by the implicit function theorem the conjugate time is a function of $p₀$. So, since here $p₀\in\R$, we can compute them by solving the initial value problem for $p₀ \in [\alpha, \beta]$:

\[ \dot{\tau}(p₀) = -\dfrac{\partial F}{\partial \tau}(\tau(p₀),p₀)^{-1}\, +plot!(plt_conj[1], [tau0], [jacobi_flow(tau0, sol1_p0)]; seriestype=:scatter)Example block output

To conclude on this example, we compute the conjugate locus by using a path following algorithm. Define $F(\tau,p₀) = \delta x(\tau,p₀)$ and suppose that the partial derivative $\partial_\tau F(\tau,p₀)$ is invertible, then, by the implicit function theorem the conjugate time is a function of $p₀$. So, since here $p₀\in\R$, we can compute them by solving the initial value problem for $p₀ \in [\alpha, \beta]$:

\[ \dot{\tau}(p₀) = -\dfrac{\partial F}{\partial \tau}(\tau(p₀),p₀)^{-1}\, \dfrac{\partial F}{\partial p₀}(\tau(p₀),p₀), \quad \tau(\alpha) = \tau_0.\]

For the numerical experiment, we set $\alpha = -0.9995$, $\beta = -0.5$.

function conjugate_times_rhs_path(tau, p0)
     dF = ForwardDiff.gradient(y -> jacobi_flow(y...), [tau, p0])
@@ -236,4 +263,4 @@
 
 #
 plot(plt_x, plt_conj_times;
-    layout=(1,2), legend=false, size=(800,300), leftmargin=25px, bottommargin=15px)
Example block output
  • 1H. Schättler & U. Ledzewicz, Geometric optimal control: theory, methods and examples, vol~38 of Interdisciplinary applied mathematics, Springer Science & Business Media, New York (2012), xiv+640.
  • 2D. Liberzon, Calculus ov Variations and Optimal Control Theory, Princeton University Press (2012).
+ layout=(1,2), legend=false, size=(800,300), leftmargin=25px, bottommargin=15px)Example block output
diff --git a/dev/index.html b/dev/index.html index f5f8be7..10de764 100644 --- a/dev/index.html +++ b/dev/index.html @@ -20,4 +20,4 @@ [1dea7af3] OrdinaryDiffEq v6.89.0 [91a5bcdd] Plots v1.40.8 [f2b01f46] Roots v2.1.8 - [fd094767] Suppressor v0.2.8 + [fd094767] Suppressor v0.2.8