Measure protocol#
Protocol defining the interface for diversity measures.
- class phypanda.protocol.DiversityMeasure(*args, **kwargs)#
Bases:
ProtocolProtocol defining the interface for diversity measures.
Notes
Concrete measures implement the operations that the public helpers in
phypanda.basecall on their behalf.- compute_diversity(network: DirectedPhyNetwork, taxa: Set[str], **kwargs: Any) float#
Compute diversity for a fixed taxon set.
- Parameters:
network (DirectedPhyNetwork) – Input phylogenetic network.
taxa (Set[str]) – Selected taxa.
**kwargs (Any) – Measure-specific keyword arguments.
- Returns:
Diversity value.
- Return type:
Examples
>>> # value = pp.compute_diversity(network, {"a", "b"}, measure=pp.all_paths)
- solve_maximization(network: DirectedPhyNetwork, budget: int, costs: Mapping[str, int] | None = None, **kwargs: Any) tuple[float, Set[str]]#
Solve diversity maximization under budget constraints.
- Parameters:
- Returns:
Objective value and selected taxa.
- Return type:
- Raises:
PhyloZooNotImplementedError – If the concrete measure does not support optimization.
Examples
>>> # value, taxa = pp.solve_max_diversity(network, budget=5, measure=pp.all_paths)