Skip to content

Population Growth

dissmodel.models.sysdyn.population_growth.PopulationGrowth

Bases: Model

Exponential population growth model with variable growth rate.

Models a population that grows at a rate that itself changes over time. This allows simulating both accelerating and decelerating growth depending on :attr:growth_change.

Parameters:

Name Type Description Default
population float

Initial population size, by default 60.

required
growth float

Initial growth rate (e.g. 0.5 = 50% per step), by default 0.5.

required
growth_change float

Multiplicative factor applied to the growth rate each step. Values > 1 accelerate growth, values < 1 decelerate it, by default 1.0 (constant growth rate).

required
Notes

The @track_plot decorator registers population for automatic live plotting. Any :class:~dissmodel.visualization.Chart connected to the same environment will plot it at every step without any extra configuration.

The update equations at each step are:

.. math::

P_{t+1} = P_t \times (1 + r_t)

r_{t+1} = r_t \times c

Where :math:P is population, :math:r is growth rate and :math:c is :attr:growth_change.

Examples:

>>> from dissmodel.core import Environment
>>> env = Environment(end_time=20)
>>> model = PopulationGrowth()
>>> env.run()
Source code in dissmodel/models/sysdyn/population_growth.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@track_plot("Population", "green")
class PopulationGrowth(Model):
    """
    Exponential population growth model with variable growth rate.

    Models a population that grows at a rate that itself changes over
    time. This allows simulating both accelerating and decelerating
    growth depending on :attr:`growth_change`.

    Parameters
    ----------
    population : float, optional
        Initial population size, by default 60.
    growth : float, optional
        Initial growth rate (e.g. 0.5 = 50% per step), by default 0.5.
    growth_change : float, optional
        Multiplicative factor applied to the growth rate each step.
        Values > 1 accelerate growth, values < 1 decelerate it,
        by default 1.0 (constant growth rate).

    Notes
    -----
    The ``@track_plot`` decorator registers ``population`` for automatic
    live plotting. Any :class:`~dissmodel.visualization.Chart` connected
    to the same environment will plot it at every step without any extra
    configuration.

    The update equations at each step are:

    .. math::

        P_{t+1} = P_t \\times (1 + r_t)

        r_{t+1} = r_t \\times c

    Where :math:`P` is population, :math:`r` is growth rate and
    :math:`c` is :attr:`growth_change`.

    Examples
    --------
    >>> from dissmodel.core import Environment
    >>> env = Environment(end_time=20)
    >>> model = PopulationGrowth()
    >>> env.run()
    """

    #: Current population size.
    population: float

    #: Current growth rate.
    growth: float

    #: Multiplicative factor applied to the growth rate each step.
    growth_change: float

    def setup(
        self,
        population: float = 60.0,
        growth: float = 0.5,
        growth_change: float = 1.0,
    ) -> None:
        """
        Configure the model parameters.

        Parameters
        ----------
        population : float, optional
            Initial population size, by default 60.
        growth : float, optional
            Initial growth rate, by default 0.5.
        growth_change : float, optional
            Multiplicative factor applied to the growth rate each step,
            by default 1.0.
        """
        self.population    = population
        self.growth        = growth
        self.growth_change = growth_change

    def execute(self) -> None:
        """
        Advance the model by one time step.

        Updates the population and growth rate according to the
        variable-rate exponential growth equations.
        """
        self.population *= (1 + self.growth)
        self.growth     *= self.growth_change

execute()

Advance the model by one time step.

Updates the population and growth rate according to the variable-rate exponential growth equations.

Source code in dissmodel/models/sysdyn/population_growth.py
86
87
88
89
90
91
92
93
94
def execute(self) -> None:
    """
    Advance the model by one time step.

    Updates the population and growth rate according to the
    variable-rate exponential growth equations.
    """
    self.population *= (1 + self.growth)
    self.growth     *= self.growth_change

setup(population=60.0, growth=0.5, growth_change=1.0)

Configure the model parameters.

Parameters:

Name Type Description Default
population float

Initial population size, by default 60.

60.0
growth float

Initial growth rate, by default 0.5.

0.5
growth_change float

Multiplicative factor applied to the growth rate each step, by default 1.0.

1.0
Source code in dissmodel/models/sysdyn/population_growth.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def setup(
    self,
    population: float = 60.0,
    growth: float = 0.5,
    growth_change: float = 1.0,
) -> None:
    """
    Configure the model parameters.

    Parameters
    ----------
    population : float, optional
        Initial population size, by default 60.
    growth : float, optional
        Initial growth rate, by default 0.5.
    growth_change : float, optional
        Multiplicative factor applied to the growth rate each step,
        by default 1.0.
    """
    self.population    = population
    self.growth        = growth
    self.growth_change = growth_change