-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimized shooting method #3
Conversation
cc also @rveltz : if you know this algorithm, let's make sure that we aren't duplicating effort. If something like this is in BFKit, or parts of the code have been tried in BFKit, let's reuse the knowledge. |
Everything works as we discussed today. |
perfect! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can optimize the code. If you don't do it until our next meeting, then I will show you how to use profiling, and we can see the big difference in profiling before and after the optimizations.
src/algorithms/optimized_shooting.jl
Outdated
OptimizedShooting(; kwargs...) | ||
|
||
A shooting method [Dednam2014](@cite) combined with Levenberg-Marquardt optimization | ||
to find periodic orbits of continuous systems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to find periodic orbits of continuous systems. | |
to find periodic orbits of continuous time systems. |
src/algorithms/optimized_shooting.jl
Outdated
R1 = compute_residual(ds, u0, T*alg.Δt, alg.n, 0) | ||
R2 = compute_residual(ds, u0, T*alg.Δt, alg.n, T) | ||
err = R2 .- R1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, isn't this here too ineficient? Every time you call the cost function you are creating R1, R2, err
. Does the optimize
function run in parallel? If not, we can re-use existing vectors R1, R2, err
instead of creating them all the time. For example, you can make costfunc
be a type and use function-like objects. Something like
struct CostFunc
R1::Vector
R2::Vector
err:Vector
end
function (cf::CostFunc)(v, ds, alg)
(; R1, R2, err) = cf
# same code as in your function
end
src/algorithms/optimized_shooting.jl
Outdated
return err | ||
end | ||
|
||
function compute_residual(ds, u0, Δt, n, t0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same story. You need to make this compute_residual!(R, ...)
that uses an existing array R
instead of creating a new one every time.
I tried to make it faster but with no success. Even though I reduced allocations almost in half, the runtime wasn't faster. Let's try profiling together next time then! |
The |
I suddenly can't build the docs. I attach the stacktrace.txt here. It originates in |
docbuild problem comes from Documenter.jl. We can't resolve it :( :( :( cc @Tortar , I searched throught the JuliaDynamics/doctheme repo, we don't have |
I implemented recent paper that searches for UPOs via optimization (link). The paper also includes python implementation in the appendix.
My implementation has a few potential problems, that should be addressed:
ds
in every iterationPeriodicOrbits.jl/src/algorithms/optimized_shooting.jl
Lines 94 to 95 in 507234f
RKO65
PeriodicOrbits.jl/src/algorithms/optimized_shooting.jl
Lines 50 to 51 in 507234f
DynamicalSystemsBase.jl
hasOrdinaryDiffEq.jl
as a dependency but the docs here say that to access the solvers, it has to be imported by the user. I wanted to change the default solver so I added theOrdinaryDiffEq.jl
as a dependency again. I don't know if this is optimal. Is there a way to access the various solvers internally throughDynamicalSystemsBase.jl
?