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

Make postorder and preorder functions perform a single memoized pass of the graph #117

Open
Boarders opened this issue Jan 15, 2019 · 0 comments

Comments

@Boarders
Copy link
Collaborator

The candidate network edges function makes use of vectors written in the form of openly recursive 'memoized producers'. That is, they are given as types defined as follows (in Data.Vector.Utility):
newtype DVector a = DVector {getDVector :: (Int -> a) -> Int -> a}

From a DVector one can then produce a memoized vector. We should factor out the memoization used in postorderSequence' (defined in Bio.Graph.PhylogeneticDAG.Postorder) and preorderSequence (defined in Bio.Graph.PhylogeneticDAG.Preorder) to make use of this new type. For any cached data that these functions make use of we should write the functions that collect this data (largely defined in Bio.Graph.ReferenceDAG.Internal) in the form of a DVector which is to be consumed by the postorder or preorder.

With the DVector type it may be worth thinking about adding custom rules as in this toy example: https://gist.github.com/Boarders/10d5697fd32dc21b0fe0219cea239f80
It is worth researching how best to write these rules to allow for further fusion optimisation if this is relevant and otherwise simply a way to not produce an intermediate data structure.

@Boarders Boarders self-assigned this Jan 15, 2019
@Boarders Boarders added this to the Version 0.3.0 milestone Jan 15, 2019
@Boarders Boarders changed the title Make postorder and preorder functions perform a single memoized pass of the graph. Make postorder and preorder functions perform a single memoized pass of the graph Jan 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants