Cooperation
Cooperation: evolutionary games between neighbours, in hyperedges, in tournaments, and between groups.
ContributorElement(label, visual=None, *, strategy=1.0, payoff=0.0, synergy=4.5, noise=0.5)
Bases: Element
Player of the spatial public goods game, a cooperator at 1 and a defector at 0, with its payoff.
The play is a PublicGoodsInteraction of the lattice or a HyperedgeGoodsInteraction of a hypergraph, and the
imitation an ImitationInteraction that reads the payoffs of the same step, which public_goods_game and
hypergraph_public_goods add.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the player or the lattice group. |
required |
visual
|
VisualSpec | None
|
How the agent is drawn, or |
None
|
strategy
|
Annotated[float, StateSpec(domain=FiniteEnumeratedSet([0, 1]))]
|
The initial strategy, 1 or 0. |
1.0
|
payoff
|
Annotated[float, StateSpec()]
|
The payoff of the last play, the sum of the shares of its groups minus its contributions. |
0.0
|
synergy
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The factor that multiplies the contributions of a group. |
4.5
|
noise
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The noise of the Fermi imitation. |
0.5
|
Examples:
>>> from skcomplex.systems.social.cooperation import ContributorElement
>>> ContributorElement('player').synergy
4.5
Source code in src/skcomplex/systems/social/cooperation/_contributor.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
DilemmaElement(label, visual=None, *, strategy=1.0, payoff=0.0, triangles=1.0)
Bases: Element
Player of the social dilemmas on a simplicial complex, a cooperator at 1 and a defector at 0, with its payoff.
The play is a SimplicialDilemmaInteraction of the network, and the imitation an ImitationInteraction that
reads the payoffs of the same step, which simplicial_social_dilemmas adds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the player or the group. |
required |
visual
|
VisualSpec | None
|
How the player is drawn, or |
None
|
strategy
|
Annotated[float, StateSpec(domain=FiniteEnumeratedSet([0, 1]))]
|
The initial strategy, 1 or 0. |
1.0
|
payoff
|
Annotated[float, StateSpec()]
|
The payoff of the last play, the mean payoff of the player over the links of its triangles. |
0.0
|
triangles
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The number of triangles of the network that hold the player. |
1.0
|
Examples:
>>> from skcomplex.systems.social.cooperation import DilemmaElement
>>> DilemmaElement('player').triangles
1.0
Source code in src/skcomplex/systems/social/cooperation/_hypergraph_games.py
56 57 58 59 60 61 62 63 64 65 66 67 68 | |
DonorElement(label, visual=VisualSpec('agents', {'color_by': 'strategy', 'color_range': (0.0, 1.0)}), *, strategy=1.0, payoff=0.0)
Bases: Element
Player of donation games on the edges of a graph, a cooperator at 1 and a defector at 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the player or the group. |
required |
visual
|
VisualSpec | None
|
How the agent is drawn, or |
VisualSpec('agents', {'color_by': 'strategy', 'color_range': (0.0, 1.0)})
|
strategy
|
Annotated[float, StateSpec(domain=FiniteEnumeratedSet([0, 1]))]
|
The strategy, 1 to cooperate and 0 to defect. |
1.0
|
payoff
|
Annotated[float, StateSpec()]
|
The payoff accumulated over the games with every neighbour in the last time step. |
0.0
|
Examples:
>>> from skcomplex.systems.social.cooperation import DonorElement
>>> DonorElement('player').strategy
1.0
Source code in src/skcomplex/systems/social/cooperation/_game_transitions.py
60 61 62 63 64 65 66 67 68 69 70 | |
DonorView(agent, stepper)
Bases: AgentView
View of a player of the game transitions system, with its states as attributes.
Source code in src/skcomplex/core/engine/solvers/_mesa.py
559 560 561 | |
GameTransitionsInteraction(label, *, target, first_benefit=3.5, second_benefit=2.6, cost=1.0, selection=0.1, after_cooperation=0.0, after_defection=1.0, transitions=True, update='death-birth')
Bases: Interaction
Evolutionary dynamics with game transitions, where the game on every edge follows the actions played on it.
Every edge of the graph carries game 1 or game 2, donation games where a cooperator pays c to give its partner
b1 or b2, and every edge starts with game 1. In every time step every player plays the game of every edge with
its neighbour and accumulates the payoff pi, of fitness 1 - delta + delta pi. Under death-birth updating a
uniformly drawn player dies and its neighbours compete for the site in proportion to their fitness, and under
pairwise comparison a uniformly drawn player copies a random neighbour with the probability
1 / (1 + exp(-delta (pi_j - pi_i))). The games then change: an edge goes to game 2 with the probability
after_cooperation after mutual cooperation, with after_defection after one defection, and surely after mutual
defection, and to game 1 otherwise. The newcomer of a site plays the games of its prior occupant. Every step of the
system has one time step per player, and the share of edges with game 1 is reported as game_one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the group of players on the nodes of a network. |
required |
first_benefit
|
Annotated[float, ParameterSpec()]
|
The benefit |
3.5
|
second_benefit
|
Annotated[float, ParameterSpec()]
|
The benefit |
2.6
|
cost
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The cost |
1.0
|
selection
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The intensity |
0.1
|
after_cooperation
|
Annotated[float, ParameterSpec(domain=closed(0, 1))]
|
The probability |
0.0
|
after_defection
|
Annotated[float, ParameterSpec(domain=closed(0, 1))]
|
The probability |
1.0
|
transitions
|
bool
|
Whether the games change, or every edge plays game 1 throughout. |
True
|
update
|
str
|
|
'death-birth'
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The update is unknown, raised by |
Examples:
>>> from skcomplex.systems.social.cooperation import GameTransitionsInteraction
>>> GameTransitionsInteraction('evolution', target='players').update
'death-birth'
Source code in src/skcomplex/systems/social/cooperation/_game_transitions.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 | |
evolve(system)
Run one time step per player: play the games, replace one player, and change the games.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/cooperation/_game_transitions.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
HyperedgeGoodsInteraction(label, *, target, phase=None)
Bases: CouplingInteraction
Play of the public goods game in every hyperedge around a player, which sets the payoffs.
It is a CouplingInteraction over the hyperedges of a network in the map form, a cooperator at 1 and a defector
at 0. In every hyperedge of m members a cooperator pays 1, and the pot multiplied by synergy is shared by the
m members, so the payoff of a player is the sum over its hyperedges of its share minus its contribution. The
synergy is a parameter of the players.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the players on the network. |
required |
phase
|
str | None
|
The phase of the step the play runs in, or |
None
|
Examples:
>>> from skcomplex.systems.social.cooperation import HyperedgeGoodsInteraction
>>> HyperedgeGoodsInteraction('play', target='players').write
'payoff'
Source code in src/skcomplex/systems/social/cooperation/_hypergraph_games.py
95 96 97 98 99 100 101 102 103 104 | |
IteratedDilemmaInteraction(label, *, target)
Bases: LocalRuleInteraction
Play of the iterated prisoner's dilemma between neighbours, revision to the best strategy, and mutation.
It is a stochastic LocalRuleInteraction of the strategies over the cells within two von Neumann steps of a
player. Every step each player plays the N-round prisoner's dilemma with its four von Neumann neighbours and sums
its years in prison. A player of strategy n against one of strategy m < n gets m R + S + (N - m - 1) P, the
other m R + T + (N - m - 1) P, and two players of strategy n get n R + (N - n) P. Every player then adopts
the strategy of the lowest score among itself and its four neighbours, a random one of them on ties, and finally
mutates to a uniformly drawn strategy with the probability mu.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the players on the lattice. |
required |
Examples:
>>> from skcomplex.systems.social.cooperation import IteratedDilemmaInteraction
>>> IteratedDilemmaInteraction('play', target='players').state
'strategy'
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
180 181 | |
years(own, other, *, rounds, reward, sucker, temptation, punishment)
staticmethod
Return the years in prison of a player of strategy n against one of strategy m in an N-round game.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
own
|
Array
|
The strategies |
required |
other
|
Array
|
The strategies |
required |
rounds
|
float | Array
|
The number |
required |
reward
|
float | Array
|
The punishment |
required |
sucker
|
float | Array
|
The punishment |
required |
temptation
|
float | Array
|
The punishment |
required |
punishment
|
float | Array
|
The punishment |
required |
Returns:
| Name | Type | Description |
|---|---|---|
years |
Array
|
The years in prison of every player. |
Examples:
>>> import numpy as np
>>> from skcomplex.systems.social.cooperation import IteratedDilemmaInteraction
>>> years = IteratedDilemmaInteraction.years(
... np.arange(11.0), np.full(11, 6.0), rounds=10, reward=0.5, sucker=1.5, temptation=0.0, punishment=1.0
... )
>>> int(np.argmin(years))
5
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | |
IteratedPrisonerElement(label, visual=None, *, strategy=0.0, rounds=7, reward=0.72, sucker=1.5, temptation=0.0, punishment=1.0, mutation=0.01, extremes=0.0)
Bases: Element
Player of the lattice iterated prisoner's dilemma, who cooperates for a number of rounds and then defects.
The strategy n of a player is the number of rounds it intends to cooperate, until round n included or until its
opponent defects, after which it defects for the rest of the game. The payoffs are years in prison, so lower is
better. The play, the revision, and the mutation are an IteratedDilemmaInteraction of the lattice, which
iterated_lattice_dilemma adds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the player or the lattice group. |
required |
visual
|
VisualSpec | None
|
How the agent is drawn, or |
None
|
strategy
|
Annotated[float, StateSpec(domain=NN)]
|
The number |
0.0
|
rounds
|
Annotated[int, ParameterSpec(domain=NN)]
|
The number |
7
|
reward
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The punishment |
0.72
|
sucker
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The punishment |
1.5
|
temptation
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The punishment |
0.0
|
punishment
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The punishment |
1.0
|
mutation
|
Annotated[float, ParameterSpec(domain=closed(0, 1))]
|
The probability |
0.01
|
extremes
|
Annotated[float, ParameterSpec(domain=closed(0, 1))]
|
1 to allow only the strategies |
0.0
|
Examples:
>>> from skcomplex.systems.social.cooperation import IteratedPrisonerElement
>>> IteratedPrisonerElement('player').rounds
7
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
PrisonerElement(label, visual=None, *, strategy=1.0, temptation=1.85, noise=0.1)
Bases: Element
Player of the spatial prisoner's dilemma, a cooperator at 1 and a defector at 0.
The play and the imitation are a PrisonersDilemmaInteraction of the lattice, which spatial_prisoners_dilemma
adds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the player or the lattice group. |
required |
visual
|
VisualSpec | None
|
How the agent is drawn, or |
None
|
strategy
|
Annotated[float, StateSpec(domain=FiniteEnumeratedSet([0, 1]))]
|
The initial strategy, 1 or 0. |
1.0
|
temptation
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The payoff of a defector against a cooperator. |
1.85
|
noise
|
Annotated[float, ParameterSpec(domain=open(0, oo))]
|
The noise of the Fermi imitation. |
0.1
|
Examples:
>>> from skcomplex.systems.social.cooperation import PrisonerElement
>>> PrisonerElement('player').temptation
1.85
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
125 126 127 128 129 130 131 132 133 134 135 136 137 | |
PrisonersDilemmaInteraction(label, *, target, imitation='best')
Bases: LocalRuleInteraction
Play of the weak prisoner's dilemma between neighbours, and imitation of more successful neighbours.
It is a stochastic LocalRuleInteraction of the strategies over the 5 by 5 square around a player, a cooperator
at 1 and a defector at 0. Every step each player plays the weak dilemma, with reward 1, temptation temptation,
and 0 otherwise, against itself and its eight neighbours. It then copies the best player among them, or a random
neighbour with the Fermi probability 1 / (1 + exp((P_own - P_other) / noise)). The temptation and the noise are
parameters of the players.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the players on the lattice. |
required |
imitation
|
str
|
|
'best'
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The imitation is unknown, raised by |
Examples:
>>> from skcomplex.systems.social.cooperation import PrisonersDilemmaInteraction
>>> PrisonersDilemmaInteraction('play', target='players', imitation='fermi').imitation
'fermi'
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
323 324 325 | |
PublicGoodsInteraction(label, *, target, phase=None)
Bases: GroupingInteraction
Play of the public goods game in the groups of a player and its four neighbours, which sets the payoffs.
It is a symbolic GroupingInteraction of the von Neumann neighbourhoods of a lattice, a cooperator at 1 and a
defector at 0. Every player joins five groups, the one centred on itself and those centred on its four neighbours.
In each group a cooperator pays 1, and the pot multiplied by synergy is shared by the members, so the payoff of a
player is the sum of its shares minus its contributions. The synergy is a parameter of the players.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the players on the lattice. |
required |
phase
|
str | None
|
The phase of the step the play runs in, or |
None
|
Examples:
>>> from skcomplex.systems.social.cooperation import PublicGoodsInteraction
>>> PublicGoodsInteraction('play', target='players').write
'payoff'
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
419 420 421 422 423 424 425 426 427 428 | |
PunisherGroupElement(label, visual=None, *, punishers=0.0)
Bases: Element
Group of defectors and altruistic punishers of a fixed size, held by its number of punishers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the group or the population of groups. |
required |
visual
|
VisualSpec | None
|
How the agent is drawn, or |
None
|
punishers
|
Annotated[float, StateSpec(domain=NN)]
|
The number of altruistic punishers of the group. |
0.0
|
Examples:
>>> from skcomplex.systems.social.cooperation import PunisherGroupElement
>>> PunisherGroupElement('group', punishers=3.0).punishers
3.0
Source code in src/skcomplex/systems/social/cooperation/_two_level_birth_death.py
51 52 53 54 55 56 57 58 59 | |
PunisherGroupView(agent, stepper)
Bases: AgentView
View of a group of the two-level birth-death process, with its states as attributes.
Source code in src/skcomplex/core/engine/solvers/_mesa.py
559 560 561 | |
SimplicialDilemmaInteraction(label, *, target, sucker=-0.2, temptation=1.2, sucker_allied=0.5, temptation_allied=0.8, sucker_opposed=-0.2, temptation_opposed=1.2, phase=None)
Bases: CouplingInteraction
Play of two-player games along the links of the triangles of a simplicial complex, which sets the payoffs.
It is a CouplingInteraction over the hyperedges of a network in the map form, a cooperator at 1 and a defector
at 0. Every game pays 1 for mutual cooperation, 0 for mutual defection, and the sucker's payoff S and the
temptation T when the strategies differ. A triangle of three links is three hyperedges of two members, along
which the players play game 1 of S1 and T1. A triangle filled as a 2-simplex is one hyperedge of three members,
where a player plays each other member while the third looks on: game 2 of S2 and T2 when the third member
shares the player's strategy, and game 3 of S3 and T3 otherwise. The payoff of a player is the sum over the two
links of every triangle around it divided by twice its number of triangles, a parameter of the players.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the players on the network. |
required |
sucker
|
Annotated[float, ParameterSpec()]
|
The payoff |
-0.2
|
temptation
|
Annotated[float, ParameterSpec()]
|
The payoff |
1.2
|
sucker_allied
|
Annotated[float, ParameterSpec()]
|
The payoff |
0.5
|
temptation_allied
|
Annotated[float, ParameterSpec()]
|
The payoff |
0.8
|
sucker_opposed
|
Annotated[float, ParameterSpec()]
|
The payoff |
-0.2
|
temptation_opposed
|
Annotated[float, ParameterSpec()]
|
The payoff |
1.2
|
phase
|
str | None
|
The phase of the step the play runs in, or |
None
|
Examples:
>>> from skcomplex.systems.social.cooperation import SimplicialDilemmaInteraction
>>> SimplicialDilemmaInteraction('play', target='players', temptation_allied=0.8).temptation_allied
0.8
Source code in src/skcomplex/systems/social/cooperation/_hypergraph_games.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
StrategistElement(label, visual=None, *, genome=1.0, fitness=0.0)
Bases: Element
Agent of the prisoner's dilemma tournament, with a genome of responses and the fitness of its last games.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
visual
|
VisualSpec | None
|
How the agent is drawn, or |
None
|
genome
|
Annotated[ArrayLike, StateSpec(vector=True)]
|
The seven moves, 1 to cooperate and 0 to defect, for the opponent's last two moves: none, C, D, CC, CD, DC, and DD. |
1.0
|
fitness
|
Annotated[float, StateSpec(domain=closed_open(0, oo))]
|
The mean score per round of the last tournament. |
0.0
|
Examples:
>>> from skcomplex.core.components.elements import GroupElement
>>> from skcomplex.systems.social.cooperation import StrategistElement
>>> group = GroupElement('agents', element=StrategistElement, size=10, values={'genome': [1.0] * 7})
>>> group.label, group.element.__name__, group.size
('agents', 'StrategistElement', 10)
Source code in src/skcomplex/systems/social/cooperation/_tournaments.py
55 56 57 58 59 60 61 62 63 64 65 | |
StrategistView(agent, stepper)
Bases: AgentView
View of a strategist of the iterated prisoner's dilemma, with its states as attributes.
Source code in src/skcomplex/core/engine/solvers/_mesa.py
559 560 561 | |
TournamentInteraction(label, *, target, rounds=6, phase=None)
Bases: GroupingInteraction
Tournament of strategies of the iterated prisoner's dilemma.
Every step the agents stand in a random ring, and every agent forms a group with its two neighbours in the ring, whom it plays. Its fitness is its mean score per round.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the group of strategists. |
required |
rounds
|
int
|
The number of rounds of every game. |
6
|
phase
|
str | None
|
The phase of the step the tournament runs in, or |
None
|
Examples:
>>> from skcomplex.systems.social.cooperation import TournamentInteraction
>>> TournamentInteraction('tournament', target='agents').rounds
6
Source code in src/skcomplex/systems/social/cooperation/_tournaments.py
152 153 154 155 156 157 158 159 160 161 | |
act_on(members, system)
Set the fitness of the first member to its mean score per round against the two others.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
members
|
list[AgentViewProtocol]
|
The agent, followed by its two neighbours in the ring. |
required |
system
|
SystemViewProtocol
|
The system view of the rule. |
required |
Source code in src/skcomplex/systems/social/cooperation/_tournaments.py
171 172 173 174 175 176 177 178 179 180 181 182 183 | |
TwoLevelBirthDeathInteraction(label, *, target, members=20, selection=0.1, conflict_rate=0.2, benefit=2.0, cost=1.0, punishment=0.5, interaction_cost=0.5, fixed_cost=0.0)
Bases: Interaction
Two-level birth-death process of Luo and coauthors with pairwise conflicts between groups.
Within a group of n members with i punishers, a punisher reproduces at the rate 1 + w pi_P(i / n) and a
defector at 1 + w pi_D(i / n), and the offspring replaces a random member of the group, the parent included.
Every group fights a randomly drawn other group at the rate Lambda, wins with the probability
rho = 1/2 + (z - u) / 2 of the fractions of punishers, and the winner's copy replaces the loser. The events of
every step of one unit of time are drawn exactly, by the Gillespie algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Annotated[str, RoleSpec()]
|
The path of the population of groups. |
required |
members
|
Annotated[int, ParameterSpec(domain=NN)]
|
The number |
20
|
selection
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The intensity |
0.1
|
conflict_rate
|
Annotated[float, ParameterSpec(domain=closed_open(0, oo))]
|
The rate |
0.2
|
benefit
|
Annotated[float, ParameterSpec()]
|
The benefit |
2.0
|
cost
|
Annotated[float, ParameterSpec()]
|
The cost |
1.0
|
punishment
|
Annotated[float, ParameterSpec()]
|
The punishment |
0.5
|
interaction_cost
|
Annotated[float, ParameterSpec()]
|
The cost |
0.5
|
fixed_cost
|
Annotated[float, ParameterSpec()]
|
The fixed cost |
0.0
|
Examples:
>>> from skcomplex.systems.social.cooperation import TwoLevelBirthDeathInteraction
>>> TwoLevelBirthDeathInteraction('competition', target='groups').members
20
Source code in src/skcomplex/systems/social/cooperation/_two_level_birth_death.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
compete(system)
Draw the births, deaths, and conflicts of one unit of time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/cooperation/_two_level_birth_death.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
game_transitions(n_players=100, *, degree=4, first_benefit=3.5, second_benefit=2.6, cost=1.0, selection=0.1, after_cooperation=0.0, after_defection=1.0, transitions=True, update='death-birth', share=0.5, random_state=0)
Return evolutionary dynamics with game transitions on a random regular graph, after Su, McAvoy, Wang, and Nowak.
Every edge carries a donation game, game 1 of benefit b1 or game 2 of benefit b2 < b1, at the same cost c.
Players accumulate the payoffs of the games with all their neighbours, one player is replaced every time step by
death-birth updating or pairwise comparison, and the game of every edge changes with the actions played on it:
with the default transitions mutual cooperation leads to game 1 and every other outcome to game 2 (arXiv 1905.10269
section 2 and section 3.1). Under weak selection and death-birth updating on a k-regular graph, cooperation is
favoured if b1 / c > k - xi (b1 - b2) / c with xi = (k - 1) / 2, lowered from the rule b1 / c > k of a
single game, and with the probabilities p and q of game 2 after mutual cooperation and after one defection,
xi = (k - 1) q / 2 - (k + 1) p / 2 (Eq. 1 and Eq. 3). Under pairwise comparison cooperation is favoured if
(b1 - b2) / (2 c) > 1 (Eq. 2), whatever b1, and never with a single game. The defaults b1 = 3.5,
b2 = b1 - 0.9, and k = 4 lie in the range of Fig. 2 where transitions favour cooperation, since
3.5 > 4 - 1.5 * 0.9, and game 1 alone does not, since 3.5 < 4.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_players
|
int
|
The number of players. |
100
|
degree
|
int
|
The number |
4
|
first_benefit
|
float
|
The benefit |
3.5
|
second_benefit
|
float
|
The benefit |
2.6
|
cost
|
float
|
The cost |
1.0
|
selection
|
float
|
The intensity |
0.1
|
after_cooperation
|
float
|
The probability |
0.0
|
after_defection
|
float
|
The probability |
1.0
|
transitions
|
bool
|
Whether the games change, or every edge plays game 1 throughout. |
True
|
update
|
str
|
|
'death-birth'
|
share
|
float
|
The share of cooperators at the start. |
0.5
|
random_state
|
int | Generator | None
|
The seed or generator of the graph and of the initial strategies. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the group |
Examples:
>>> from skcomplex.systems.social.cooperation import game_transitions
>>> game_transitions(20).elements[0].prepare().size_
20
Source code in src/skcomplex/systems/social/cooperation/_game_transitions.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
hypergraph_public_goods(n_nodes=400, *, sizes=(3, 5), hyperdegree=2.0, synergy=4.0, noise=0.5, share=0.5, seed=0)
Return the public goods game on a hypergraph, played in every hyperedge, with Fermi imitation.
Every hyperedge is a group that plays the public goods game: a cooperator pays 1, and the pot multiplied by
synergy is shared by the members. Every step has two phases. In the phase play every player takes the sum of
its shares minus its contributions over the hyperedges around it, and in the phase imitate every player copies a
random neighbour, a member of one of its hyperedges, with the Fermi probability 1 / (1 + exp((P_own - P_other) /
K)) of the payoffs of the same step, at the noise K. In a well-mixed population defection wins in a group of m
for synergy < m, so cooperation needs a synergy near the sizes of the hyperedges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_nodes
|
int
|
The number of players. |
400
|
sizes
|
Sequence[int]
|
The sizes of the hyperedges. |
(3, 5)
|
hyperdegree
|
float
|
The mean number of hyperedges of every size around a player, whose members are drawn at random. |
2.0
|
synergy
|
float
|
The factor that multiplies the contributions of a hyperedge. |
4.0
|
noise
|
float
|
The noise of the Fermi imitation. |
0.5
|
share
|
float
|
The share of cooperators at the start. |
0.5
|
seed
|
int
|
The seed of the hypergraph and the initial strategies. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the strategies |
Examples:
>>> from skcomplex.systems.social.cooperation import hypergraph_public_goods
>>> hypergraph_public_goods(30).elements[0].prepare().size_
30
Source code in src/skcomplex/systems/social/cooperation/_hypergraph_games.py
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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
iterated_lattice_dilemma(shape=(30, 30), *, rounds=7, reward=0.6, sucker=1.5, temptation=0.0, punishment=1.0, mutation=0.01, extremes=False, random_state=0)
Return Argun's evolutionary iterated prisoner's dilemma on a lattice, with strategies of n cooperation rounds.
The payoffs are years in prison, T < R < P < S, so lower is better. A strategy n cooperates until round n
or until the opponent defects, and defects afterwards, so n = 0 always defects and n = N always cooperates.
Against a strategy m the best reply is n = m - 1. Every step each player plays the N-round game with its four
von Neumann neighbours, adopts the strategy of the lowest total among itself and its neighbours, random on ties,
and mutates to a random strategy with the probability mu (Argun et al. 2021 sections 13.2 and 13.3). With every
strategy allowed and S = 1.5, cooperative strategies prevail for R below about 0.5, all strategies coexist and
cycle between about 0.5 and 0.75, and defecting strategies dominate above, so the default R = 0.6 lies in the
middle of the cycling regime, where a finite lattice is not absorbed by defection. With only the two extreme
strategies,
extremes=True, cooperation dominates at R = 0.82, coexists with defection at R = 0.84, and vanishes at
R = 0.86 (Exercise 13.3).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of rows and columns of the periodic lattice. |
(30, 30)
|
rounds
|
int
|
The number |
7
|
reward
|
float
|
The punishment |
0.6
|
sucker
|
float
|
The punishment |
1.5
|
temptation
|
float
|
The punishment |
0.0
|
punishment
|
float
|
The punishment |
1.0
|
mutation
|
float
|
The probability |
0.01
|
extremes
|
bool
|
Whether only the strategies 0, always defect, and |
False
|
random_state
|
int | Generator | None
|
The seed or generator of the initial strategies. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the strategies |
Examples:
>>> from skcomplex.systems.social.cooperation import iterated_lattice_dilemma
>>> iterated_lattice_dilemma((10, 10)).elements[0].prepare().size_
100
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | |
nonlinear_pairwise_group_conflict(cells=100, *, victory='fermi', group_strength=2.0, benefit=2.0, cost=1.0, punishment=0.5, interaction_cost=0.1, fixed_cost=0.0, sensitivity=2.0, exponent=1.0)
Return the density of groups of defectors and altruistic punishers under pairwise group conflict.
The density f(z) of groups with a fraction z of punishers is advected by the replicator dynamics within groups,
z (1 - z) (pi_P - pi_D), and groups win pairwise conflicts, copying themselves over the loser, at the rate
group_strength f(z) int (rho(z, u) - rho(u, z)) f(u) du. The victory probability rho is not additively
separable: the group Fermi rule (1 + tanh(s (G(z) - G(u)))) / 2 ('fermi'), the local rule normalized by the
payoffs of both groups ('local'), or the Tullock contest function of the payoffs above their minimum with the
exponent 1 / a ('tullock'), where G(z) is the average payoff of a group (Cooney 2024, arXiv 2405.18419 §3.1
and §6). The density starts uniform, and the integral against the two-point kernel rho(z, u) - rho(u, z) keeps
its total at one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cells
|
int
|
The number of cells of the axis of the fraction of punishers. |
100
|
victory
|
str
|
The victory probability, |
'fermi'
|
group_strength
|
float
|
The relative strength |
2.0
|
benefit
|
float
|
The benefit |
2.0
|
cost
|
float
|
The cost |
1.0
|
punishment
|
float
|
The punishment |
0.5
|
interaction_cost
|
float
|
The cost |
0.1
|
fixed_cost
|
float
|
The fixed cost |
0.0
|
sensitivity
|
float
|
The sensitivity |
2.0
|
exponent
|
float
|
The exponent |
1.0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the density |
Raises:
| Type | Description |
|---|---|
ValidationError
|
The victory probability is unknown. |
Examples:
>>> from skcomplex.systems.social.cooperation import nonlinear_pairwise_group_conflict
>>> nonlinear_pairwise_group_conflict(40).elements[0].prepare().size_
40
Source code in src/skcomplex/systems/social/cooperation/_multilevel_selection.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
play(first, second, rounds=6)
Return the scores of two genomes in an iterated prisoner's dilemma.
A genome holds seven moves, 1 to cooperate and 0 to defect, for the opponent's last two moves: none, C, D, CC, CD, DC, and DD. A round pays 3 to both cooperators, 1 to both defectors, and 5 to a defector against a cooperator, who gets 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
first
|
ArrayLike
|
The genome of the first player. |
required |
second
|
ArrayLike
|
The genome of the second player. |
required |
rounds
|
int
|
The number of rounds. |
6
|
Returns:
| Name | Type | Description |
|---|---|---|
scores |
tuple[float, float]
|
The total scores of the two players. |
Examples:
>>> from skcomplex.systems.social.cooperation import play
>>> play([1] * 7, [0] * 7)
(0.0, 30.0)
Source code in src/skcomplex/systems/social/cooperation/_tournaments.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
prisoners_dilemma_tournament(n_agents=100, *, rounds=6, death=0.1, mutation=0.05, random_state=0)
Return the evolution of strategies of the iterated prisoner's dilemma from random genomes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_agents
|
int
|
The number of agents. |
100
|
rounds
|
int
|
The number of rounds of every game. |
6
|
death
|
float
|
The probability that an agent dies every step. |
0.1
|
mutation
|
float
|
The probability that an offspring has one gene flipped. |
0.05
|
random_state
|
int | Generator | None
|
The seed or generator of the initial genomes. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the group |
Examples:
>>> from skcomplex.systems.social.cooperation import prisoners_dilemma_tournament
>>> prisoners_dilemma_tournament(10, random_state=0).elements[0].prepare().size_
10
Source code in src/skcomplex/systems/social/cooperation/_tournaments.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
public_goods_game(shape=(50, 50), *, synergy=4.5, noise=0.5, share=0.5, random_state=0)
Return the spatial public goods game in groups of five neighbours, with Fermi imitation.
Every step has two phases. In the phase play every player takes the payoff of its five groups, and in the phase
imitate every player copies a random neighbour with the Fermi probability 1 / (1 + exp((P_own - P_other) / K))
of the payoffs of the same step, at the noise K.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of rows and columns of the periodic lattice. |
(50, 50)
|
synergy
|
float
|
The factor that multiplies the contributions of a group. |
4.5
|
noise
|
float
|
The noise of the Fermi imitation. |
0.5
|
share
|
float
|
The share of cooperators at the start. |
0.5
|
random_state
|
int | Generator | None
|
The seed or generator of the initial strategies. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the strategies |
Examples:
>>> from skcomplex.systems.social.cooperation import public_goods_game
>>> public_goods_game((10, 10)).elements[0].prepare().size_
100
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
simplicial_social_dilemmas(n_nodes=500, *, simplices=0.5, sucker=-0.2, temptation=1.2, sucker_allied=0.5, temptation_allied=0.8, sucker_opposed=None, temptation_opposed=None, noise=0.1, share=0.5, seed=0)
Return the social dilemmas of Guo et al. on the links and the 2-simplices of a simplicial complex.
The network grows from a complete graph on five nodes, every new node joining both ends of a random link, which
forms one new triangle. A share simplices of the triangles, drawn at random, are 2-simplices, and the others are
three links. Players play game 1 along the links of a plain triangle, and in a 2-simplex game 2 against a member
when the third member shares their strategy and game 3 otherwise, every game paying 1 for mutual cooperation, 0
for mutual defection, and S and T to a cooperator and a defector that meet. The payoff of a player is the mean
over the two links of every triangle around it. Every step has two phases: in play every player takes its
payoff, and in imitate every player copies a random neighbour with the Fermi probability 1 / (1 + exp((P_own -
P_other) / K)) at the noise K.
The review of Majhi et al. writes the payoff as a mean over the links of a player of the mean over the triangles of
each link, and picks game 2 when s_ki = s_kj. This system takes the mean over the links of the triangles, which
counts a link once per triangle, and reads the condition as the third member sharing the strategy of the player.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_nodes
|
int
|
The number of players. |
500
|
simplices
|
float
|
The share of the triangles that are 2-simplices. |
0.5
|
sucker
|
float
|
The sucker's payoff |
-0.2
|
temptation
|
float
|
The temptation |
1.2
|
sucker_allied
|
float
|
The sucker's payoff |
0.5
|
temptation_allied
|
float
|
The temptation |
0.8
|
sucker_opposed
|
float | None
|
The sucker's payoff |
None
|
temptation_opposed
|
float | None
|
The temptation |
None
|
noise
|
float
|
The noise of the Fermi imitation. |
0.1
|
share
|
float
|
The share of cooperators at the start. |
0.5
|
seed
|
int
|
The seed of the network, the 2-simplices, and the initial strategies. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the strategies |
Examples:
>>> from skcomplex.systems.social.cooperation import simplicial_social_dilemmas
>>> simplicial_social_dilemmas(30).elements[0].prepare().size_
30
Source code in src/skcomplex/systems/social/cooperation/_hypergraph_games.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | |
spatial_prisoners_dilemma(shape=(50, 50), *, temptation=1.85, imitation='best', noise=0.1, share=0.9, random_state=0)
Return the spatial prisoner's dilemma of Nowak and May, with best-neighbour or Fermi imitation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
Sequence[int]
|
The number of rows and columns of the periodic lattice. |
(50, 50)
|
temptation
|
float
|
The payoff of a defector against a cooperator. |
1.85
|
imitation
|
str
|
|
'best'
|
noise
|
float
|
The noise of the Fermi imitation. |
0.1
|
share
|
float
|
The share of cooperators at the start. |
0.9
|
random_state
|
int | Generator | None
|
The seed or generator of the initial strategies. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the strategies |
Examples:
>>> from skcomplex.systems.social.cooperation import spatial_prisoners_dilemma
>>> spatial_prisoners_dilemma((10, 10)).elements[0].prepare().size_
100
Source code in src/skcomplex/systems/social/cooperation/_spatial_games.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | |
trimorphic_multilevel_selection(cells=30, *, victory='defectors', group_strength=4.0, benefit=3.0, cost=1.0, punishment=0.5, interaction_cost=0.1, fixed_cost=0.0)
Return the density of groups of cooperators, defectors, and altruistic punishers on the 2-simplex.
The density f(x, y) of groups with fractions x of cooperators, y of defectors, and 1 - x - y of punishers
lives on the 2-simplex. The replicator dynamics within groups advect it, and groups win pairwise conflicts at the
rate group_strength f(x, y) int (rho(x, y; u, v) - rho(u, v; x, y)) f(u, v) du dv over the simplex. The victory
probability is 1/2 + (v - y) / 2 of the fraction of non-defectors ('defectors'), or the difference of the
average payoffs normalized by their largest difference on the simplex ('payoff') (Cooney 2024, arXiv 2405.18419
§3.2 and §7). The density starts uniform at two, so its integral is one, the cells along the slanted face are half
cells, and no flux leaves the simplex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cells
|
int
|
The number of cells of each axis of the simplex. |
30
|
victory
|
str
|
The victory probability, |
'defectors'
|
group_strength
|
float
|
The relative strength |
4.0
|
benefit
|
float
|
The benefit |
3.0
|
cost
|
float
|
The cost |
1.0
|
punishment
|
float
|
The punishment |
0.5
|
interaction_cost
|
float
|
The cost |
0.1
|
fixed_cost
|
float
|
The fixed cost |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the density |
Raises:
| Type | Description |
|---|---|
ValidationError
|
The victory probability is unknown. |
Examples:
>>> from skcomplex.systems.social.cooperation import trimorphic_multilevel_selection
>>> trimorphic_multilevel_selection(10).elements[0].prepare().size_
100
Source code in src/skcomplex/systems/social/cooperation/_multilevel_selection.py
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
two_level_birth_death(groups=50, *, members=20, selection=0.1, conflict_rate=0.2, benefit=2.0, cost=1.0, punishment=0.5, interaction_cost=0.5, fixed_cost=0.0, random_state=0)
Return the finite two-level birth-death process of defectors and altruistic punishers in competing groups.
The population has m groups of n members. Within groups, punishers and defectors reproduce at the rates
1 + w pi_P(z) and 1 + w pi_D(z) of the fraction z of punishers, with pi_P = (b + k) z - (c + q + k) and
pi_D = (b - p) z, and the offspring replaces a random member of the group. Every group fights a random other
group at the rate Lambda and wins with the probability 1/2 + (z - u) / 2, and the winner's copy replaces the
loser (Cooney 2024, arXiv 2405.18419 section 3.1 and appendix A.1). With many large groups, the density of the
fractions of punishers follows two_level_replicator with lambda = Lambda / w, so between-group conflict
sustains the punishers above lambda* = c + q - p and the defectors take over without it. The groups start with
uniformly drawn numbers of punishers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
groups
|
int
|
The number |
50
|
members
|
int
|
The number |
20
|
selection
|
float
|
The intensity |
0.1
|
conflict_rate
|
float
|
The rate |
0.2
|
benefit
|
float
|
The benefit |
2.0
|
cost
|
float
|
The cost |
1.0
|
punishment
|
float
|
The punishment |
0.5
|
interaction_cost
|
float
|
The cost |
0.5
|
fixed_cost
|
float
|
The fixed cost |
0.0
|
random_state
|
int | Generator | None
|
The seed or generator of the initial groups. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the group |
Examples:
>>> from skcomplex.systems.social.cooperation import two_level_birth_death
>>> two_level_birth_death(10).elements[0].prepare().size_
10
Source code in src/skcomplex/systems/social/cooperation/_two_level_birth_death.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
two_level_replicator(cells=100, *, victory='punishers', group_strength=2.0, benefit=2.0, cost=1.0, punishment=0.5, interaction_cost=0.5, fixed_cost=0.0)
Return the two-level replicator equation of defectors and altruistic punishers, additive pairwise group conflict.
The density f(z) of groups with a fraction z of punishers is advected by the replicator dynamics within groups,
z (1 - z) (pi_P - pi_D), and groups replicate at the rate group_strength f(z) (G(z) - int G(u) f(u) du)
(Cooney 2024, arXiv 2405.18419 Eq. 3.3). Pairwise group conflict with an additively separable victory probability
rho(z, u) = 1/2 + (G(z) - G(u)) / 2 reduces to this equation (Eq. 3.11): G(z) = z for the probability of
Boyd and coauthors based on the fraction of punishers ('punishers', Eq. 3.6 and section 5.1), or the average
payoff of a group normalized by its range, G(z) / (G* - G_*) ('payoff', Eq. 3.8 and section 5.2). From a uniform
density with G(z) = z and p < c + q, the groups concentrate at the all-defector state below the threshold
lambda* = c + q - p, and above it the mean fraction of punishers tends to 1 - (c + q - p) / lambda (Eq. 5.4).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cells
|
int
|
The number of cells of the axis of the fraction of punishers. |
100
|
victory
|
str
|
The group-level victory probability, |
'punishers'
|
group_strength
|
float
|
The relative strength |
2.0
|
benefit
|
float
|
The benefit |
2.0
|
cost
|
float
|
The cost |
1.0
|
punishment
|
float
|
The punishment |
0.5
|
interaction_cost
|
float
|
The cost |
0.5
|
fixed_cost
|
float
|
The fixed cost |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
system |
System
|
The system, with the density |
Raises:
| Type | Description |
|---|---|
ValidationError
|
The victory probability is unknown. |
Examples:
>>> from skcomplex.systems.social.cooperation import two_level_replicator
>>> two_level_replicator(40).elements[0].prepare().size_
40
Source code in src/skcomplex/systems/social/cooperation/_multilevel_selection.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |