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

Irregular grid via matrices #94

Closed StefanVaylBX2023 closed 9 months ago

StefanVaylBX2023 commented 10 months ago

What could be the starting point with automatic initialization of this matrix with discretization levels, I don't see any way to this without user specified parameters, for example, if one would specify number of regions along axis to be studied, we can at least get the dimensions of the matrix, while having some amount of random points with velocity vectors, won't let us construct this matrix, probably I am missing something, so let me know if you thought of a different approach.,

codecov-commenter commented 10 months ago

Codecov Report

Merging #94 (5b7ba12) into main (4786eb7) will increase coverage by 10.55%. Report is 4 commits behind head on main. The diff coverage is 90.17%.

@@             Coverage Diff             @@
##             main      #94       +/-   ##
===========================================
+ Coverage   73.43%   83.99%   +10.55%     
===========================================
  Files          21       20        -1     
  Lines        1201     1156       -45     
===========================================
+ Hits          882      971       +89     
+ Misses        319      185      -134     
Files Coverage Δ
src/mapping/attractor_mapping.jl 80.95% <ø> (ø)
src/mapping/grouping/cluster_config.jl 66.19% <ø> (ø)
src/mapping/attractor_mapping_recurrences.jl 90.30% <90.17%> (+0.05%) :arrow_up:

... and 2 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

StefanVaylBX2023 commented 9 months ago

Few questions: 1) lines 407-412 of attractors_mapping_recurrences.jl , I forgot to mention during the meeting but I've noticed that sometimes evaluation of velocities may return NaN values, i do remember while testing in general for newton map, precisely point (0,0) was a problem. How should I fix such an issue, currently just assigning random value like 1 ( or i can assign just any value/mean/max/min from computed before if it is not the first computation), which is not good in general case or is there something I dont understand conceptually. 2) Documentation, example and location of functions, where the best to put them from your point of view.

Datseris commented 9 months ago

Documentation, example and location of functions, where the best to put them from your point of view.

It is the same as other PRs. Documentation is first done by adding documentation strings to the new exported functions, and updating the documentation strings of the functions you have altered. Then you add these documentation strings in new @docs blocks in the documetnation markdown files. Where the functions are located is fine as it is now. Examples you put in the examples documentation markdown file, just like you have done with e.g. the minimal fatal shock.

Datseris commented 9 months ago

I forgot to mention during the meeting but I've noticed that sometimes evaluation of velocities may return NaN value

Assign Inf to NaN values. This way NaN values get 0 level of discretization.

p.s.: There is no meaning to do this for discrete-time dynamical systems like the newton map. THere is no such thing as state space velocity for discrete time systems.

StefanVaylBX2023 commented 9 months ago

At the moment: 1) basins_of_attraction issue, you've already noticed the test version problem, but I don't get the way how I can construct grids tuples automatically with its immutable specification, as far as I understand I do need a maximal lvl grid to be passed into basins_of_attraction to get correct results (from what I've been testing before, I may misunderstand this). And as you also noticed I am storing original grid in the structure because it is indeed needed in many parts of the code, while maximal only here. I can either modify generate_ic_on_grid to feed a vector of ranges in it or if you see more optimal solution, please let me know. 2) Docs are not ready yet, I am into this and report together now, will be done quite soon. 3) You can check that example with prays and predators we used before, it actually works quite well, you'll find observable samples in the bottom of irregular_grid.jl test file 4) Two tests seem to be failing, idk if it is on my side or not, rest of AttrViaRec works:

Basin entropy and Fractal test: Test Failed at /home/stefan/.julia/dev/Attractors/test/basins/uncertainty_tests.jl:62
  Expression: 0.4 ≤ Sb ≤ 0.42
   Evaluated: 0.4 ≤ 0.4200399104141245 ≤ 0.42

Basin entropy and Fractal test: Test Failed at /home/stefan/.julia/dev/Attractors/test/basins/uncertainty_tests.jl:63
  Expression: 0.6 ≤ Sbb ≤ 0.61
   Evaluated: 0.6 ≤ 0.5954634397705195 ≤ 0.6
Datseris commented 9 months ago
  1. I don't understand what the question is. I also don't understand where you are referring to. Saying just basins_of_attraction is not specific enough. Please rephrase your question and explain it in more detail.
  2. Ok.
  3. Ok!
  4. Yes, that is unrelated to your PR. We just need to slightly increase the accuracy bounds for these tests.
StefanVaylBX2023 commented 9 months ago

Issue with tests were on my side, small but ridiculous mistake(

Datseris commented 9 months ago

Is this ready to review?

Datseris commented 9 months ago

Tests fail, you are plotting Figure in the test suite, which shuldn't happen.

StefanVaylBX2023 commented 9 months ago

Is this ready to review?

Except for the problem with basins_of_attraction lines 185-193. I need to automatically construct new tuple grid for arbitrary dimension but I don't see the way I can do this in tuple, something in form Tuple(axises_array...) doesn't work.

StefanVaylBX2023 commented 9 months ago

Basin cell index idea test: xg = yg = range(0,5, length = 6), discrete lvls {0,1,2,3} Subdivided_based_grid.xlsx

StefanVaylBX2023 commented 9 months ago

I am failing to build docs at the moment

ERROR: LoadError: type Context has no field version
Stacktrace:
 [1] Context!(ctx::Pkg.Types.Context; kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:version, :io), Tuple{String, Base.TTY}}})
   @ Pkg.Types /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/Types.jl:495
 [2] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:version, :io), Tuple{String, Base.TTY}}})
   @ Pkg.API /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:229
 [3] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:version,), Tuple{String}}})
   @ Pkg.API /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:156
 [4] #add#25
   @ /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:144 [inlined]
 [5] add
   @ /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:144 [inlined]
 [6] #add#24
   @ /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:143 [inlined]
 [7] top-level scope
   @ ~/.julia/dev/Attractors/docs/build_docs_with_style.jl:6
in expression starting at /home/stefan/.julia/dev/Attractors/docs/build_docs_with_style.jl:6
StefanVaylBX2023 commented 9 months ago

I am failing to build docs at the moment

ERROR: LoadError: type Context has no field version
Stacktrace:
 [1] Context!(ctx::Pkg.Types.Context; kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:version, :io), Tuple{String, Base.TTY}}})
   @ Pkg.Types /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/Types.jl:495
 [2] add(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, kwargs::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:version, :io), Tuple{String, Base.TTY}}})
   @ Pkg.API /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:229
 [3] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:version,), Tuple{String}}})
   @ Pkg.API /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:156
 [4] #add#25
   @ /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:144 [inlined]
 [5] add
   @ /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:144 [inlined]
 [6] #add#24
   @ /opt/julia-1.9.2/share/julia/stdlib/v1.9/Pkg/src/API.jl:143 [inlined]
 [7] top-level scope
   @ ~/.julia/dev/Attractors/docs/build_docs_with_style.jl:6
in expression starting at /home/stefan/.julia/dev/Attractors/docs/build_docs_with_style.jl:6

line 6 of build_docs_with_style.jl ig has typo Pkg.add("Documenter"; version = "0.27") -> Pkg.add(name = "Documenter", version = "0.27"), but after this change using DocumenterTools: Themes fails for me.

Probably it is on my side, but before I could compile them, now cannot at all

Datseris commented 9 months ago

No, it isn't on your side. DocumetnerTools does not work with Documenter v1. I've fixed this now by pinning documenter to v0.27. I'll finish the review now.

Datseris commented 9 months ago

Great! I did some QoL (quality of life) changes: I allowed users to create their own subdivision matrix if need be, and I also added some helpful error messages.