Skip to content

Innovation

Innovation: technological progress, combinatorial evolution, and more.

It also holds discovery, autocatalytic sets, and adoption.

AdjacentPossibleElement(label, *, x=0.1, d=0.0, r=5.0)

Bases: Element

Combinatorial system of entities.

It holds the share that exists and the share its new pairs can produce.

Parameters:

Name Type Description Default
label str

The label of the system.

required
x Annotated[float, closed_open(0, oo)]

The share of existing entities, the diversity.

0.1
d Annotated[float, closed_open(0, oo)]

The share of new entities, the adjacent possible.

0.0
r float

The rule density, the number of productive pairs per entity.

5.0

Examples:

>>> from skcomplex.systems.economics.innovation import AdjacentPossibleElement
>>> AdjacentPossibleElement('system', r=2.0).r
2.0
Source code in src/skcomplex/systems/economics/innovation/_diversity.py
51
52
53
54
55
56
57
58
59
60
61
62
def __init__(
    self,
    label: str,
    *,
    x: Annotated[float, RealSet.closed_open(0, oo)] = 0.1,
    d: Annotated[float, RealSet.closed_open(0, oo)] = 0.0,
    r: float = 5.0,
) -> None:
    super().__init__(label)
    self.x = x
    self.d = d
    self.r = r

AdoptionInteraction(label, *, target='households')

Bases: Interaction

Growth of the incomes of households and their adoption of a phone.

Every year the income of every household grows by its rate, income' = income (1 + growth). Then the households decide one after the other in a new random order, and a household gets a phone when its income reaches its threshold and one of its neighbours has a phone, so phones spread along chains of affording neighbours within a year.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The households, on the cells of a lattice.

'households'

Examples:

>>> from skcomplex.systems.economics.innovation import AdoptionInteraction
>>> AdoptionInteraction('adoption').target
'households'
Source code in src/skcomplex/systems/economics/innovation/_adoption.py
136
137
138
def __init__(self, label: str, *, target: Role = 'households') -> None:
    super().__init__(label)
    self.target = target

