All-paths (MAPD) measure#
All-paths diversity measure implementation.
- class phypanda.measure.all_paths.AllPathsDiversity#
Bases:
objectAll-paths diversity measure.
Examples
>>> import phypanda as pp >>> # value = pp.all_paths.compute_diversity(network, {"a", "b"})
- compute_diversity(network: DirectedPhyNetwork, taxa: Set[str], **kwargs: Any) float#
Compute all-paths diversity for a taxon set.
- Parameters:
network (DirectedPhyNetwork) – Input phylogenetic network.
taxa (Set[str]) – Selected taxa.
**kwargs (Any) – Unused measure-specific options.
- Returns:
All-paths diversity value.
- Return type:
Examples
>>> import phypanda as pp >>> # value = pp.all_paths.compute_diversity(network, {"a", "b"})
- solve_maximization(network: DirectedPhyNetwork, budget: int, costs: Mapping[str, int] | None = None, algorithm: str = 'nsw_fpt_budget', tree_extension: TreeExtension | None = None, **kwargs: Any) tuple[float, Set[str]]#
Solve all-paths diversity maximization under budget constraints.
- Parameters:
network (DirectedPhyNetwork) – Input network.
budget (int) – Integer budget.
algorithm (str, optional) – Solver backend name. Default is
"nsw_fpt_budget".tree_extension (TreeExtension | None, optional) – Optional precomputed tree extension for compatible solvers. If
None, the solver computes one usingscanwidthdefaults.**kwargs (Any) – Solver-specific options forwarded to the selected backend (for example
numba=Falsewithalgorithm="nsw_fpt_budget"to disable Numba in the child-merge DP).
- Returns:
Objective value and selected taxa.
- Return type:
Examples
>>> import phypanda as pp >>> # value, taxa = pp.all_paths.solve_maximization(network, budget=5) >>> # value2, taxa2 = pp.all_paths.solve_maximization( ... # network, budget=5, algorithm="esw_fpt", tree_extension=None ... # )