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

Checking that SA trees use the right operators is problematic #807

Open
laduplessis opened this issue Sep 7, 2018 · 4 comments
Open

Checking that SA trees use the right operators is problematic #807

laduplessis opened this issue Sep 7, 2018 · 4 comments

Comments

@laduplessis
Copy link
Contributor

Current state:

The tree class in beast2 core implements sampled ancestor trees, but the operators for adding/removing sampled ancestors in a tree are part of the sampled-ancestors package. By default a tree will be initalised without sampled ancestors and the regular tree operators will be valid.

Problem:

If a package implements a tree initialisation method that introduces sampled ancestors or implements a treeprior that assumes a sampled ancestor tree, it is left to the package designer to implement a test that sampled ancestor tree operators are being used instead of regular tree operators. This leads to code duplication since the same check needs to be implemented in multiple packages and scenarios.

Additionally, when multiple trees are being used there is a danger that the package will throw an error for operators on the wrong tree. Furthermore, it ignores the possibility of implementing new operators that either extend blacklisted operators, but can handle SA trees, or new operators that are not blacklisted but cannot handle SA trees.

Proposed solutions

Solution 1:

Add a boolean attribute hasSampledAncestors to the Tree class. In initAndValidate() the Tree class should then check that the correct sampled ancestors tree operators are being used instead of the regular tree operators. This places the check in a central location, but won't solve any issues with new operators.

Solution 2:

Add method canHandleSampledAncestors() to the TreeOperator abstract class (that returns false by default). Add a boolean attribute hasSampledAncestors to the Tree class. Then add initAndValidate() method to TreeOperator that throws an error if the tree has sampled ancestors, but the operator cannot handle them.

This will require adding super.initAndValidate() to all existing TreeOperators. (Since TreeOperator has no initAndValidate() method, most TreeOperators have a blank initAndValidate() method as well).

Solution 3:

Let SATree inherit from Tree. Operators, tree initialisers and tree priors now have to use the right type of tree. (I think this was actually the original behaviour with the original ZeroBranchSATrees wasn't it?)

@alexeid
Copy link
Member

alexeid commented Sep 11, 2018 via email

@tgvaughan
Copy link
Contributor

Great idea. Would it be possible to make the set of tree spaces extensible? Perhaps by using a TreeSpace class rather than an enum?

@alexeid
Copy link
Member

alexeid commented Sep 11, 2018 via email

@rbouckaert
Copy link
Member

Yes, adding a class to identify TreeSpaces makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants