aegis_sim.submodels.predation

 1import numpy as np
 2
 3
 4class Predation:
 5    """
 6    GUI
 7    Predation is an optional source of mortality, useful for modeling death with prey-predator dynamics.
 8    [[PREDATION_RATE]] specifies how deadly the predators are; thus if set to 0, no predation deaths will occur.
 9    Apart from [[PREDATION_RATE]], the probability that an individual actually gets predated depends also on the number of predators; the response curve is logistic.
10    The predator population grows according to the logistic Verhulst growth model, whose slope is parameterized by [[PREDATOR_GROWTH]].
11    All individuals are equally susceptible to predation; age and genetics have no impact.
12    """
13
14    def __init__(self, PREDATOR_GROWTH, PREDATION_RATE):
15        self.N = 1
16        self.PREDATOR_GROWTH = PREDATOR_GROWTH
17        self.PREDATION_RATE = PREDATION_RATE
18
19    def __call__(self, prey_count):
20
21        # TODO Add attrition penalty for when there are no living prey around (but there still are eggs)
22        if prey_count == 0:
23            return 0
24
25        # Use Verhulst model
26        change = self.N * self.PREDATOR_GROWTH * (1 - self.N / prey_count)
27        self.N += change
28
29        ratio = np.log(self.N / prey_count)
30        # probability to get killed
31        # compute logistically
32        # multiplication with 2 so that when n_predators == n_prey, the mortality rate is equal to PREDATION_RATE
33        fraction_killed = 2 * self.PREDATION_RATE / (1 + np.exp(-ratio))
34
35        return fraction_killed
class Predation:
 5class Predation:
 6    """
 7    GUI
 8    Predation is an optional source of mortality, useful for modeling death with prey-predator dynamics.
 9    [[PREDATION_RATE]] specifies how deadly the predators are; thus if set to 0, no predation deaths will occur.
10    Apart from [[PREDATION_RATE]], the probability that an individual actually gets predated depends also on the number of predators; the response curve is logistic.
11    The predator population grows according to the logistic Verhulst growth model, whose slope is parameterized by [[PREDATOR_GROWTH]].
12    All individuals are equally susceptible to predation; age and genetics have no impact.
13    """
14
15    def __init__(self, PREDATOR_GROWTH, PREDATION_RATE):
16        self.N = 1
17        self.PREDATOR_GROWTH = PREDATOR_GROWTH
18        self.PREDATION_RATE = PREDATION_RATE
19
20    def __call__(self, prey_count):
21
22        # TODO Add attrition penalty for when there are no living prey around (but there still are eggs)
23        if prey_count == 0:
24            return 0
25
26        # Use Verhulst model
27        change = self.N * self.PREDATOR_GROWTH * (1 - self.N / prey_count)
28        self.N += change
29
30        ratio = np.log(self.N / prey_count)
31        # probability to get killed
32        # compute logistically
33        # multiplication with 2 so that when n_predators == n_prey, the mortality rate is equal to PREDATION_RATE
34        fraction_killed = 2 * self.PREDATION_RATE / (1 + np.exp(-ratio))
35
36        return fraction_killed

GUI Predation is an optional source of mortality, useful for modeling death with prey-predator dynamics. [[PREDATION_RATE]] specifies how deadly the predators are; thus if set to 0, no predation deaths will occur. Apart from [[PREDATION_RATE]], the probability that an individual actually gets predated depends also on the number of predators; the response curve is logistic. The predator population grows according to the logistic Verhulst growth model, whose slope is parameterized by [[PREDATOR_GROWTH]]. All individuals are equally susceptible to predation; age and genetics have no impact.

Predation(PREDATOR_GROWTH, PREDATION_RATE)
15    def __init__(self, PREDATOR_GROWTH, PREDATION_RATE):
16        self.N = 1
17        self.PREDATOR_GROWTH = PREDATOR_GROWTH
18        self.PREDATION_RATE = PREDATION_RATE
N
PREDATOR_GROWTH
PREDATION_RATE