Skip to content
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

Store UPOs in a set & test possibly wrong #334

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ChaosTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ include("dimreduction/dyca.jl")
include("stability/fixedpoints.jl")
include("periodicity/period.jl")
include("periodicity/yin.jl")
include("periodicity/custombintree.jl")
include("periodicity/po_datastructure.jl")
include("periodicity/lambdamatrix.jl")
include("periodicity/periodicorbits.jl")
include("periodicity/davidchacklai.jl")
Expand Down
57 changes: 0 additions & 57 deletions src/periodicity/custombintree.jl

This file was deleted.

14 changes: 7 additions & 7 deletions src/periodicity/davidchacklai.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ end


function detect_orbits(
fps::RBTree{VectorWithEpsRadius{T}},
fps::Set{T},
ds::DeterministicIteratedMap,
n::Integer,
seed::AbstractVector{D},
Expand All @@ -174,16 +174,16 @@ function detect_orbits(
end

function detect_orbits(
fps::RBTree{VectorWithEpsRadius{T}},
fps::Set{T},
ds::DeterministicIteratedMap,
n::Integer,
seed::RBTree{VectorWithEpsRadius{T}},
seed::Set{T},
β,
C_matrices;
kwargs...
) where {T}
for C in C_matrices
_detect_orbits!(fps, ds, n, tovector(seed), C, β; kwargs...)
_detect_orbits!(fps, ds, n, collect(seed), C, β; kwargs...)
end
end

Expand All @@ -207,15 +207,15 @@ end
function output(fps, type, n)
output = Vector{Vector{type}}(undef, n)
for i in 1:n # not including periodic orbit n+1 because it may be incomplete
output[i] = tovector(fps[i])
output[i] = collect(fps[i])
end
return output
end

function storage(type, n)
storage = Vector{RBTree{VectorWithEpsRadius{type}}}(undef, n+1)
storage = Vector{Set{type}}(undef, n+1)
for i in 1:n+1
storage[i] = fpcollection(type)
storage[i] = Set{type}()
end
return storage
end
8 changes: 4 additions & 4 deletions src/periodicity/periodicorbits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ function periodicorbits(
end

type = typeof(current_state(ds))
FP = fpcollection(type)
FP = Set{type}()
for λ in λs, inds in indss, sings in singss
Λ = lambdamatrix(λ, inds, sings)
_periodicorbits!(FP, ds, o, ics, Λ, maxiters, disttol, inftol, abstol)
end
return Dataset(tovector(FP))
return Dataset(collect(FP))
end

function periodicorbits(
Expand All @@ -96,10 +96,10 @@ function periodicorbits(
end

type = typeof(current_state(ds))
FP = fpcollection(type)
FP = Set{type}()
Λ = lambdamatrix(0.001, dimension(ds))
_periodicorbits!(FP, ds, o, ics, Λ, maxiters, disttol, inftol, abstol)
return Dataset(tovector(FP))
return Dataset(collect(FP))
end

function _periodicorbits!(FP, ds, o, ics, Λ, maxiter, disttol, inftol, abstol)
Expand Down
12 changes: 12 additions & 0 deletions src/periodicity/po_datastructure.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function storefp!(set, fp, abstol)
previously_detected(set, fp, abstol) ? nothing : push!(set, fp)
end

function previously_detected(set, fp, abstol)
for elem in set
if norm(fp - elem) <= abstol
return true
end
end
return false
end
2 changes: 1 addition & 1 deletion test/periodicity/davidchacklai.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end
sort!(fps[3])
fps[3] = [round.(x, digits=7) for x in fps[3]]
@test length(fps[3]) == 5
@test isapprox(SVector(0.0), fps[1][1]; atol = tol)
@test isapprox(SVector(0.0), fps[3][1]; atol = tol)
@test isapprox(SVector(0.1599288), fps[3][2]; atol = tol)
@test isapprox(SVector(0.5143553), fps[3][3]; atol = tol)
@test isapprox(SVector(0.7387961), fps[3][4]; atol = tol)
Expand Down
Loading