Dense homogeneous associative network of transient attractors
The dense homogeneous associative network of Gros.
- Class:
AssociativeThoughtProcessSystem - Import:
from skcomplex.systems.biology.neuroscience import AssociativeThoughtProcessSystem - Field:
biology/neuroscience - Topics:
associative memory,transient attractors,winners-take-all,cognitive systems,ode - References:
- Gros 2007
- 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.neuroscience import AssociativeThoughtProcessSystem
trajectory = AssociativeThoughtProcessSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
cliques |
((0, 1), (0, 6), (3, 6), (1, 2, 3), (4, 5, 6), (1, 2, 4, 5)) |
w |
0.15 |
z |
1.0 |
x_c |
0.85 |
gamma_plus |
0.005 |
gamma_minus |
0.005 |
start |
(0, 1) |
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 AssociativeThoughtProcessSystem(BaseSystem):
"""The dense homogeneous associative network of Gros.
Its memories become active one after the other.
Every memory is a clique of sites joined by excitatory links of strength `w`, and every other pair of sites inhibits
each other with strength `z`. Without reservoirs the network is a winners-take-all network whose cliques are stable
attractors. The reservoirs of an active clique deplete slowly, and once they are low the clique loses its excitation
and its hold on the other sites, so the activity hops to an associated clique that shares sites with it. The
memories become transient attractors, and the network runs through a sequence of them, an associative thought
process. The default is the network of seven sites and six cliques of Gros (2015, figure 10.12). The system has the
activities `sites.x` and the reservoirs `sites.phi`.
Args:
cliques:
The memories, each a sequence of site indices.
w:
The strength of the excitatory links within a clique.
z:
The strength of the inhibition between sites of no common clique.
x_c:
The activity above which a site counts as active.
gamma_plus:
The recovery rate of the reservoirs.
gamma_minus:
The depletion rate of the reservoirs.
start:
The sites that are active at the start.
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.neuroscience import AssociativeThoughtProcessSystem
>>> AssociativeThoughtProcessSystem().prepare().system_.elements[0].size
7
"""
field = 'biology/neuroscience'
topics = ('associative memory', 'transient attractors', 'winners-take-all', 'cognitive systems', 'ode')
references = ('Gros 2007', 'Gros 2015')
until = 1500.0
dt = 2.0
def __init__(
self,
cliques: Sequence[Sequence[int]] = CLIQUES,
*,
w: float = 0.15,
z: float = 1.0,
x_c: float = 0.85,
gamma_plus: float = 0.005,
gamma_minus: float = 0.005,
start: Sequence[int] = (0, 1),
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.cliques = cliques
self.w = w
self.z = z
self.x_c = x_c
self.gamma_plus = gamma_plus
self.gamma_minus = gamma_minus
self.start = start
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set the system of the dense homogeneous associative network of Gros.
Args:
context:
The observables to compile with the problem, or `None` for none.
"""
super()._prepare(context)
size = 1 + max(max(clique) for clique in self.cliques)
links = np.zeros((size, size))
for clique in self.cliques:
for first, second in combinations(clique, 2):
links[first, second] = links[second, first] = self.w
activities = np.zeros(size)
activities[list(self.start)] = 1.0
sites = AssociativeSiteElement(
'sites',
x=activities,
phi=1.0,
x_c=self.x_c,
gamma_plus=self.gamma_plus,
gamma_minus=self.gamma_minus,
size=size,
)
competition = CliqueCompetitionInteraction(
'competition',
sites='sites',
w=tuple(map(tuple, links.tolist())),
z=self.z,
)
reservoirs = ReservoirInteraction('reservoirs', target='sites')
self.system_ = System(self.label, elements=[sites], interactions=[reservoirs, competition])
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
AssociativeSiteElement, fromElement
Interactions:
ReservoirInteraction, fromInteractionCliqueCompetitionInteraction, fromInteraction
class AssociativeSiteElement(Element):
"""Sites of a dense homogeneous associative network, with an activity and a slow reservoir.
Args:
label:
The label of the site or of the group of sites.
x:
The initial activity.
phi:
The initial reservoir.
x_c:
The activity above which a site counts as active.
gamma_plus:
The recovery rate of the reservoir.
gamma_minus:
The depletion rate of the reservoir.
size:
The number of members, or `None` for one.
Examples:
>>> from skcomplex.systems.biology.neuroscience import AssociativeSiteElement
>>> AssociativeSiteElement('sites').x_c
0.85
"""
def __init__(
self,
label: str,
*,
x: Annotated[float | Array, UNIT] = 0.0,
phi: Annotated[float | Array, UNIT] = 1.0,
x_c: Annotated[float | Array, RealSet.open(0, 1)] = 0.85,
gamma_plus: Annotated[float | Array, RealSet.closed_open(0, oo)] = 0.005,
gamma_minus: Annotated[float | Array, RealSet.closed_open(0, oo)] = 0.005,
size: int | None = None,
) -> None:
super().__init__(label, size=size)
self.x = x
self.phi = phi
self.x_c = x_c
self.gamma_plus = gamma_plus
self.gamma_minus = gamma_minus
class ReservoirInteraction(Interaction):
"""Depletion and recovery of the reservoirs of the sites of an associative network.
The reservoir `phi` of an active site, `x > x_c`, depletes as `dphi/dt = -gamma_minus phi`, and the reservoir of an
inactive site recovers as `dphi/dt = gamma_plus (1 - phi) (1 - x / x_c)`. The network couples the activities.
Args:
label:
The label of the interaction.
target:
The path of the sites, whose values are `x`, `phi`, `x_c`, `gamma_plus`, and `gamma_minus`.
Examples:
>>> from skcomplex.systems.biology.neuroscience import ReservoirInteraction
>>> ReservoirInteraction('reservoirs', target='sites').target
'sites'
"""
law_classes = (RateLaw,)
def __init__(self, label: str, *, target: Role) -> None:
super().__init__(label)
self.target = target
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the laws of the target.
Args:
context:
The namespace of the target, the time `t`, and the parameters.
"""
super()._prepare(context)
target = context.target
recovery = target.gamma_plus * (1 - target.phi) * (1 - target.x / target.x_c)
self.laws_ = [RateLaw(target.phi, where(target.x > target.x_c, -target.gamma_minus * target.phi, recovery))]
class CliqueCompetitionInteraction(Interaction):
"""Competition of the cliques of a winners-take-all network.
The reservoirs of the sites gate the competition.
Site `i` grows by `dx_i/dt = (1 - x_i) r_i` for a positive input `r_i` and decays by `dx_i/dt = x_i r_i` for a
negative one, with `r_i = sum_j [f_w(phi_i) w_ij + z_ij f_z(phi_j)] x_j`. The excitatory links `w_ij > 0` join the
sites of every clique, and every other pair inhibits with `z_ij = -|z|`. The reservoir functions `f(phi) = f_min +
(1 - f_min) (atan((phi - phi_c) / width) - atan(-phi_c / width)) / (atan((1 - phi_c) / width) - atan(-phi_c /
width))` switch off the excitation of a site whose own reservoir is low and the inhibition by a site whose
reservoir is low.
Args:
label:
The label of the interaction.
sites:
The path of the group of sites.
w:
The excitatory links, a symmetric matrix with zeros where sites inhibit each other.
z:
The strength of the inhibition.
phi_w:
The inflection point of the reservoir function of the excitation.
phi_z:
The inflection point of the reservoir function of the inhibition.
width:
The width of the reservoir functions.
f_w_min:
The floor of the reservoir function of the excitation.
f_z_min:
The floor of the reservoir function of the inhibition.
Examples:
>>> from skcomplex.systems.biology.neuroscience import CliqueCompetitionInteraction
>>> CliqueCompetitionInteraction('competition', sites='sites', w=((0.0, 0.1), (0.1, 0.0))).z
1.0
"""
law_classes = (RateLaw,)
def __init__(
self,
label: str,
*,
sites: Role,
w: Sequence[Sequence[float]] = ((0.0,),),
z: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
phi_w: Annotated[float, RealSet.open(0, 1)] = 0.7,
phi_z: Annotated[float, RealSet.open(0, 1)] = 0.15,
width: Annotated[float, RealSet.open(0, oo)] = 0.05,
f_w_min: Annotated[float, RealSet.closed(0, 1)] = 0.1,
f_z_min: Annotated[float, RealSet.closed(0, 1)] = 0.0,
) -> None:
super().__init__(label)
self.sites = sites
self.w = w
self.z = z
self.phi_w = phi_w
self.phi_z = phi_z
self.width = width
self.f_w_min = f_w_min
self.f_z_min = f_z_min
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the growth and decay of the activities.
Args:
context:
The namespace of the symbols the laws can use.
"""
super()._prepare(context)
s = context
site = s.sites
excitatory = np.asarray(self.w, dtype=float)
inhibitory = np.where(excitatory > 0, 0.0, -1.0)
np.fill_diagonal(inhibitory, 0.0)
excitation = self._get_reservoir(site.phi, s.phi_w, s.f_w_min, s.width) * total(site.x, weights=excitatory)
inhibition = s.z * total(
self._get_reservoir(site.phi, s.phi_z, s.f_z_min, s.width) * site.x,
weights=inhibitory,
)
r = excitation + inhibition
self.laws_: list[BaseLaw] = [RateLaw(site.x, where(r > 0, (1 - site.x) * r, site.x * r))]
def _get_reservoir(self, phi: Expression, center: Expression, floor: Expression, width: Expression) -> Expression:
"""Return the sigmoidal reservoir function of a reservoir level."""
lowest = atan(-center / width)
return floor + (1 - floor) * (atan((phi - center) / width) - lowest) / (atan((1 - center) / width) - lowest)
Equations
The equations are those that symbolic returns for the system with its default parameters.
sites.x[i]: diff(x_sites(t), t) == where(_reduced_0*(f_w_min_competition - (f_w_min_competition - 1)*(arctan(-(phi_w_competition - phi_sites(t))/width_competition) - arctan(-phi_w_competition/width_competition))/(arctan(-(phi_w_competition - 1)/width_competition) - arctan(-phi_w_competition/width_competition))) + _reduced_1*z_competition > 0, -(_reduced_0*(f_w_min_competition - (f_w_min_competition - 1)*(arctan(-(phi_w_competition - phi_sites(t))/width_competition) - arctan(-phi_w_competition/width_competition))/(arctan(-(phi_w_competition - 1)/width_competition) - arctan(-phi_w_competition/width_competition))) + _reduced_1*z_competition)*(x_sites(t) - 1), (_reduced_0*(f_w_min_competition - (f_w_min_competition - 1)*(arctan(-(phi_w_competition - phi_sites(t))/width_competition) - arctan(-phi_w_competition/width_competition))/(arctan(-(phi_w_competition - 1)/width_competition) - arctan(-phi_w_competition/width_competition))) + _reduced_1*z_competition)*x_sites(t))
sites.phi[i]: diff(phi_sites(t), t) == where(x_sites(t) > x_c_sites, -gamma_minus_sites*phi_sites(t), gamma_plus_sites*(x_sites(t)/x_c_sites - 1)*(phi_sites(t) - 1))