ArthurPolakSystem(*, max_components=12, max_inputs=3, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Arthur and Polak's evolution of technology.

It builds logic functions from NAND gates. The pool starts with the NAND gate and the constants 0 and 1. Every step wires a random circuit from the pool and keeps it when it computes a wanted function, negation, two-input and, or, exclusive or, nor, equivalence, and implication, or three-input and, or, parity, and majority, so simple inventions become the building blocks of complex ones. The system has the pool technologies, whose size is the reporter technologies.count.

Parameters:

Name Type Description Default
max_components int

The largest number of technologies in a circuit.

12
max_inputs int

The largest number of inputs of a circuit.

3
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.economics.innovation import ArthurPolakSystem
>>> ArthurPolakSystem().prepare().system_.elements[0].size
3
Source code in src/skcomplex/systems/economics/innovation/_technology.py
462
463
464
465
466
467
468
469
470
471
472
473
def __init__(
    self,
    *,
    max_components: int = 12,
    max_inputs: int = 3,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.max_components = max_components
    self.max_inputs = max_inputs

BallElement(label, *, color=0, count=1, drawn=0, values=None, size=None, space=None)

Bases: Element

Balls of one colour in the urn of a node.

The element holds how many there are and whether the node has drawn the colour.

A ball agent stands for every ball of its colour in the urn of the node it sits on, so the set of ball agents on a node is the set of colours of its urn, and their multiplicities make the urn a multiset.

Parameters:

Name Type Description Default
label str

The label of the agent or group.

required
color Annotated[object, NN]

The colour, a number shared by the balls of that colour in every urn.

0
count Annotated[object, NN]

The number of balls of the colour in the urn.

1
drawn Annotated[object, NN]

1 when the node has drawn the colour, and 0 when it has not.

0
values Mapping[str, object] | None

Further values by name, such as the node node of each member on the network.

None
size int | None

The number of balls, or None for one.

None
space BaseSpace | None

The network the balls live on, whose axis node places them, or None.

None

Examples:

>>> from skcomplex.systems.economics.innovation import BallElement
>>> BallElement('balls', color=3, count=2).count
2
Source code in src/skcomplex/systems/economics/innovation/_discovery.py
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
def __init__(
    self,
    label: str,
    *,
    color: Annotated[object, NN] = 0,
    count: Annotated[object, NN] = 1,
    drawn: Annotated[object, NN] = 0,
    values: Mapping[str, object] | None = None,
    size: int | None = None,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, values=values, size=size, space=space)
    self.color = color
    self.count = count
    self.drawn = drawn

BassDiffusionSystem(market=1000.0, *, adopters=0.0, p=0.03, q=0.38, label='system', solver='auto', backend='auto')

Bases: StockFlowSystem

The Bass diffusion system, people who adopt a new product.

They adopt through advertising and word of mouth. A market of N people splits into potential adopters P and adopters A. Potential adopters adopt at the rate (p + q A / N) P, where the coefficient of innovation p captures adoption from external influence, such as advertising, and the coefficient of imitation q adoption from contact with adopters. People are conserved, so the adoption is a flow from P to A. With q > p the adoption rate rises to a peak at the time log(q / p) / (p + q) and the adopters follow an S-shaped curve. Starting without adopters, the closed form is A(t) = N (1 - exp(-(p + q) t)) / (1 + (q / p) exp(-(p + q) t)). The defaults are the mean coefficients that Sultan, Farley and Lehmann (1990) estimated over many products, with time in years.

The system has the potential adopters market.P, the adopters market.A, and the adoption flow market.adoption in people per year, over years.

Parameters:

Name Type Description Default
market float

The market potential N, the number of people who eventually adopt.

1000.0
adopters float

The initial adopters, a part of the market.

0.0
p float

The coefficient of innovation, per year.

0.03
q float

The coefficient of imitation, per year.

0.38
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.economics.innovation import BassDiffusionSystem
>>> BassDiffusionSystem(market=500.0, adopters=10.0).prepare().system_.elements[0].values['P']
490.0
Source code in src/skcomplex/systems/economics/innovation/_bass.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def __init__(
    self,
    market: float = 1000.0,
    *,
    adopters: float = 0.0,
    p: float = 0.03,
    q: float = 0.38,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label=label, solver=solver, backend=backend)
    self.market = market
    self.adopters = adopters
    self.p = p
    self.q = q

CccModelSystem(n_entities=100, *, r_plus=5.0, r_minus=10.0, p=0.0002, initial=0.5, random_state=0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

The co-evolving combinatorial critical model.

Its diversity shows punctuated equilibria. Every entity exists or not. Pairs of existing entities produce other entities through the production tensor M+ and destroy them through the destruction tensor M-, random tensors with on average r+ productive and r- destructive sets per entity, fixed during the run. Every step, in random sequential order, an entity exists when its active productive sets outnumber its active destructive ones, disappears in the opposite case, and keeps its state on a tie, and then switches spontaneously with a small probability p (Thurner et al. 2018, Section 5.6.4). The diversity stays nearly constant for long quasi-equilibria, whose lifetimes and the sizes of the changes between them have approximate power laws, and restructures in bursts. Mostly productive tensors fill the system, mostly destructive ones keep it nearly empty, and the punctuated regime lies in between without fine-tuning. The source leaves the initial state open, so every entity exists at the start with the probability initial. With the tensors of this implementation the setting r+ = 10 and r- = 15 of Fig. 5.14 restructures almost every step, so the defaults take r+ = 5 and r- = 10, which is punctuated.

The system has the group entities and the update update, whose reporters are the number of existing entities update.diversity and the entities that changed state in the step update.changes.

Parameters:

Name Type Description Default
n_entities int

The number of entities.

100
r_plus float

The mean number of productive sets per entity.

5.0
r_minus float

The mean number of destructive sets per entity.

10.0
p float

The probability per step that an entity switches its state spontaneously.

0.0002
initial float

The probability that an entity exists at the start.

0.5
random_state int | Generator | None

The seed or generator of the tensors and the initial states.

0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.economics.innovation import CccModelSystem
>>> CccModelSystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/economics/innovation/_ccc.py
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
def __init__(
    self,
    n_entities: int = 100,
    *,
    r_plus: float = 5.0,
    r_minus: float = 10.0,
    p: float = 0.0002,
    initial: float = 0.5,
    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.n_entities = n_entities
    self.r_plus = r_plus
    self.r_minus = r_minus
    self.p = p
    self.initial = initial
    self.random_state = random_state

CombinationInteraction(label, *, target='system')

Bases: Interaction

Growth of the diversity of a combinatorial system by the new entities its pairs produce.

The share of existing entities grows by the adjacent possible, x' = x + d, and the new pairs of existing entities produce the next adjacent possible, d' = r (1 - x') (x'^2 - x^2), at most the share 1 - x' that does not exist yet. The rule density r is a value of the system, the number of productive pairs per entity.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The combinatorial system, with the diversity x, the adjacent possible d, and the rule density r.

'system'

Examples:

>>> from skcomplex.systems.economics.innovation import CombinationInteraction
>>> CombinationInteraction('combination').target
'system'
Source code in src/skcomplex/systems/economics/innovation/_diversity.py
87
88
89
def __init__(self, label: str, *, target: Role = 'system') -> None:
    super().__init__(label)
    self.target = target

CombinatorialEntityElement(label, *, exists=0.0, fitness=0.0, size=None)

Bases: Element

Entity of a combinatorial evolution, which exists or not.

It is a species, a good, or a technology.

Parameters:

Name Type Description Default
label str

The label of the agent or group.

required
exists Annotated[object, closed(0, 1)]

1 when the entity exists, 0 otherwise.

0.0
fitness object

The active productive minus the active destructive sets of the entity at its last update.

0.0
size int | None

The number of entities, or None for one.

None

Examples:

>>> from skcomplex.systems.economics.innovation import CombinatorialEntityElement
>>> CombinatorialEntityElement('entities', size=3).size
3
Source code in src/skcomplex/systems/economics/innovation/_ccc.py
58
59
60
61
62
63
64
65
66
67
68
def __init__(
    self,
    label: str,
    *,
    exists: Annotated[object, RealSet.closed(0, 1)] = 0.0,
    fitness: object = 0.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.exists = exists
    self.fitness = fitness

CombinatorialUpdateInteraction(label, *, rule=None, phase=None, entities, production=(), destruction=(), p=0.0002)

Bases: PolicyRuleInteraction[SystemView]

Random sequential update of the CCC model by the sign of the fitness.

Spontaneous flips are added. Every step every entity i, in random order, computes its fitness f_i = sum_jk (M+_ijk - M-_ijk) sigma_j sigma_k from the current states, exists when it is positive, disappears when it is negative, and keeps its state when it is zero (Eq. 5.61 of Thurner et al. 2018). Then it switches its state with the probability p.

Parameters:

Name Type Description Default
label str

The label of the update.

required
rule None

Unused, since the update overrides act.

None
phase str | None

The phase the update acts in, or None for the default phase.

None
entities Role

The path of the group of entities.

required
production tuple[tuple[int, int, int], ...]

The productive sets, triples (i, j, k) of the nonzero entries of M+.

()
destruction tuple[tuple[int, int, int], ...]

The destructive sets, triples (i, j, k) of the nonzero entries of M-.

()
p Annotated[float, closed(0, 1)]

The probability per step that an entity switches its state spontaneously.

0.0002

Examples:

>>> from skcomplex.systems.economics.innovation import CombinatorialUpdateInteraction
>>> CombinatorialUpdateInteraction('update', entities='entities').reports
('diversity', 'changes')
Source code in src/skcomplex/systems/economics/innovation/_ccc.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
def __init__(
    self,
    label: str,
    *,
    rule: None = None,
    phase: str | None = None,
    entities: Role,
    production: tuple[tuple[int, int, int], ...] = (),
    destruction: tuple[tuple[int, int, int], ...] = (),
    p: Annotated[float, RealSet.closed(0, 1)] = 0.0002,
) -> None:
    super().__init__(label, rule=rule, phase=phase)
    self.entities = entities
    self.production = production
    self.destruction = destruction
    self.p = p

act(system)

Update every entity once in random order.

Parameters:

Name Type Description Default
system SystemView

The system view of the update.

required
Source code in src/skcomplex/systems/economics/innovation/_ccc.py
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
def act(self, system: SystemView) -> None:
    """Update every entity once in random order.

    Args:
        system:
            The system view of the update.
    """
    entities = sorted(
        cast(list[CombinatorialEntityView], system.get_agents('entities')),
        key=lambda entity: entity.id,
    )
    size, rng = len(entities), system.rng
    states = np.array([entity.exists for entity in entities])
    before = states.copy()
    plus, minus = self._get_sets(self.production, size), self._get_sets(self.destruction, size)
    fitness = np.array([entity.fitness for entity in entities])
    flips = rng.random(size) < system.get_parameter('p')
    for entity in rng.permutation(size):
        gain = states[plus[entity][:, 0]] @ states[plus[entity][:, 1]]
        loss = states[minus[entity][:, 0]] @ states[minus[entity][:, 1]]
        fitness[entity] = gain - loss
        if fitness[entity] != 0:
            states[entity] = float(fitness[entity] > 0)
        if flips[entity]:
            states[entity] = 1 - states[entity]
    for entity, state, value in zip(entities, states, fitness, strict=True):
        entity.exists, entity.fitness = float(state), float(value)
    system.report('diversity', float(states.sum()))
    system.report('changes', float(np.sum(states != before)))

CreativePhaseTransitionSystem(x=0.1, *, r=5.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

The diversity of a combinatorial system.

It jumps from sparse to full above a critical rule density. The share of existing entities x grows by the share d of new entities that pairs of existing entities can produce, x_{t+1} = x_t + d_t and d_{t+1} = r (1 - x_{t+1}) (x_{t+1}^2 - x_t^2), with the rule density r. The first step produces d_0 = r x_0^2 (1 - x_0), and no step produces more than the entities that do not exist yet. The final diversity changes discontinuously with r and x_0. The system has the diversity system.x and the adjacent possible system.d.

Parameters:

Name Type Description Default
x float

The initial share of existing entities.

0.1
r float

The rule density, the number of productive pairs per entity.

5.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.economics.innovation import CreativePhaseTransitionSystem
>>> CreativePhaseTransitionSystem(r=2.0).prepare().system_.elements[0].r
2.0
Source code in src/skcomplex/systems/economics/innovation/_diversity.py
146
147
148
149
150
151
152
153
154
155
156
157
def __init__(
    self,
    x: float = 0.1,
    *,
    r: float = 5.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.x = x
    self.r = r

HouseholdElement(label, *, income=1.0, phone=0.0, social_class=float(MIDDLE), growth=0.02, threshold=1.2, size=None, space=None, values=None)

Bases: Element

Household whose income grows every year.

It gets a phone when it can afford one and a neighbour has one.

Parameters:

Name Type Description Default
label str

The label of the agent or group.

required
income Annotated[object, closed_open(0, oo)]

The initial income, relative to the mean income at the start.

1.0
phone Annotated[object, NN]

1 for a household with a phone and 0 otherwise.

0.0
social_class Annotated[object, NN]

0 for the upper, 1 for the middle, and 2 for the lower class.

float(MIDDLE)
growth object

The yearly growth rate of the income.

0.02
threshold Annotated[object, closed_open(0, oo)]

The income from which a household can afford a phone.

1.2
size int | None

The number of households, or None for one.

None
space BaseSpace | None

The space the households live on, or None for none.

None
values Mapping[str, object] | None

More values by name, such as the cells x and y of the households on a lattice, or None for none.

None

Examples:

>>> from skcomplex.systems.economics.innovation import HouseholdElement
>>> HouseholdElement('households', threshold=1.5, size=4).size
4
Source code in src/skcomplex/systems/economics/innovation/_adoption.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
def __init__(
    self,
    label: str,
    *,
    income: Annotated[object, RealSet.closed_open(0, oo)] = 1.0,
    phone: Annotated[object, NN] = 0.0,
    social_class: Annotated[object, NN] = float(MIDDLE),
    growth: object = 0.02,
    threshold: Annotated[object, RealSet.closed_open(0, oo)] = 1.2,
    size: int | None = None,
    space: BaseSpace | None = None,
    values: Mapping[str, object] | None = None,
) -> None:
    super().__init__(label, values=values, size=size, space=space)
    self.income = income
    self.phone = phone
    self.social_class = social_class
    self.growth = growth
    self.threshold = threshold

InteractingUrnsNetworkSystem(graph=None, *, rho=4, nu=1, m0=None, label='system', solver='auto', backend='auto')

Bases: BaseSystem

One urn with triggering per node of a network.

Every node draws from its own urn and those of its neighbours. The discovery process of Iacopini et al. (2020, Eqs. 1 and 2). Every node holds an urn of m0 balls of colours that no other urn holds. Every step every node draws one ball from its social urn, its own urn and one ball of every colour of the urns of its neighbours, all from the urns at the start of the step. It then adds rho balls of the drawn colour to its own urn, and when it draws a colour for the first time, a novelty, nu + 1 balls of colours that no urn held before. The number of novelties of a node grows as Heaps' law D_i(t) ~ t^beta_i, with beta = nu / rho for an isolated urn and higher exponents for nodes whose neighbours enlarge their social urns.

The urn of a node is the set of ball agents of the variable group balls on its node, one agent per colour with its multiplicity, which the node reads with agents_here and its neighbours with neighbors(group='balls'). The system has the urns urns and their novelties urns.novelties, and the balls balls.

Parameters:

Name Type Description Default
graph Graph | None

The NetworkX graph of the explorers, or None for Zachary's karate club.

None
rho int

The reinforcement, the balls of the drawn colour added after every draw.

4
nu int

The triggering, one less than the colours added after a novelty.

1
m0 int | None

The initial number of balls of every urn, or None for nu + 1.

None
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> import networkx as nx
>>> from skcomplex.systems.economics.innovation import InteractingUrnsNetworkSystem
>>> system = InteractingUrnsNetworkSystem(nx.path_graph(3), rho=2, nu=1).prepare().system_
>>> [element.size for element in system.elements]
[3, 6]
Source code in src/skcomplex/systems/economics/innovation/_discovery.py
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
def __init__(
    self,
    graph: nx.Graph | None = None,
    *,
    rho: int = 4,
    nu: int = 1,
    m0: int | None = None,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.graph = graph
    self.rho = rho
    self.nu = nu
    self.m0 = m0

InventionInteraction(label, *, technologies, max_components=12, max_inputs=3)

Bases: Interaction

Random wiring of technologies of the pool into a circuit.

The circuit is kept if it computes a wanted function more cheaply. A circuit has between one and max_inputs inputs and wires between two and max_components technologies in a row, each pin to an input or to the output of an earlier technology. The output of the last one is the circuit's output. A circuit that computes a wanted function joins the pool, or replaces the technology of that function when it uses fewer NAND gates.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
technologies Role

The path of the group of technologies.

required
max_components Annotated[float, open(0, oo)]

The largest number of technologies in a circuit.

12
max_inputs Annotated[float, open(0, oo)]

The largest number of inputs of a circuit.

3

Examples:

>>> from skcomplex.systems.economics.innovation import InventionInteraction
>>> InventionInteraction('invention', technologies='technologies', max_components=6).max_components
6
Source code in src/skcomplex/systems/economics/innovation/_technology.py
136
137
138
139
140
141
142
143
144
145
146
147
def __init__(
    self,
    label: str,
    *,
    technologies: Role,
    max_components: Annotated[float, RealSet.open(0, oo)] = 12,
    max_inputs: Annotated[float, RealSet.open(0, oo)] = 3,
) -> None:
    super().__init__(label)
    self.technologies = technologies
    self.max_components = max_components
    self.max_inputs = max_inputs

invent(system)

Wire a random circuit and add it to the pool if it is better.

It is better when it computes a wanted function better.

Parameters:

Name Type Description Default
system SystemView

The system.

required
Source code in src/skcomplex/systems/economics/innovation/_technology.py
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
def invent(self, system: SystemView) -> None:
    """Wire a random circuit and add it to the pool if it is better.

    It is better when it computes a wanted function better.

    Args:
        system:
            The system.
    """
    pool = cast(list[TechnologyView], system.get_agents('technologies'))
    arity, table, cost = self._wire(pool, system)
    if (arity, table) not in GOALS:
        return
    known = [technology for technology in pool if (technology.arity, technology.table) == (arity, table)]
    if not known:
        system.create('technologies', arity=arity, table=table, cost=cost)
    elif cost < known[0].cost:
        known[0].cost = cost

NkTechnologySystem(n_components=10, d=2, *, random_state=0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

McNerney's system of technological improvement.

Its cost falls as a power of the cumulative production. Every step is one unit of production and one attempt to redesign a random component together with the components that depend on it. Redesigns are kept only when they cut the total cost, which falls like Wright's law, more slowly for designs whose components depend on more others. The system has the group components and the total cost total_cost.

Parameters:

Name Type Description Default
n_components int

The number of components.

10
d int

The number of components that a redesign of one component changes, itself included.

2
random_state int | Generator | None

The seed or generator of the design structure matrix and the initial costs.

0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.economics.innovation import NkTechnologySystem
>>> NkTechnologySystem(5, 1).prepare().system_.interactions[0].dependencies[0]
(1.0, 0.0, 0.0, 0.0, 0.0)
Source code in src/skcomplex/systems/economics/innovation/_technology.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
def __init__(
    self,
    n_components: int = 10,
    d: int = 2,
    *,
    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.n_components = n_components
    self.d = d
    self.random_state = random_state

PartElement(label, *, cost=1.0, size=None)

Bases: Element

PartElement of a technology, described by its unit cost.

Parameters:

Name Type Description Default
label str

The label of the agent or group.

required
cost Annotated[object, closed_open(0, oo)]

The initial unit cost.

1.0
size int | None

The number of members, or None for one.

None

Examples:

>>> from skcomplex.systems.economics.innovation import PartElement
>>> PartElement('components', cost=0.5, size=5).size
5
Source code in src/skcomplex/systems/economics/innovation/_technology.py
69
70
71
72
73
74
75
76
77
def __init__(
    self,
    label: str,
    *,
    cost: Annotated[object, RealSet.closed_open(0, oo)] = 1.0,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.cost = cost

PhoneAdoptionSystem(shape=(30, 30), *, growth=0.02, threshold=1.2, initial_share=0.1, class_incomes=(1.6, 1.0, 0.6), random_state=0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Hamill and Gilbert's adoption of fixed-line phones by British households.

The adoption starts from 1951. One household lives in every cell of a torus. The upper class lives in the top left quadrant, the lower class in the bottom left, and the middle class elsewhere, so neighbours tend to be alike. Incomes are lognormal, scaled by class and normalised to a mean of 1, and grow every year. A household gets a phone once its income reaches the threshold and one of its eight neighbours has a phone. Households decide one after the other in a new random order every year, so phones spread along chains of affording neighbours within a year. The first owners are a cluster of affording households grown from the richest upper-class household.

The system has the group households and the share of households with a phone share.

Parameters:

Name Type Description Default
shape Sequence[int]

The number of columns and rows.

(30, 30)
growth float

The yearly growth rate of incomes.

0.02
threshold float

The income from which a household can afford a phone.

1.2
initial_share float

The share of households with a phone at the start.

0.1
class_incomes Sequence[float]

The income scale of the upper, middle, and lower classes.

(1.6, 1.0, 0.6)
random_state int | Generator | None

The seed or generator of the incomes.

0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.economics.innovation import PhoneAdoptionSystem
>>> PhoneAdoptionSystem((10, 10)).prepare().system_.elements[0].size
100
Source code in src/skcomplex/systems/economics/innovation/_adoption.py
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
def __init__(
    self,
    shape: Sequence[int] = (30, 30),
    *,
    growth: float = 0.02,
    threshold: float = 1.2,
    initial_share: float = 0.1,
    class_incomes: Sequence[float] = (1.6, 1.0, 0.6),
    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.shape = shape
    self.growth = growth
    self.threshold = threshold
    self.initial_share = initial_share
    self.class_incomes = class_incomes
    self.random_state = random_state

RedesignInteraction(label, *, components, dependencies=())

Bases: Interaction

Attempt to cut the cost of a technology by redesigning its components.

It redesigns a random component and the components that depend on it. The redesigned components get new costs drawn uniformly from [0, 1], and the redesign is kept only if the total cost falls. dependencies[i][j] is 1 when a change of component j requires a change of component i.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
components Role

The path of the group of components.

required
dependencies Sequence[Sequence[float]]

The design structure matrix.

()

Examples:

>>> from skcomplex.systems.economics.innovation import RedesignInteraction
>>> RedesignInteraction('redesign', components='components', dependencies=[[1.0]]).dependencies
[[1.0]]
Source code in src/skcomplex/systems/economics/innovation/_technology.py
240
241
242
243
244
245
246
247
248
249
def __init__(
    self,
    label: str,
    *,
    components: Role,
    dependencies: Sequence[Sequence[float]] = (),
) -> None:
    super().__init__(label)
    self.components = components
    self.dependencies = dependencies

redesign(system)

Propose new costs for a random component and its dependents.

They are kept if the total cost falls.

Parameters:

Name Type Description Default
system SystemView

The system.

required
Source code in src/skcomplex/systems/economics/innovation/_technology.py
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
def redesign(self, system: SystemView) -> None:
    """Propose new costs for a random component and its dependents.

    They are kept if the total cost falls.

    Args:
        system:
            The system.
    """
    components = sorted(cast(list[PartView], system.get_agents('components')), key=lambda component: component.id)
    cost = np.array([component.cost for component in components])
    proposal, changed = RedesignInteraction._get_components(
        cost,
        np.asarray(self.dependencies, dtype=float),
        system.rng,
    )
    if proposal.sum() >= cost.sum():
        return
    for index in changed:
        components[index].cost = float(proposal[index])

TapCatalysisSystem(m0=10, *, parents=4, alpha=0.01, goods=1250, pc=0.0044, label='system', solver='auto', backend='auto')

Bases: BaseSystem

The TAP growth of goods from combinations of goods.

Their production functions are catalysed at random. The TAP model with catalysis of Hordijk and Kauffman (2022, Algorithm 1), in continuous time. From m0 goods, new goods made from i parents drawn uniformly among the M goods appear at the rate alpha^i C(M, i), for every i up to parents, until there are goods goods. The production function of a new good is a hyperedge of its parents and the good, its last member. A new good catalyses the production of every other good, and every other good catalyses its production, each with the probability pc, as directed edges from the catalyst to the good. Algorithm 1 draws a Poisson number of goods of every order per step from the rates at its start, and the process here draws them one at a time from the rates at that time. The initial goods are the food set, and autocatalytic_sets finds the largest autocatalytic set of the production functions, which exists in about half the runs at pc = 0.0044 and then tends to hold most of the network.

The system has the goods goods, the catalysis catalysis, and the production functions functions.

Parameters:

Name Type Description Default
m0 int

The number of initial goods, the food set.

10
parents int

The largest number of parents of a good, K.

4
alpha float

The base of the probabilities alpha^i that a combination of i goods makes a new one.

0.01
goods int

The number of goods at which the growth stops, M.

1250
pc float

The catalysis probability.

0.0044
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.economics.innovation import TapCatalysisSystem
>>> [element.label for element in TapCatalysisSystem(goods=50).prepare().system_.elements]
['goods', 'catalysis', 'functions']
Source code in src/skcomplex/systems/economics/innovation/_catalysis.py
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def __init__(
    self,
    m0: int = 10,
    *,
    parents: int = 4,
    alpha: float = 0.01,
    goods: int = 1250,
    pc: float = 0.0044,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.m0 = m0
    self.parents = parents
    self.alpha = alpha
    self.goods = goods
    self.pc = pc

TechnologyElement(label, *, arity=2, table=NAND[1], cost=1, size=None)

Bases: Element

Logic circuit in the pool of technologies.

It is described by the truth table of the function it computes. Bit r of the table is the output on the inputs whose bits form r, with the first input as the lowest bit.

Parameters:

Name Type Description Default
label str

The label of the agent or group.

required
arity Annotated[object, NN]

The number of inputs.

2
table Annotated[object, NN]

The truth table.

NAND[1]
cost Annotated[object, NN]

The number of NAND gates in the circuit.

1
size int | None

The number of members, or None for one.

None

Examples:

>>> from skcomplex.systems.economics.innovation import TechnologyElement
>>> TechnologyElement('technologies', arity=[2, 0, 0], table=[7, 0, 1], size=3).size
3
Source code in src/skcomplex/systems/economics/innovation/_technology.py
326
327
328
329
330
331
332
333
334
335
336
337
338
def __init__(
    self,
    label: str,
    *,
    arity: Annotated[object, NN] = 2,
    table: Annotated[object, NN] = NAND[1],
    cost: Annotated[object, NN] = 1,
    size: int | None = None,
) -> None:
    super().__init__(label, size=size)
    self.arity = arity
    self.table = table
    self.cost = cost

TriggeringInteraction(label, *, target='urns', balls=BALLS)

Bases: Interaction

Draws of urns with triggering from their social urns, and the growth of their own urns.

Every step every node draws one ball from its social urn, its own balls with their multiplicities and one ball of every colour in the urns of its neighbours, in the phase 'draw'. In the phase 'grow' it adds rho balls of the drawn colour to its own urn, and when it draws the colour for the first time, a novelty, it adds one ball of each of nu + 1 colours that no urn held before, the adjacent possible.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The urns that draw.

'urns'
balls Role

The balls of every urn.

BALLS

Examples:

>>> from skcomplex.systems.economics.innovation import TriggeringInteraction
>>> TriggeringInteraction('triggering').balls
'balls'
Source code in src/skcomplex/systems/economics/innovation/_discovery.py
201
202
203
204
def __init__(self, label: str, *, target: Role = 'urns', balls: Role = BALLS) -> None:
    super().__init__(label)
    self.target = target
    self.balls = balls

draw(agent, system) staticmethod

Draw a ball from the social urn of the node.

It records its colour and whether it is a novelty.

Parameters:

Name Type Description Default
agent UrnView

The view of the urn.

required
system SystemView

The view of the system.

required
Source code in src/skcomplex/systems/economics/innovation/_discovery.py
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
@staticmethod
def draw(agent: UrnView, system: SystemView) -> None:
    """Draw a ball from the social urn of the node.

    It records its colour and whether it is a novelty.

    Args:
        agent:
            The view of the urn.

        system:
            The view of the system.
    """
    own = [ball for ball in agent.get_agents_here(BALLS) if isinstance(ball, BallView)]
    social = [ball for ball in agent.get_neighbors(group=BALLS) if isinstance(ball, BallView)]
    colors = [ball.color for ball in own] + [ball.color for ball in social]
    weights = np.asarray([ball.count for ball in own] + [1.0] * len(social), dtype=float)
    if not colors:
        return
    chosen = colors[int(system.rng.choice(len(colors), p=weights / weights.sum()))]
    agent.color = chosen
    agent.novel = float(not any(ball.color == chosen and ball.drawn for ball in own))

grow(agent, system) staticmethod

Reinforce the drawn colour in the own urn.

After a novelty, it adds the colours of the adjacent possible.

Parameters:

Name Type Description Default
agent UrnView

The view of the urn.

required
system SystemView

The view of the system.

required
Source code in src/skcomplex/systems/economics/innovation/_discovery.py
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
@staticmethod
def grow(agent: UrnView, system: SystemView) -> None:
    """Reinforce the drawn colour in the own urn.

    After a novelty, it adds the colours of the adjacent possible.

    Args:
        agent:
            The view of the urn.

        system:
            The view of the system.
    """
    if agent.color < 0:
        return
    rho, nu = agent.rho, agent.nu
    own = [ball for ball in agent.get_agents_here(BALLS) if isinstance(ball, BallView)]
    ball = next((ball for ball in own if ball.color == agent.color), None)
    if ball is None:
        agent.create(BALLS, color=agent.color, count=rho, drawn=1)
    else:
        ball.count += rho
        ball.drawn = 1
    if not agent.novel:
        return
    agent.novelties += 1
    stored = system.storage.get('colors')
    first = (
        stored
        if isinstance(stored, int)
        else int(max(item.color for item in cast(list[BallView], system.get_agents(BALLS)))) + 1
    )
    for color in range(first, first + int(nu) + 1):
        agent.create(BALLS, color=color, count=1, drawn=0)
    system.storage['colors'] = first + int(nu) + 1

UrnElement(label, *, novelties=0, color=-1, novel=0, rho=4, nu=1, values=None, size=None, space=None)

Bases: Element

Urn with triggering on a node of a network.

It draws from its own balls and those of its neighbours by TriggeringInteraction. The urn of the interacting discovery processes of Iacopini et al. (2020). The urn of a node is the set of ball agents on its node.

Parameters:

Name Type Description Default
label str

The label of the agent or group.

required
novelties Annotated[object, NN]

The number of distinct colours the node has drawn, D_i(t).

0
color object

The colour of the last draw.

-1
novel Annotated[object, NN]

1 when the last draw was a novelty, and 0 when it was not.

0
rho Annotated[object, NN]

The reinforcement, the balls of the drawn colour added after every draw.

4
nu Annotated[object, NN]

The triggering, one less than the colours added after a novelty.

1
values Mapping[str, object] | None

Further values by name, such as the node node of each member on the network.

None
size int | None

The number of urns, or None for one.

None
space BaseSpace | None

The network the urns live on, whose axis node places them, or None.

None

Examples:

>>> from skcomplex.systems.economics.innovation import UrnElement
>>> UrnElement('urns', rho=4, nu=2).nu
2
Source code in src/skcomplex/systems/economics/innovation/_discovery.py
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
def __init__(
    self,
    label: str,
    *,
    novelties: Annotated[object, NN] = 0,
    color: object = -1,
    novel: Annotated[object, NN] = 0,
    rho: Annotated[object, NN] = 4,
    nu: Annotated[object, NN] = 1,
    values: Mapping[str, object] | None = None,
    size: int | None = None,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, values=values, size=size, space=space)
    self.novelties = novelties
    self.color = color
    self.novel = novel
    self.rho = rho
    self.nu = nu