All-paths (MAPD) measure#

All-paths diversity measure implementation.

class phypanda.measure.all_paths.AllPathsDiversity#

Bases: object

All-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:

float

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.

  • costs (Mapping[str, int] | None, optional) – Taxon costs.

  • 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 using scanwidth defaults.

  • **kwargs (Any) – Solver-specific options forwarded to the selected backend (for example numba=False with algorithm="nsw_fpt_budget" to disable Numba in the child-merge DP).

Returns:

Objective value and selected taxa.

Return type:

tuple[float, Set[str]]

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
... # )