Skip to content

Mackey-Glass

The Mackey-Glass equation of blood cell production.

  • Class: MackeyGlassSystem
  • Import: from skcomplex.systems.biology.physiology import MackeyGlassSystem
  • Field: biology/physiology
  • Topics: chaos, delay, physiology
  • References:
    • Mackey and Glass 1977
    • Erneux 2009

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.physiology import MackeyGlassSystem

trajectory = MackeyGlassSystem().prepare().simulate()

Parameters

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

Parameter Default
x 0.5
beta 0.2
gamma 0.1
n 10.0
tau 17.0
solver 'auto'
backend 'auto'

Tags

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

Tag Values
Time continuous
Space none
Laws rate
Randomness deterministic
Domains real
Structure fixed

Class

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

class MackeyGlassSystem(BaseSystem):
    """The Mackey-Glass equation of blood cell production.

    It is `x' = beta x(t - tau) / (1 + x(t - tau)^n) - gamma x`.

    It is periodic for `tau = 6` and chaotic for `tau = 17`. The history before the start is the initial value. The
    system has the concentration `cells.x`.

    Args:
        x:
            The initial concentration, also its history.

        beta:
            The production rate.

        gamma:
            The decay rate.

        n:
            The steepness of the production feedback.

        tau:
            The delay of production.

        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.physiology import MackeyGlassSystem
        >>> MackeyGlassSystem(tau=6.0).prepare().system_.interactions[0].tau
        6.0
    """

    field = 'biology/physiology'
    topics = ('chaos', 'delay', 'physiology')
    references = ('Mackey and Glass 1977', 'Erneux 2009')
    until = 500.0
    dt = 0.5

    def __init__(
        self,
        x: float = 0.5,
        *,
        beta: float = 0.2,
        gamma: float = 0.1,
        n: float = 10.0,
        tau: float = 17.0,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.x = x
        self.beta = beta
        self.gamma = gamma
        self.n = n
        self.tau = tau

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the Mackey-Glass equation of blood cell production.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.
        """
        super()._prepare(context)
        self.system_ = System(
            self.label,
            elements=[MackeyGlassElement('cells', x=self.x)],
            interactions=[
                MackeyGlassInteraction(
                    'production',
                    target='cells',
                    beta=self.beta,
                    gamma=self.gamma,
                    n=self.n,
                    tau=self.tau,
                ),
            ],
        )

Components

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

Elements:

Interactions:

  • MackeyGlassInteraction, from Interaction
class MackeyGlassElement(Element):
    """Blood cells of Mackey and Glass, with the number `x` of cells.

    Args:
        label:
            The label of the cells.

        x:
            The initial number of cells.

    Examples:
        >>> from skcomplex.systems.biology.physiology import MackeyGlassElement
        >>> MackeyGlassElement('cells').x
        0.5
    """

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

class MackeyGlassInteraction(Interaction):
    """Delayed production and loss of blood cells, `x' = beta x_tau / (1 + x_tau^n) - gamma x`.

    The production reads the number of cells `x_tau` a delay `tau` earlier.

    Args:
        label:
            The label of the interaction.

        target:
            The path of the cells.

        beta:
            The rate of production.

        gamma:
            The rate of loss.

        n:
            The exponent of the feedback.

        tau:
            The delay of the production.

    Examples:
        >>> from skcomplex.systems.biology.physiology import MackeyGlassInteraction
        >>> MackeyGlassInteraction('production', target='cells').tau
        17.0
    """

    law_classes = (RateLaw,)

    def __init__(
        self,
        label: str,
        *,
        target: Role,
        beta: float = 0.2,
        gamma: float = 0.1,
        n: float = 10.0,
        tau: Annotated[float, RealSet.open(0, oo)] = 17.0,
    ) -> None:
        super().__init__(label)
        self.target = target
        self.beta = beta
        self.gamma = gamma
        self.n = n
        self.tau = tau

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the delayed production and the loss of the cells.

        Args:
            context:
                The namespace of the cells, the time `t`, and the parameters.
        """
        super()._prepare(context)
        s = context
        x = s.target.x
        history = x(t=s.t - s.tau)
        self.laws_ = [RateLaw(x, s.beta * history * (1 - hill(history, 1, s.n)) - s.gamma * x)]

Equations

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

cells.x: diff(x_cells(t), t) == -beta_production*(x_cells(t - tau_production)^n_production/(x_cells(t - tau_production)^n_production + 1) - 1)*x_cells(t - tau_production) - gamma_production*x_cells(t)