Skip to content

Gompertz growth

A tumour whose growth slows as the logarithm of the room left, dn/dt = r n log(K / n).

  • Name: gompertz
  • Field: biology/oncology
  • Formalism: ordinary differential equations
  • References: Padmanabhan, Meskin, and Al Moustafa 2021; Benzekry et al. 2014; Gompertz 1825

Factory

@register_model(
    field='biology/oncology',
    tags=('tumour growth', 'ode', 'sigmoid'),
    references=(*GROWTH_REFERENCES, 'Gompertz 1825'),
    defaults={'until': 100.0, 'dt': 0.5},
)
def gompertz(n: float = 10.0, *, r: float = 0.0719, K: float = 1964.0) -> System:
    """Return a tumour whose growth slows as the logarithm of the room left, `dn/dt = r n log(K / n)`.

    The volume follows `K exp(log(n0 / K) exp(-r t))` and tends to `K`. The rate is the fitted decay of the
    proliferation of breast cancer, per day, and the capacity is in mm³.

    Args:
        n:
            The initial volume.

        r:
            The rate at which the growth slows.

        K:
            The carrying capacity.

    Returns:
        system:
            The model, with the volume `tumour.n`.

    Examples:
        >>> from skcomplex.models.biology.oncology import gompertz
        >>> gompertz(K=1000.0).interactions[0].K
        1000.0
    """
    return System(
        elements=[PopulationElement('tumour', n=n)],
        interactions=[GompertzGrowthInteraction('growth', target='tumour', r=r, K=K)],
    )

Components

class PopulationElement(CompartmentElement):
    """Population of one species, a compartment whose state `n` holds its size.

    Args:
        label:
            The label of the population.

        visual:
            How the element is drawn, or `None` for `default_visual_`.

        n:
            The initial size.

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

    def __init__(
        self,
        label: str,
        visual: VisualSpec | None = None,
        *,
        n: Annotated[float, StateSpec(domain=RealSet.closed_open(0, oo))] = 1.0,
    ) -> None:
        super().__init__(label, visual=visual, n=n)

class GompertzGrowthInteraction(GrowthInteraction):
    """Gompertz growth towards a capacity, `dn/dt = r n log(K / n(t - tau))`, without harvest.

    Args:
        label:
            The label of the interaction.

        target:
            The path of the element or group whose population grows.

        r:
            The growth rate.

        K:
            The capacity.

        tau:
            The delay of the limiting factor, 0 for none.

        state:
            The name of the state of the target that holds the population.

    Examples:
        >>> from skcomplex.core.elements import CompartmentElement
        >>> from skcomplex.core.system import System
        >>> from skcomplex.engine.runtime import Simulation
        >>> from skcomplex.models.biology.common.populations import GompertzGrowthInteraction
        >>> system = System(
        ...     elements=[CompartmentElement('tumour', n=1.0)],
        ...     interactions=[GompertzGrowthInteraction('growth', target='tumour', r=1.0, K=20.0)],
        ... )
        >>> trajectory = Simulation(system, dt=0.1).check().prepare().run(until=30.0).trajectory_
        >>> round(float(trajectory.values('tumour.n')[-1]), 3)
        20.0
    """

    def __init__(
        self,
        label: str,
        *,
        target: Annotated[str, RoleSpec()],
        r: Annotated[float, ParameterSpec(domain=RealSet.open(0, oo))] = 0.0719,
        K: Annotated[float, ParameterSpec(domain=RealSet.open(0, oo))] = 1964.0,
        tau: Annotated[float, ParameterSpec(domain=RealSet.closed_open(0, oo))] = 0.0,
        state: str = 'n',
    ) -> None:
        super().__init__(label, target=target, r=r, K=K, tau=tau, form='gompertz', state=state)

    def _get_rate(self, namespace: SimpleNamespace) -> Expression:
        """Return the Gompertz growth, with no harvest.

        Args:
            namespace:
                The namespace of the symbols the rate can use, with the namespace of the target.

        Returns:
            rate:
                The rate of the population.
        """
        return self._get_growth(namespace)

Equations

tumour.n: diff(n_tumour(t), t) == r_growth*log(K_growth/n_tumour(t))*n_tumour(t)