Huepe-Aldana noisy majority Boolean network
The Boolean network of Huepe and Aldana-González.
- Class:
NoisyBooleanNetworkSystem - Import:
from skcomplex.systems.biology.systems_biology import NoisyBooleanNetworkSystem - Field:
biology/systems_biology - Topics:
boolean network,noise,phase transition,mean field,stochastic map - References:
- Huepe and Aldana-González 2002
- Gros 2015
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.systems_biology import NoisyBooleanNetworkSystem
trajectory = NoisyBooleanNetworkSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
n |
1000 |
k |
3 |
eta |
0.1 |
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 | none |
| Laws | update |
| Randomness | stochastic |
| Domains | integer |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class NoisyBooleanNetworkSystem(BaseSystem):
"""The Boolean network of Huepe and Aldana-González.
Its nodes follow the noisy majority of `k` inputs.
Every node takes the sign of the sum of its `k` random inputs, flipped with the probability `eta`. The order
parameter `Psi`, the time average of the absolute mean state, undergoes a continuous phase transition at the noise
`eta_c = (1 - 1 / Phi'(0)) / 2` of mean-field theory, with `Phi'(0) = k C(k - 1, (k - 1) / 2) / 2^(k - 1)`, which is
1/6 for `k = 3`. Below it the network orders, above it the mean state falls to fluctuations of order `1 / sqrt(n)`.
The system has the states `nodes.sigma`.
Args:
n:
The number of nodes.
k:
The number of inputs of every node, odd.
eta:
The noise, the probability of a flip.
seed:
The seed of the inputs.
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:
ValidationError:
The number of inputs is even.
Examples:
>>> from skcomplex.systems.biology.systems_biology import NoisyBooleanNetworkSystem
>>> NoisyBooleanNetworkSystem(10).prepare().system_.elements[0].size
10
"""
field = 'biology/systems_biology'
topics = ('boolean network', 'noise', 'phase transition', 'mean field', 'stochastic map')
references = ('Huepe and Aldana-González 2002', 'Gros 2015')
until = 200
dt = 1
def __init__(
self,
n: int = 1000,
*,
k: int = 3,
eta: float = 0.1,
seed: int | None = 0,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.n = n
self.k = k
self.eta = eta
self.seed = seed
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the Boolean network of Huepe and Aldana-González.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
if self.k % 2 == 0:
error_msg = f'The number of inputs must be odd so that the majority is defined, not {self.k}.'
raise ValidationError(error_msg)
rng = np.random.default_rng(self.seed)
inputs = np.zeros((self.n, self.n))
for node in range(self.n):
inputs[node, rng.choice(np.delete(np.arange(self.n), node), size=self.k, replace=False)] = 1.0
nodes = MajorityNodeElement('nodes', sigma=np.ones(self.n), eta=self.eta, size=self.n)
majority = NoisyMajorityInteraction('majority', nodes='nodes', inputs=scipy.sparse.csr_array(inputs))
self.system_ = System(self.label, elements=[nodes], interactions=[majority])
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
MajorityNodeElement, fromElement
Interactions:
NoisyMajorityInteraction, fromInteraction
class MajorityNodeElement(Element):
"""Node of a noisy Boolean network, a state of plus or minus one.
The node follows the majority of its inputs.
Args:
label:
The label of the node or of the group of nodes.
sigma:
The state, -1 or 1.
eta:
The probability that the node takes the state opposite to the majority.
size:
The number of members, or `None` for one.
Examples:
>>> from skcomplex.systems.biology.systems_biology import MajorityNodeElement
>>> MajorityNodeElement('node', eta=0.1).eta
0.1
"""
def __init__(
self,
label: str,
*,
sigma: Annotated[float | Array, FiniteEnumeratedSet([-1, 1])] = 1.0,
eta: Annotated[float | Array, RealSet.closed(0, 1)] = 0.0,
size: int | None = None,
) -> None:
super().__init__(label, size=size)
self.sigma = sigma
self.eta = eta
class NoisyMajorityInteraction(Interaction):
"""Update of every node of a Boolean network to the sign of the sum of its inputs.
The sign is flipped with a probability.
Node `i` takes `sign(sum_j sigma_ij)` over its inputs with the probability `1 - eta` and the opposite sign with
the probability `eta`, all nodes at once, the network of Huepe and Aldana-González (2002).
Args:
label:
The label of the interaction.
nodes:
The path of the group of nodes.
inputs:
The input matrix, dense or sparse, one row per node with 1 for every input, an odd number per row.
Examples:
>>> from skcomplex.systems.biology.systems_biology import NoisyMajorityInteraction
>>> NoisyMajorityInteraction('majority', nodes='nodes', inputs=((0.0, 1.0), (1.0, 0.0))).nodes
'nodes'
"""
draws = True
law_classes = (UpdateLaw,)
def __init__(
self,
label: str,
*,
nodes: Role,
inputs: Sequence[Sequence[float]] | scipy.sparse.sparray = ((0.0,),),
) -> None:
super().__init__(label)
self.nodes = nodes
self.inputs = inputs
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the noisy majority update.
Args:
context:
The namespace of the group of nodes.
"""
super()._prepare(context)
node = context.nodes
weights = self.inputs if scipy.sparse.issparse(self.inputs) else np.asarray(self.inputs, dtype=float)
majority = where(total(node.sigma, weights=weights) > 0, 1, -1)
self.laws_: list[BaseLaw] = [UpdateLaw(node.sigma, where(uniform('flip') < node.eta, -majority, majority))]
Equations
The equations are those that symbolic returns for the system with its default parameters.
nodes.sigma[i]: sigma_nodes(t + 1) == where(uniform_flip_majority < eta_nodes, -where(_reduced_0 > 0, 1, -1), where(_reduced_0 > 0, 1, -1))