Skip to content

Coupled map lattices on networks

Chaotic logistic maps on the nodes of a network.

  • Class: CoupledMapLatticesOnNetworksSystem
  • Import: from skcomplex.systems.physics.synchronization import CoupledMapLatticesOnNetworksSystem
  • Field: physics/synchronization
  • Topics: synchronization, map, chaos, network
  • References:
    • Arenas et al. 2008
    • Kaneko 1989

Use this system

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

from skcomplex.systems.physics.synchronization import CoupledMapLatticesOnNetworksSystem

trajectory = CoupledMapLatticesOnNetworksSystem().prepare().simulate()

Parameters

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

Parameter Default
n_nodes 100
network 'erdos_renyi'
degree 20
rewiring 0.1
r 4.0
epsilon 0.9
seed 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 network
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 CoupledMapLatticesOnNetworksSystem(BaseSystem):
    """Chaotic logistic maps on the nodes of a network.

    Each map is pulled towards the mean of its neighbours.

    Node `i` follows `x_i(t + 1) = (1 - epsilon) f(x_i) + (epsilon / k_i) sum_j A_ij f(x_j)` with the logistic map `f(x)
    = r x (1 - x)`, a mean over the neighbours of the network. For a coupling `epsilon` large enough against the
    Lyapunov exponent of the map and the spectral gap of the network, the maps synchronize on one chaotic orbit, and the
    variance of the states over the nodes falls to zero. Below it they stay incoherent. The system has the states
    `maps.x` and their variance over the nodes, `spread`.

    Args:
        n_nodes:
            The number of maps, the nodes of the network.

        network:
            The generator, `'watts_strogatz'`, `'erdos_renyi'`, or `'barabasi_albert'`.

        degree:
            The mean degree of the network.

        rewiring:
            The probability of rewiring every edge of the Watts-Strogatz ring.

        r:
            The parameter of the logistic map, chaotic at 4.

        epsilon:
            The coupling between 0 and 1.

        seed:
            The seed of the network and the initial states.

        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.

    Raises:
        ValueError:
            The network is unknown.

    Examples:
        >>> from skcomplex.systems.physics.synchronization import CoupledMapLatticesOnNetworksSystem
        >>> CoupledMapLatticesOnNetworksSystem(20).prepare().system_.elements[0].space.graph.number_of_nodes()
        20
    """

    field = 'physics/synchronization'
    topics = ('synchronization', 'map', 'chaos', 'network')
    references = ('Arenas et al. 2008', 'Kaneko 1989')
    until = 100.0
    dt = 1.0
    observables = (Observable('spread', group='maps', variable='x', reduce='var'),)

    def __init__(
        self,
        n_nodes: int = 100,
        *,
        network: str = 'erdos_renyi',
        degree: int = 20,
        rewiring: float = 0.1,
        r: float = 4.0,
        epsilon: float = 0.9,
        seed: int = 0,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.n_nodes = n_nodes
        self.network = network
        self.degree = degree
        self.rewiring = rewiring
        self.r = r
        self.epsilon = epsilon
        self.seed = seed

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of chaotic logistic maps on the nodes of a network.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.

        Raises:
            ValueError:
                The network is unknown.
        """
        super()._prepare(context)
        space = KuramotoOnNetworksSystem._get_network(self.network, self.n_nodes, self.degree, self.rewiring, self.seed)
        rng = np.random.default_rng(self.seed + 1)
        maps = LogisticNodeElement(
            'maps',
            x=rng.uniform(0.0, 1.0, self.n_nodes),
            r=self.r,
            epsilon=self.epsilon,
            space=space,
        )
        coupling = LogisticCouplingInteraction('coupling', target='maps')
        self.system_ = System(self.label, elements=[maps], interactions=[coupling])

Components

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

Elements:

  • LogisticNodeElement, from Element

Interactions:

  • LogisticCouplingInteraction, from Interaction
class LogisticNodeElement(Element):
    """Logistic maps on the nodes of a network, with their values, growth rates, and weights of the neighbours.

    `LogisticCouplingInteraction` iterates `x_i(t + 1) = (1 - epsilon) f(x_i) + epsilon mean_j f(x_j)`, where the map
    `f(x) = r x (1 - x)` of the node mixes with the mean of the maps of its neighbours `j` on the network.

    Args:
        label:
            The label of the maps.

        x:
            The initial value, or one value per node.

        r:
            The growth rate of the logistic map.

        epsilon:
            The weight of the neighbours.

        space:
            The network or lattice with one map on every node, or `None` for one map.

    Examples:
        >>> from skcomplex.systems.physics.synchronization import LogisticNodeElement
        >>> LogisticNodeElement('node').epsilon
        0.5
    """

    visual = VisualSpec('sites', {'states': ['x'], 'low': 0.0, 'high': 1.0})

    def __init__(
        self,
        label: str,
        *,
        x: object = 0.5,
        r: float = 4.0,
        epsilon: Annotated[float, RealSet.closed_open(0, oo)] = 0.5,
        space: BaseSpace | None = None,
    ) -> None:
        super().__init__(label, space=space)
        self.x = x
        self.r = r
        self.epsilon = epsilon

class LogisticCouplingInteraction(Interaction):
    """Coupled logistic maps.

    The maps follow `x_i(t + 1) = (1 - epsilon) f(x_i) + epsilon mean_j f(x_j)` with `f(x) = r x (1 - x)`.

    The map of every node mixes with the mean of the maps of its neighbours `j` on its lattice or network, with the
    parameters `r` and `epsilon` of the node. A node with no neighbours keeps `(1 - epsilon) f(x_i)`. It is the map
    form of coupling, as for populations on islands that exchange migrants or chaotic lasers that share light.

    Args:
        label:
            The label of the interaction, unique among the components of its system.

        target:
            The path of the maps, on the nodes of a lattice or network.

        state:
            The name of the state that the maps iterate.

    Examples:
        >>> import networkx as nx
        >>> from skcomplex.core.components.spaces import NetworkSpace
        >>> from skcomplex.core.systems import System
        >>> from skcomplex.systems.physics.synchronization import LogisticCouplingInteraction, LogisticNodeElement
        >>> maps = LogisticNodeElement('maps', x=[0.25, 0.5], epsilon=0.5, space=NetworkSpace(nx.path_graph(2)))
        >>> system = System(elements=[maps], interactions=[LogisticCouplingInteraction('coupling', target='maps')])
        >>> system.prepare().simulate(until=1).get_values('maps.x')[-1].tolist()
        [0.875, 0.875]
    """

    law_classes = (UpdateLaw,)

    def __init__(self, label: str, *, target: Role, state: str = 'x') -> None:
        super().__init__(label)
        self.target = target
        self.state = state

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the map of every node mixed with the mean map of its neighbours.

        Args:
            context:
                The namespace of the target, the time `t`, and the parameters.
        """
        super()._prepare(context)
        node = context.target
        x, other = getattr(node, self.state), getattr(node.other, self.state)
        neighbours = neighbors(node.r * other * (1 - other), reduce='mean')
        self.laws_ = [UpdateLaw(x, (1 - node.epsilon) * (node.r * x * (1 - x)) + node.epsilon * neighbours)]