Skip to content

Nicholson-Bailey

Hosts and parasitoids in discrete generations.

  • Class: NicholsonBaileySystem
  • Import: from skcomplex.systems.biology.ecology import NicholsonBaileySystem
  • Field: biology/ecology
  • Topics: host-parasitoid, discrete map, oscillation
  • References:
    • Nicholson and Bailey 1935
    • Argun et al. 2021

Use this system

The block imports the class and simulates the system with its default parameters and its tuned run settings.

from skcomplex.systems.biology.ecology import NicholsonBaileySystem

trajectory = NicholsonBaileySystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
hosts 25.0
parasitoids 10.0
k 2.0
a 0.05
c 1.0
solver 'auto'
backend 'auto'

Tags

The system with its default parameters has these capability tags, which solvers and analyses check.

Tag Values
Time discrete
Space none
Laws update
Randomness deterministic
Domains real
Structure fixed

Class

The source of the class shows how it builds its components from its model parameters.

class NicholsonBaileySystem(BaseSystem):
    """Hosts and parasitoids in discrete generations.

    Their equilibrium is unstable to growing oscillations.

    The equilibrium is `H = k ln k / ((k - 1) a c)` and `P = ln k / a`. The system has the populations `hosts` and
    `parasitoids`.

    Args:
        hosts:
            The initial number of hosts.

        parasitoids:
            The initial number of parasitoids.

        k:
            The reproductive rate of the hosts.

        a:
            The searching efficiency of the parasitoids.

        c:
            The number of viable eggs a parasitoid lays in a host.

        label:
            The label of the system, which names it when it is nested in another one.

        solver:
            The solver of the problem, or `'auto'` for the one the system chooses.

        backend:
            The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.

    Examples:
        >>> from skcomplex.systems.biology.ecology import NicholsonBaileySystem
        >>> NicholsonBaileySystem(k=3.0).prepare().system_.interactions[0].k
        3.0
    """

    field = 'biology/ecology'
    topics = ('host-parasitoid', 'discrete map', 'oscillation')
    references = ('Nicholson and Bailey 1935', 'Argun et al. 2021')
    until = 30
    dt = 1

    def __init__(
        self,
        hosts: float = 25.0,
        parasitoids: float = 10.0,
        *,
        k: float = 2.0,
        a: float = 0.05,
        c: float = 1.0,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.hosts = hosts
        self.parasitoids = parasitoids
        self.k = k
        self.a = a
        self.c = c

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of hosts and parasitoids in discrete generations.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.
        """
        super()._prepare(context)
        self.system_ = System(
            self.label,
            elements=[PopulationElement('hosts', x=self.hosts), PopulationElement('parasitoids', x=self.parasitoids)],
            interactions=[
                ParasitismInteraction(
                    'parasitism',
                    host='hosts',
                    parasitoid='parasitoids',
                    k=self.k,
                    a=self.a,
                    c=self.c,
                ),
            ],
        )

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

Interactions:

  • ParasitismInteraction, from Interaction
class PopulationElement(CompartmentElement):
    """Population of one species, a compartment whose state `x` holds its size.

    Args:
        label:
            The label of the population.

        x:
            The initial size.

    Examples:
        >>> from skcomplex.systems.biology.common.populations import PopulationElement
        >>> PopulationElement('rabbits', x=40).x
        40
    """

    def __init__(
        self,
        label: str,
        *,
        x: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
    ) -> None:
        super().__init__(label, x=x)

class ParasitismInteraction(Interaction):
    """Nicholson-Bailey parasitism of hosts by parasitoids in discrete generations.

    Parasitoids search at random, so a host escapes with probability `exp(-a P)`, giving `H' = k H exp(-a P)` and
    `P' = c H (1 - exp(-a P))`.

    Args:
        label:
            The label of the interaction.

        host:
            The path of the host population `H`.

        parasitoid:
            The path of the parasitoid population `P`.

        k:
            The reproductive rate of the hosts.

        a:
            The searching efficiency of the parasitoids.

        c:
            The number of viable eggs a parasitoid lays in a host.

    Examples:
        >>> from skcomplex.systems.biology.ecology import ParasitismInteraction
        >>> ParasitismInteraction('parasitism', host='moths', parasitoid='wasps', k=2.0).k
        2.0
    """

    law_classes = (UpdateLaw,)

    def __init__(
        self,
        label: str,
        *,
        host: Role,
        parasitoid: Role,
        k: Annotated[float, RealSet.open(0, oo)] = 2.0,
        a: Annotated[float, RealSet.open(0, oo)] = 0.05,
        c: Annotated[float, RealSet.open(0, oo)] = 1.0,
    ) -> None:
        super().__init__(label)
        self.host = host
        self.parasitoid = parasitoid
        self.k = k
        self.a = a
        self.c = c

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the next generations `k H exp(-a P)` and `c H (1 - exp(-a P))`.

        Args:
            context:
                The namespace of the bound elements, the time `t`, and the parameters.
        """
        super()._prepare(context)
        s = context
        hosts, parasitoids = s.host.x, s.parasitoid.x
        escape = exp(-s.a * parasitoids)
        self.laws_ = [UpdateLaw(hosts, s.k * hosts * escape), UpdateLaw(parasitoids, s.c * hosts * (1 - escape))]

Equations

The equations are those that symbolic returns for the system with its default parameters.

hosts.x: x_hosts(t + 1) == k_parasitism*e^(-a_parasitism*x_parasitoids(t))*x_hosts(t)
parasitoids.x: x_parasitoids(t + 1) == -c_parasitism*(e^(-a_parasitism*x_parasitoids(t)) - 1)*x_hosts(t)