-
Notifications
You must be signed in to change notification settings - Fork 35
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
Improve UPO storage in periodicorbits.jl
#325
Conversation
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.
This file has confused me a bit... So Datastructures provides a binary tree. What is the DummyStructure
supposed to do? WHy do we need this?
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.
Typically binary tree will store value to the left child if it is less than root and to the right side if it is more. I want to store value to the left only if it at least DymmyStructure.eps
away from the root. Hence duplicate periodic points that are close closer than DummyStructure.eps
won't be stored. DummyStructure is needed for ==
and <
overload so that it can be used in the binary tree from Datastructures. Perhaps there is a more elegant way to do it. I agree that it is confusing.
src/periodicity/periodicorbits.jl
Outdated
roundtol::Int = 4 | ||
spacetol::Real = 1e-8, |
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.
Right, notice that this is a breaking change right now. You have removed a keyword, so users that were using this code will be getting an error. They should be getting a warning instead.
Do roundtol = nothing
and inside the function have a warning code:
if !isnothing(roundtol)
warn("`roundtol` keyword has been removed in favor of `spacetol`")
end
by the way, why the name spacetol
? This is an absolute tolerance right? perhaps abstol
is better?
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 are right. I added warning. abstol
would stand for absolute tolerance. I renamed spacetol
as absintol
for absolute intolerance, which is what it actually is: dropping results in absintol
neighborhood.
src/periodicity/custombintree.jl
Outdated
|
||
struct DummyStructure{T} |
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.
Okay, please add comments here explaining why this exists (copy paste the explanation you gave in the GitHub discussion)
src/periodicity/periodicorbits.jl
Outdated
*if* they are not already contained in `FP`. | ||
This is done so that `FP` doesn't contain duplicate fixed points (notice | ||
that this has nothing to do with `disttol`). | ||
* `absintol = 1e-8`: A detected fixed point isn't stored if it is in `absintol` |
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.
Alright, then rename this to abstol
. it is the same as abstol
in the isapprox
function so it will make it easier to approach for a user.
src/periodicity/periodicorbits.jl
Outdated
|
||
FP = typeof(current_state(ds))[] | ||
type = typeof(current_state(ds)) | ||
FP = RBTree{DummyStructure{type}}() |
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.
Here in the FP write a couple of lines of code why you use the tree. The same explanation you gave to me.
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.
All in all good, I have some standind comments for adding comments in the source code to increase clarity for the non obvious additions.
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.
Perfect. Please rename DummyStructure
to NumberWithEpsRadius
, which is a much more indicative name of the data structure. Then I'll merge. Would be nice to add a changelog entry and bumb the minor version in project toml. We will release this along with your other PR.
I renamed it as VectorWithEpsRadius since it's used with SVectors. Should the changelog include info about both PRs? I will make another PR this week adding the Davidchack-Lai algorithm. It will internally also make use of VectorWithEpsRadius. Perhaps all three could be released together. |
we can add the changelog in your 3rd PR, it's fine. |
I noticed that while using periodicorbits algorithm with parameter roundtol that is high (eg. 8 ), it detects many duplicate UPOs.
MVE:
Output:
My proposed change solves this:
Output:
I have implemented
FP
as a binary tree. This way, new fixed points are inserted intoFP
only if they arespacetol
away from the remaining fixed points inFP
. Thus duplicates are avoided for a good choice ofspacetol
.Additionally, binary tree removes the need for linear search through
FP
even though this doesn't seem to be a bottleneck.Let me know if there is something to fix. This is my first PR :).