JuliaDynamics / Attractors.jl

Find attractors of dynamical systems, their basins, and continue them across parameters. Study global stability (a.k.a. non-local, or resilience). Also tipping points functionality.
MIT License
27 stars 5 forks source link

Wada basins detection with the merging algorithm #124

Closed awage closed 2 months ago

awage commented 2 months ago

This is an implementation of the merging algorithm to detect Wada basins. EDIT: only possible in 2D

It is fast and simple to understand. The distance between boundaries is computed using the distance transform of a binary matrix. See this thread:

https://cs.stackexchange.com/questions/117989/hausdorff-distance-between-two-binary-images-according-to-distance-maps

The boundaries can also be computed using this distance matrix so the code is minimal and quite fast (a few ms for 1000x1000 basins matrix)

A. Daza, Alexandre Wagemakers and Miguel A.F. Sanjuán. Ascertaining when a basin is Wada: The merging method. Scientific Reports 8, 9954, 2018.

The basic idea of the algorithm is to compute all boundaries between a basin and the other merged basins. If all boundaries are within some distance r in pixels then we judge that the basins are Wada: there is a unique boundary.

The Doc still needs improvement and the haussdorff_distance is optional. Tests are based on an artificial basins matrix.

Datseris commented 2 months ago

@awage have you checked where the test failure is coming from?

awage commented 2 months ago

I think the problem comes from the docs. All tests are passing locally but there is an error when I try to build the docs.

 Error: no docs found for 'reinit!(::DynamicalSystem, args...; kwargs...)' in `@docs` block in src/dynsysref.md:32-36
│ ```@docs
│ step!(::DynamicalSystem, args...; kwargs...)
│ reinit!(::DynamicalSystem, args...; kwargs...)
│ set_parameter!
│ ```
awage commented 2 months ago

And also:

ERROR: LoadError: `makedocs` encountered an error [:docs_block] -- terminating build before rendering.
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] runner(::Type{Documenter.Builder.RenderDocument}, doc::Documenter.Document)
    @ Documenter ~/.julia/packages/Documenter/CJeWX/src/builder_pipeline.jl:253
  [3] dispatch(::Type{Documenter.Builder.DocumentPipeline}, x::Documenter.Document)
    @ Documenter.Selectors ~/.julia/packages/Documenter/CJeWX/src/utilities/Selectors.jl:170
  [4] #86
    @ ~/.julia/packages/Documenter/CJeWX/src/makedocs.jl:248 [inlined]
  [5] withenv(::Documenter.var"#86#88"{Documenter.Document}, ::Pair{String, Nothing}, ::Vararg{Pair{String, Nothing}})
    @ Base ./env.jl:257
  [6] #85
    @ ~/.julia/packages/Documenter/CJeWX/src/makedocs.jl:247 [inlined]
  [7] cd(f::Documenter.var"#85#87"{Documenter.Document}, dir::String)
    @ Base.Filesystem ./file.jl:112
  [8] makedocs(; debug::Bool, format::Documenter.HTMLWriter.HTML, kwargs::@Kwargs{…})
    @ Documenter ~/.julia/packages/Documenter/CJeWX/src/makedocs.jl:247
  [9] makedocs
    @ ~/.julia/packages/Documenter/CJeWX/src/makedocs.jl:241 [inlined]
 [10] build_docs_with_style(::Vector{…}, ::Module, ::Vararg{…}; bib::CitationBibliography, authors::String, draft::Bool, htmlkw::@NamedTuple{}, kwargs::@Kwargs{…})
    @ Main ~/urjc/investigacion/proyecto_basins_computing/Attractors.jl/docs/build_docs_with_style.jl:78
 [11] top-level scope
    @ ~/urjc/investigacion/proyecto_basins_computing/Attractors.jl/docs/make.jl:31
 [12] include(fname::String)
    @ Base.MainInclude ./client.jl:489
 [13] top-level scope
    @ REPL[2]:1