Lamplighter
The parity automaton on a ball of the lamplighter group.
- Class:
LamplighterAutomatonSystem - Import:
from skcomplex.systems.computer_science.automata import LamplighterAutomatonSystem - Field:
computer_science/automata - Topics:
group,cellular automaton,linear,lamplighter - References:
- Ceccherini-Silberstein and Coornaert 2023
- Grigorchuk and Zuk 2001
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.computer_science.automata import LamplighterAutomatonSystem
trajectory = LamplighterAutomatonSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
radius |
7 |
density |
0.1 |
random_state |
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 | lattice |
| Laws | update |
| Randomness | unknown |
| Domains | boolean |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class LamplighterAutomatonSystem(BaseSystem):
"""The parity automaton on a ball of the lamplighter group.
It is a linear rule over the field of two elements. Every cell takes the sum modulo 2 of itself and the cells at the
generators `a` and `b`, so a few ones spread into nested, self-similar patterns over the Diestel-Leader graph of the
group. The system has the cells `cells.alive`.
Args:
radius:
The radius of the ball.
density:
The probability that a cell starts at 1.
random_state:
The seed or generator of the initial cells.
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.computer_science.automata import LamplighterAutomatonSystem
>>> LamplighterAutomatonSystem(radius=3).prepare().simulate(until=1).get_values('cells.alive').shape
(2, 39)
"""
field = 'computer_science/automata'
topics = ('group', 'cellular automaton', 'linear', 'lamplighter')
references = ('Ceccherini-Silberstein and Coornaert 2023', 'Grigorchuk and Zuk 2001')
until = 20
dt = 1
observables = (Observable('density', group='cells', variable='alive'),)
def __init__(
self,
*,
radius: int = 7,
density: float = 0.1,
random_state: int | np.random.Generator | None = 0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.radius = radius
self.density = density
self.random_state = random_state
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of random cells on a ball of the lamplighter group and their parity rule."""
super()._prepare(context)
space = CayleySpace(lamplighter(), ball=self.radius)
cells = np.asarray(
np.random.default_rng(self.random_state).random(space.prepare().size_) < self.density,
dtype=float,
)
self.system_ = System(
self.label,
elements=[BinaryCellElement('cells', alive=cells, space=space)],
interactions=[ParityRuleInteraction('parity', target='cells', neighborhood=LAMPLIGHTER_MEMORY)],
)
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
BinaryCellElement, fromElement
Interactions:
ParityRuleInteraction, fromInteraction
class BinaryCellElement(Element):
"""Cell of an automaton whose value `alive` is 0 or 1.
The local rule of an interaction changes the value. With `space`, the element holds one cell on every site.
Args:
label:
The label of the cells.
alive:
The initial value, 0 or 1, or one value per cell.
space:
The space with one cell on every site, such as a lattice, or `None` for one cell.
Examples:
>>> from skcomplex.systems.computer_science.automata import BinaryCellElement
>>> BinaryCellElement('cell', alive=1).alive
1
"""
def __init__(
self,
label: str,
*,
alive: Annotated[float | Array, {0, 1}] = 0,
space: BaseSpace | None = None,
) -> None:
super().__init__(label, space=space)
self.alive = alive
class ParityRuleInteraction(Interaction):
"""Parity rule of binary cells, the sum modulo 2 of a cell and its neighbours.
It is a linear rule over the field of two elements, so a sum of configurations maps to the sum of their images.
Args:
label:
The label of the interaction.
target:
The cells whose state `alive` the rule updates.
neighborhood:
The cell and its neighbours, such as a memory set of a group.
Examples:
>>> from skcomplex.systems.computer_science.automata import ParityRuleInteraction
>>> from skcomplex.systems.computer_science.common.automata import MemoryNeighborhood
>>> memory = MemoryNeighborhood(('1', 'a', 'b'))
>>> ParityRuleInteraction('parity', target='cells', neighborhood=memory).neighborhood.elements
('1', 'a', 'b')
"""
def __init__(
self,
label: str,
*,
target: Role = 'cells',
neighborhood: MemoryNeighborhood = LAMPLIGHTER_MEMORY,
) -> None:
super().__init__(label)
self.target = target
self.neighborhood = neighborhood
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the parity of every cell and its neighbours as the law.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
parity = TotalisticSpec({total: total % 2 for total in range(len(self.neighborhood.elements) + 1)})
alive = context.target.alive
self.laws_: list[BaseLaw] = [
UpdateLaw(alive, parity, neighborhood=self.neighborhood, label=self.label),
]