JuliaDynamics / ChaosTools.jl

Tools for the exploration of chaos and nonlinear dynamics
https://juliadynamics.github.io/DynamicalSystemsDocs.jl/chaostools/stable/
MIT License
187 stars 35 forks source link

Fix nearest neighbors search of attractors #239

Closed awage closed 2 years ago

awage commented 2 years ago

Fix to reduce the number of allocations in the second mode of operation in basins_of_attraction.

Two new variables have been added to BasinsInfo.

New default value ε = 1e-5

Closes #238

Datseris commented 2 years ago

Why so small ε though?

awage commented 2 years ago

Nothing wrong with 1e-3. I was just annoyed by this behavior.

I solved the problem. There was a break statement in the loop once the attractor was found. The correct way to do is to return the label of the basin. For some reason the program was doing something else.

closes issue #238

Performances are smashing, for a 2000x2000 grid:

@time basins, att2 = basins_of_attraction(grid, ds; attractors = att, show_progress = true )
 17.078572 seconds (19.98 M allocations: 862.074 MiB, 1.05% gc time)

On my old laptop.

Datseris commented 2 years ago

I always wondered why that break was there instead of return and thought we do some kind of cleanup of the indexing, but guess it was just a mistake xD will merge and tag once tests pass