Organizations
Organizations: hierarchies, queues, workplaces, and institutions.
AjanisChoiceSystem(n_employers=10, *, n_workers=500, asks=1, chat=3, adjustment=0.2, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Chesney's Ajani's Choice, migrant farm workers and employers.
Underpayment emerges among them. Employers need between 50 and 99 workers a day each and start with a random wage
between 1 and 2, the minimum wage being 1. Workers live in two slums, n_workers in each, and ask the employers of
their local area for work every morning, accepting an offer below the minimum wage only when desperate, after a day
without work at the minimum wage, or when no employer is left to ask. Every evening employers lower their wage if
they filled their workforce and raise it otherwise, by adjustment, within [0.1, 2], and then average the wages
of chat random employers (Chesney 2021 sections 3.3 and 3.8). A worker paid below the minimum wage is a slave, and
a run lasts 60 days, two summer months. When workers outnumber the jobs, desperation drags the wages below the
minimum, as with the default 10 employers and 1000 workers. The NetLogo listing of section 3.8 accepts a low offer
when yesterday's pay was above the minimum, against rule 3 of the text, and the system follows the text.
The system has the groups employers and workers, and the reporters day.slaves and day.in_work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_employers
|
int
|
The number of employers. |
10
|
n_workers
|
int
|
The number of workers in each slum. |
500
|
asks
|
int
|
The number of employers a worker asks for work in a day. |
1
|
chat
|
int
|
The number of employers whose wages an employer averages in the evening. |
3
|
adjustment
|
float
|
The change of the wage of an employer after a day. |
0.2
|
random_state
|
int | Generator | None
|
The seed or generator of the employers. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import AjanisChoiceSystem
>>> AjanisChoiceSystem(5, n_workers=10).prepare().system_.elements[1].size
20
Source code in src/skcomplex/systems/social/organizations/_wages.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |
ArmsRaceElement(label, *, a=10.0, b=10.5, margin=0.1, adjustment_time=2.0, perception_delay=1.0)
Bases: Element
Arms race element.
Source code in src/skcomplex/systems/social/organizations/_traps.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
AssemblyInteraction(label, *, target, interruption=0.01)
Bases: Interaction
Assembly of the Hora and Tempus fable.
There is one action per step, which an interruption can undo. Every step every watchmaker takes one action on the
task in hand, unless a customer calls, with the probability interruption, and the unfinished task falls to pieces.
A finished task is stable, and a watchmaker who finishes the last task of a watch sells it and starts the next one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of watchmakers. |
required |
interruption
|
Annotated[float, closed(0, 1)]
|
The probability that a watchmaker is interrupted at an action. |
0.01
|
Examples:
>>> from skcomplex.systems.social.organizations import AssemblyInteraction
>>> AssemblyInteraction('assembly', target='watchmakers').interruption
0.01
Source code in src/skcomplex/systems/social/organizations/_watchmakers.py
117 118 119 120 121 122 123 124 125 126 | |
assemble(system)
Take one action of every watchmaker.
An interruption undoes the task in hand instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_watchmakers.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
BonabeauHierarchiesSystem(width=20, height=20, *, density=0.5, eta=1.0, relaxation=0.1, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Bonabeau system.
A hierarchy of strengths emerges above a critical density of agents. The system has the group contenders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The number of columns of the torus. |
20
|
height
|
int
|
The number of rows of the torus. |
20
|
density
|
float
|
The share of cells with an agent. |
0.5
|
eta
|
float
|
The sensitivity of the outcome of a fight to the strength difference. |
1.0
|
relaxation
|
float
|
The fraction of its strength an agent loses every step. |
0.1
|
random_state
|
int | Generator | None
|
The seed or generator of the initial cells. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import BonabeauHierarchiesSystem
>>> BonabeauHierarchiesSystem(10, 10, density=0.2).prepare().system_.elements[0].size
20
Source code in src/skcomplex/systems/social/organizations/_hierarchies.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | |
BurdenElement(label, *, capability=0.5, intervention=0.0, desired=1.0, fix_rate=1.0, build_time=5.0, solution_delay=2.0, erosion=0.5)
Bases: Element
Burden element.
Source code in src/skcomplex/systems/social/organizations/_traps.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
CityDwellerElement(label, *, angle=0.0, age=0.0, degree=0.0, meetings=0.0, space=None)
Bases: Element
Resident of a growing city.
It holds an angle of similarity, an age, and the meetings of the last step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the group. |
required |
angle
|
object
|
The angle of the resident on the circle, its similarity coordinate. |
0.0
|
age
|
Annotated[object, closed_open(0, oo)]
|
The number of steps since the resident joined. |
0.0
|
degree
|
Annotated[object, closed_open(0, oo)]
|
The number of neighbours of the resident at the start of the last step. |
0.0
|
meetings
|
Annotated[object, closed_open(0, oo)]
|
The number of neighbours the resident met in the last step. |
0.0
|
space
|
BaseSpace | None
|
The network whose nodes hold the residents, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import CityDwellerElement
>>> CityDwellerElement('residents', angle=1.5).angle
1.5
Source code in src/skcomplex/systems/social/organizations/_urban_interactions.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
CityResidentElement(label, *, x=0.0, y=0.0, contacts=0.0, size=None, space=None)
Bases: Element
Resident of a city, who stays at a position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the resident or the group. |
required |
x
|
ArrayLike
|
The position along the first axis of the city. |
0.0
|
y
|
ArrayLike
|
The position along the second axis of the city. |
0.0
|
contacts
|
ArrayLike
|
The initial guess of the sum of the interactions with the others, which the equation replaces. |
0.0
|
size
|
int | None
|
The number of residents, or |
None
|
space
|
BaseSpace | None
|
The plane of the city, whose axes |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import CityResidentElement
>>> CityResidentElement('resident', x=1.0, y=2.0).y
2.0
Source code in src/skcomplex/systems/social/organizations/_urban_scaling.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
CommuteInteraction(label, *, target)
Bases: MovementInteraction
Commute of every resident in a cycle of three steps.
The steps go to work, to its favourite place, and back home. The work and the favourite place are regions of the
layers facilities and places, so a resident stands at a new uniform point of the region at every visit, and at
the same point of its home.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the group of residents. |
required |
Examples:
>>> from skcomplex.systems.social.organizations import CommuteInteraction
>>> CommuteInteraction('commute', target='residents').schedule
'member'
Source code in src/skcomplex/systems/social/organizations/_kauai.py
229 230 | |
ContainerMobilityInteraction(label, *, target, levels=3, side=4, travel=(0.6, 0.3, 0.1), exponent=1.5)
Bases: Interaction
Container model of Alessandretti and coauthors.
It displaces individuals between locations nested in containers. Space is a nested grid of levels levels, every
container of a level split into side by side containers of the level below, and the containers of the lowest
level are the locations. The children of every container have attractivenesses drawn from a power law of the
exponent exponent and normalized, and home is the location of the largest attractiveness at every level. Every
step every individual draws the level-distance d of its displacement from travel, chooses a container of level
d other than its own among the children of its container of level d + 1, by attractiveness, and then descends to
a location by the attractivenesses of the children at every level below. Every individual has its own hierarchy,
drawn at its first step, and starts at home.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of individuals. |
required |
levels
|
Annotated[int, NN]
|
The number |
3
|
side
|
Annotated[int, NN]
|
The number of children of a container along every axis. |
4
|
travel
|
Sequence[float]
|
The probabilities of displacements at the level-distances 1 to |
(0.6, 0.3, 0.1)
|
exponent
|
Annotated[float, open(0, oo)]
|
The exponent of the power law of the attractivenesses. |
1.5
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The probabilities of travel do not match the levels, raised by |
Examples:
>>> from skcomplex.systems.social.organizations import ContainerMobilityInteraction
>>> ContainerMobilityInteraction('displacement', target='individuals').levels
3
Source code in src/skcomplex/systems/social/organizations/_mobility.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
move(system)
Displace every individual once.
The displacement is at a drawn level-distance, to a location chosen by attractiveness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_mobility.py
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 | |
ContainerMobilitySystem(n_individuals=10, *, levels=3, side=4, travel=(0.6, 0.3, 0.1), exponent=1.5, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The container model of human mobility of Alessandretti, Aslak, and Lehmann.
Its trajectories cross scales. Space is a hierarchy of L levels of containers, a nested grid where every container
holds side by side containers of the level below, down to the locations, and every container has an
attractiveness among its siblings, drawn from a power law. An individual travels at the level-distance d, the
highest level at which its origin and destination differ, with the probability p_d, chooses the destination
container of level d among the other children of its container of level d + 1 by attractiveness, and descends by
attractiveness to a location (arXiv 2109.07381 Methods, Generating traces). The nested grid, the power law of the
attractivenesses, and the probabilities of travel that do not depend on the distance from home follow Supplementary
Note 3. Displacements are a mixture of the scales of the containers, from one cell to side^(L - 1) cells.
The system has the group individuals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_individuals
|
int
|
The number of individuals. |
10
|
levels
|
int
|
The number |
3
|
side
|
int
|
The number of children of a container along every axis. |
4
|
travel
|
Sequence[float]
|
The probabilities |
(0.6, 0.3, 0.1)
|
exponent
|
float
|
The exponent of the power law of the attractivenesses. |
1.5
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import ContainerMobilitySystem
>>> ContainerMobilitySystem(3).prepare().system_.elements[0].size
3
Source code in src/skcomplex/systems/social/organizations/_mobility.py
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
ContenderElement(label, *, strength=0.0, eta=1.0, relaxation=0.1, x=0, y=0, size=None, space=None)
Bases: Element
Agent of the Bonabeau system.
It wanders on a grid and fights the agents it runs into. Every step an agent's strength relaxes by the factor
1 - relaxation, and the agent tries to step into a random neighbouring cell. An attacker beats the occupant with
probability 1 / (1 + exp(eta * (h_occupant - h_attacker))), the winner gains 1 and the loser loses 1, and a
winning attacker swaps places with the occupant. Agents differ only by their strength, so the swap exchanges their
strengths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
strength
|
object
|
The initial strength |
0.0
|
eta
|
Annotated[object, closed_open(0, oo)]
|
The sensitivity of the outcome of a fight to the strength difference. |
1.0
|
relaxation
|
Annotated[object, closed_open(0, oo)]
|
The fraction of its strength an agent loses every step. |
0.1
|
x
|
object
|
The column of the cell of the contender on a lattice, one per contender or shared. |
0
|
y
|
object
|
The row of the cell of the contender on a lattice, one per contender or shared. |
0
|
size
|
int | None
|
The number of members, or |
None
|
space
|
BaseSpace | None
|
The lattice the contenders live on, whose axes |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import ContenderElement
>>> group = ContenderElement('contenders', size=10)
>>> group.label, type(group).__name__, group.size
('contenders', 'ContenderElement', 10)
Source code in src/skcomplex/systems/social/organizations/_hierarchies.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
ContenderView
Bases: AgentViewProtocol, Protocol
View of an agent of the Bonabeau hierarchy system.
Its states and parameters are attributes.
ContestElement(label, *, a=55.0, b=45.0, budget=10.0, lifetime=10.0)
Bases: Element
Contest element.
Source code in src/skcomplex/systems/social/organizations/_traps.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
DailyMovementsInteraction(label, *, women, premises, n_cities=3, phase=None, victims_phase=None)
Bases: Interaction
Movements of the women of the brothel movement system.
Every day one random free woman moves to a random cell of a random city, and in the steps of the phase
victims_phase the traffickers move a random number of the victims of every brothel to random brothels. A move
between cities counts as a train trip. The cities are vertical bands of equal width of the grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
women
|
Role
|
The path of the group of travellers. |
required |
premises
|
Role
|
The path of the group of premises, whose brothels the victims move between. |
required |
n_cities
|
int
|
The number of cities, vertical bands of equal width. |
3
|
phase
|
str | None
|
The phase of the step the free woman moves in, or |
None
|
victims_phase
|
str | None
|
The phase of the step the victims move in, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import DailyMovementsInteraction
>>> DailyMovementsInteraction('day', women='women', premises='premises').n_cities
3
Source code in src/skcomplex/systems/social/organizations/_trafficking.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
move_free(system)
Move a random free woman to a random cell of a random city.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_trafficking.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
move_victims(system)
Move a random number of the victims of every brothel to random brothels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_trafficking.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
DietInteraction(label, *, target, day_phase='evening', week_phase='week')
Bases: Interaction
Days and weekly weight change of the people of the obesity system.
Every evening a person counts one more day lived in the system, and once a week its weight changes by the calories of the week beyond its basal needs, and a new week starts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of people. |
required |
day_phase
|
str | None
|
The phase the days are counted in. |
'evening'
|
week_phase
|
str | None
|
The phase the weight changes in. |
'week'
|
Examples:
>>> from skcomplex.systems.social.organizations import DietInteraction
>>> DietInteraction('diet', target='people').week_phase
'week'
Source code in src/skcomplex/systems/social/organizations/_obesity.py
319 320 321 322 323 324 325 326 327 328 329 330 | |
count_day(agent, system)
Count one more day lived in the system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
EaterView
|
The person. |
required |
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_obesity.py
345 346 347 348 349 350 351 352 353 354 355 | |
gain_weight(agent, system)
Change the weight by the calories of the week, and start a new week.
Only the calories beyond the basal needs count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
EaterView
|
The person. |
required |
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_obesity.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
DriftToLowPerformanceSystem(performance=1.0, *, bias=0.1, perception_time=2.0, correction_time=2.0, goal_time=5.0, absolute=False, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Meadows' drift to low performance trap.
The goals erode, following a pessimistic view of the performance. The actor compares the desired state with the
actual performance and corrects the gap over the correction time, an ordinary balancing loop. The actor perceives
the performance worse than it is, smoothed over the perception time and lowered by the negative bias, and the
desired state slips toward the perceived state over the goal time. The lower the perceived state, the lower the
goal, the less corrective action, and the lower the performance, a reinforcing loop that drags the performance down
exponentially. With absolute standards, absolute=True, the desired state does not slip and the performance holds,
and with an upbeat bias, a negative bias, the same structure drifts toward high performance, the two ways out of
the book. The book gives the structure only, as a narrative, so the parameters are a documented choice.
The system has the performance performance.performance, the perceived state performance.perceived, and the
desired state performance.desired, and the flows performance.correction, performance.perception, and
performance.goal_erosion. The observable of the system is performance.discrepancy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
performance
|
float
|
The initial performance, also the initial perceived and desired states. |
1.0
|
bias
|
float
|
The fraction by which the actor underrates the performance, negative for an upbeat bias. |
0.1
|
perception_time
|
float
|
The time over which the actor perceives the performance. |
2.0
|
correction_time
|
float
|
The time over which the corrective action closes the gap to the desired state. |
2.0
|
goal_time
|
float
|
The time over which the desired state follows the perceived state. |
5.0
|
absolute
|
bool
|
Whether the desired state is kept absolute, regardless of the performance. |
False
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import DriftToLowPerformanceSystem
>>> DriftToLowPerformanceSystem(absolute=True).prepare().system_.elements[0].erosion
0.0
Source code in src/skcomplex/systems/social/organizations/_traps.py
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 | |
EaterElement(label, *, home=0.0, work=0.0, weight=70.0, height=170.0, age=40.0, male=1.0, habit=1.0, calories=0.0, bmi=24.0, day=0.0, reach=30.0, activity=1.55, values=None, size=None, space=None)
Bases: Element
Person of the obesity system.
The person goes from home to work and back every day and eats near each place. The moves and the meals of the day
are movements and transfers of the system, in the phases home, work, and evening. The calories of a meal are
drawn from the bottom, middle, or top half of the restaurant's range by the eating habit. In the phase week, every
seventh step, the weight changes by the calories eaten beyond seven days of the expenditure, the basal metabolic
rate times the activity factor of the Harris-Benedict equation, at 7700 kilocalories per kilogram.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
home
|
ArrayLike
|
The position of the person's home. |
0.0
|
work
|
ArrayLike
|
The position of the person's workplace. |
0.0
|
weight
|
Annotated[object, open(0, oo)]
|
The weight in kilograms. |
70.0
|
height
|
Annotated[object, open(0, oo)]
|
The height in centimetres. |
170.0
|
age
|
Annotated[object, open(0, oo)]
|
The age in years. |
40.0
|
male
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
1 for a man and 0 for a woman. |
1.0
|
habit
|
Annotated[object, NN]
|
The eating habit: low at 0, medium at 1, or high at 2. |
1.0
|
calories
|
Annotated[object, closed_open(0, oo)]
|
The calories eaten so far this week. |
0.0
|
bmi
|
Annotated[object, open(0, oo)]
|
The body mass index. |
24.0
|
day
|
Annotated[object, NN]
|
The number of days lived in the system. |
0.0
|
reach
|
Annotated[object, open(0, oo)]
|
The distance within which a person looks for a restaurant. |
30.0
|
activity
|
Annotated[object, open(0, oo)]
|
The factor of the basal metabolic rate a person spends a day, 1.2 when sedentary and 1.9 when very active. |
1.55
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the position |
None
|
size
|
int | None
|
The number of members, or |
None
|
space
|
BaseSpace | None
|
The plane whose axes |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import EaterElement
>>> group = EaterElement('people', home=[1.0, 2.0], work=[3.0, 4.0], size=5)
>>> group.label, group.size
('people', 5)
Source code in src/skcomplex/systems/social/organizations/_obesity.py
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 | |
draw_meal(agent, restaurant, system)
staticmethod
Return the calories of a meal.
They are drawn from the part of the range of a restaurant that a habit eats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
EaterView
|
The person. |
required |
restaurant
|
RestaurantView
|
The restaurant. |
required |
system
|
SystemView
|
The system. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
calories |
float
|
The calories of the meal. |
Source code in src/skcomplex/systems/social/organizations/_obesity.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
go_home(agent, system)
staticmethod
Return the position of the home of a person.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
EaterView
|
The person. |
required |
system
|
SystemView
|
The system. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
position |
NDArray[float64]
|
The position of the home. |
Source code in src/skcomplex/systems/social/organizations/_obesity.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
go_to_work(agent, system)
staticmethod
Return the position of the workplace of a person.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
EaterView
|
The person. |
required |
system
|
SystemView
|
The system. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
position |
NDArray[float64]
|
The position of the workplace. |
Source code in src/skcomplex/systems/social/organizations/_obesity.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
settle_meal(agent, restaurant, amounts, system)
staticmethod
Credit a person with the calories of a meal.
The sale is counted on the restaurant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
EaterView
|
The person. |
required |
restaurant
|
RestaurantView
|
The restaurant. |
required |
amounts
|
Sequence[float]
|
The calories of the meal, the only amount. |
required |
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_obesity.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
EaterView
Bases: AgentViewProtocol, Protocol
View of a person of the obesity system.
Its states and parameters are attributes.
EmployeeElement(label, *, predisposed=0.0, disgruntlement=0.0, stress=0.0, skill=0.0, affect=0.5, risk=0.5, days=0.0, first=0.0, mean_feeling=0.0, expectation=0.0, feeling=0.0, turnover=0.15, culture=0.8, change=0.05, primacy=1.0, consistency=1.0, recency=1.0, affect_weight=1.0, alpha_seen=0.5, lambda_seen=1.0, alpha_unseen=0.25, lambda_unseen=0.0, skill_growth=0.001, skill_variance=0.0005, size=None)
Bases: Element
Employee of the insider sabotage system, whose risk is the sum of five factors.
The risk is R = P + D + S + K + A: the predisposition P, the disgruntlement D of predisposed employees whose
daily feeling about the organization falls short of their expectation, the stress S raised by seeing a supervisor,
the skill K that grows every day, and the fixed affect A. The expectation weighs the first, the mean, and the
latest feeling. Every day an employee wanders to an adjacent cell and leaves with probability turnover / 365,
replaced by a new hire. In InsiderSabotageSystem, a movement, a map of every state, and a life cycle that renews
the employees who leave run these steps in turn in the activation of every employee.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
predisposed
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
Whether the employee is predisposed to sabotage, 1, or not, 0. |
0.0
|
disgruntlement
|
object
|
The initial disgruntlement |
0.0
|
stress
|
Annotated[object, closed_open(0, oo)]
|
The initial stress |
0.0
|
skill
|
object
|
The initial skill |
0.0
|
affect
|
Annotated[object, closed_open(0, oo)]
|
The affect |
0.5
|
risk
|
object
|
The initial risk |
0.5
|
days
|
Annotated[object, NN]
|
The number of days the employee has felt about the organization. |
0.0
|
first
|
object
|
The first feeling. |
0.0
|
mean_feeling
|
object
|
The mean feeling. |
0.0
|
expectation
|
object
|
The expected feeling. |
0.0
|
feeling
|
object
|
The latest feeling. |
0.0
|
turnover
|
Annotated[object, closed_open(0, oo)]
|
The yearly share of employees who leave. |
0.15
|
culture
|
object
|
The mean daily feeling about the organization. |
0.8
|
change
|
Annotated[object, closed_open(0, oo)]
|
The variance of the daily feeling. |
0.05
|
primacy
|
Annotated[object, closed_open(0, oo)]
|
The weight of the first feeling in the expectation. |
1.0
|
consistency
|
Annotated[object, closed_open(0, oo)]
|
The weight of the mean feeling in the expectation. |
1.0
|
recency
|
Annotated[object, closed_open(0, oo)]
|
The weight of the latest feeling in the expectation. |
1.0
|
affect_weight
|
object
|
The factor of the shortfall of a feeling in the disgruntlement. |
1.0
|
alpha_seen
|
Annotated[object, closed_open(0, oo)]
|
The learning rate of stress when a supervisor is in sight. |
0.5
|
lambda_seen
|
Annotated[object, closed_open(0, oo)]
|
The level stress approaches when a supervisor is in sight. |
1.0
|
alpha_unseen
|
Annotated[object, closed_open(0, oo)]
|
The learning rate of stress otherwise. |
0.25
|
lambda_unseen
|
Annotated[object, closed_open(0, oo)]
|
The level stress approaches otherwise. |
0.0
|
skill_growth
|
object
|
The mean daily growth of skill. |
0.001
|
skill_variance
|
Annotated[object, closed_open(0, oo)]
|
The variance of the daily growth of skill. |
0.0005
|
size
|
int | None
|
The number of members, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import EmployeeElement
>>> group = EmployeeElement('employees', affect=0.5, size=10)
>>> group.label, group.size
('employees', 10)
Source code in src/skcomplex/systems/social/organizations/_sabotage.py
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 | |
EmployeeView
Bases: AgentViewProtocol, Protocol
View of an employee of the insider sabotage system.
Its states and parameters are attributes.
EmploymentTakeoverInteraction(label, *, target='cells')
Bases: Interaction
Colours of workers and employers that follow each other on a checkerboard.
Every step each worker first takes the colour of the employer to its right, and then each employer takes the colour of three or four of its four workers, keeping its own colour on a tie of two.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The cells whose state |
'cells'
|
Examples:
>>> from skcomplex.systems.social.organizations import EmploymentTakeoverInteraction
>>> EmploymentTakeoverInteraction('takeover', target='cells').target
'cells'
Source code in src/skcomplex/systems/social/organizations/_employment.py
91 92 93 | |
EmploymentTakeoverSystem(size=32, *, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The employment takeover system on a periodic checkerboard.
Half of each kind is coloured at random. The system has the colours cells.colour and the employers
cells.employer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
The even number of rows and columns. |
32
|
random_state
|
int | Generator | None
|
The seed or generator of the cells coloured 1. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import EmploymentTakeoverSystem
>>> EmploymentTakeoverSystem(4).prepare().system_.elements[0].colour.size
16
Source code in src/skcomplex/systems/social/organizations/_employment.py
165 166 167 168 169 170 171 172 173 174 175 176 | |
EscalationSystem(a=10.0, b=10.5, *, margin=0.1, adjustment_time=2.0, perception_delay=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Meadows' escalation trap.
Two parties each want to exceed the other's stock by a margin. Each party sees the stock of the other through an
information smoothing over the perception delay, wants to hold 1 + margin times that stock, and builds up the gap
over the adjustment time. The loop through both stocks is reinforcing, so both stocks grow exponentially at the rate
r that solves r * adjustment_time = (1 + margin) / (1 + r * perception_delay) - 1. The book gives the structure
only, so the parameters are a documented choice.
The system has the stocks race.a and race.b in years, and the flows race.build_a and race.build_b. The
observables of the system are race.desired_a and race.desired_b.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
The initial stock of the first party. |
10.0
|
b
|
float
|
The initial stock of the second party. |
10.5
|
margin
|
float
|
The fraction by which each party wants to exceed the other. |
0.1
|
adjustment_time
|
float
|
The time over which a party closes the gap to its desired stock. |
2.0
|
perception_delay
|
float
|
The time over which a party perceives the stock of the other. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import EscalationSystem
>>> EscalationSystem(margin=0.2).prepare().system_.elements[0].margin
0.2
Source code in src/skcomplex/systems/social/organizations/_traps.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | |
ExecutionInteraction(label, *, target)
Bases: Interaction
Execution of one task per step from the list of the Barabási system.
The highest priority task is executed with probability greed and a random task otherwise. The executed task is
replaced by a new task with a uniform random priority, and every other task ages by one step. The waiting time of
the executed task is reported as wait, so the run records one waiting time per step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of tasks. |
required |
Examples:
>>> from skcomplex.systems.social.organizations import ExecutionInteraction
>>> ExecutionInteraction('execution', target='tasks').target
'tasks'
Source code in src/skcomplex/systems/social/organizations/_queues.py
113 114 115 116 117 118 119 120 | |
execute(system)
Execute one task and replace it with a new one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_queues.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
ExplorationInteraction(label, *, target, rho=0.6, gamma=0.21, beta=1.55, least_jump=1.0)
Bases: Interaction
Exploration and preferential return of Song and coauthors.
There is one displacement per individual and step. An individual who has visited S distinct locations explores a
new one with the probability rho S^-gamma, at a distance drawn from the power law P(r) ~ r^-beta above
least_jump in a uniform direction, and otherwise returns to a visited location with the probability proportional
to its number of visits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of individuals. |
required |
rho
|
Annotated[float, closed(0, 1)]
|
The factor |
0.6
|
gamma
|
Annotated[float, closed_open(0, oo)]
|
The exponent |
0.21
|
beta
|
Annotated[float, open(1, oo)]
|
The exponent |
1.55
|
least_jump
|
Annotated[float, open(0, oo)]
|
The least jump length. |
1.0
|
Examples:
>>> from skcomplex.systems.social.organizations import ExplorationInteraction
>>> ExplorationInteraction('displacement', target='individuals').rho
0.6
Source code in src/skcomplex/systems/social/organizations/_mobility.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
move(system)
Displace every individual once, to a new location or back to a visited one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_mobility.py
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 | |
ExplorationPreferentialReturnSystem(n_individuals=10, *, rho=0.6, gamma=0.21, beta=1.55, least_jump=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The exploration and preferential return model of human mobility.
The model is that of Song and coauthors. At every displacement an individual who has visited S distinct locations
explores a new place with the probability rho S^-gamma, at a distance drawn from the power law P(r) ~ r^-beta,
and otherwise returns to a visited location chosen in proportion to its number of visits (arXiv 2109.07381 Methods,
the baseline of Fig. 2). The number of distinct locations grows as n^(1 / (1 + gamma)) after n displacements,
and the visits of the locations follow Zipf's law. The defaults rho = 0.6 and gamma = 0.21 are the values of
Song and coauthors, and every individual starts at the origin.
The system has the group individuals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_individuals
|
int
|
The number of individuals. |
10
|
rho
|
float
|
The factor |
0.6
|
gamma
|
float
|
The exponent |
0.21
|
beta
|
float
|
The exponent |
1.55
|
least_jump
|
float
|
The least jump length. |
1.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import ExplorationPreferentialReturnSystem
>>> ExplorationPreferentialReturnSystem(3).prepare().system_.elements[0].size
3
Source code in src/skcomplex/systems/social/organizations/_mobility.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | |
ExplorerElement(label, *, x=0.0, y=0.0, distinct=1.0, level=0.0, size=None)
Bases: Element
Individual of the mobility systems.
It holds its position, its number of distinct locations, and its last level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the individual or the group. |
required |
x
|
object
|
The first coordinate of the current location. |
0.0
|
y
|
object
|
The second coordinate of the current location. |
0.0
|
distinct
|
Annotated[object, NN]
|
The number of distinct locations visited. |
1.0
|
level
|
Annotated[object, NN]
|
The level-distance of the last displacement in a hierarchy of containers, 0 without one. |
0.0
|
size
|
int | None
|
The number of members, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import ExplorerElement
>>> ExplorerElement('individual').distinct
1.0
Source code in src/skcomplex/systems/social/organizations/_mobility.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
ExplorerView
Bases: AgentViewProtocol, Protocol
View of an individual of the mobility systems, with its states as attributes.
FarmerElement(label, *, wage=1.0, workforce=50.0, employed=0.0, area=0.0, size=None)
Bases: Element
Employer of Ajani's Choice.
It offers a daily wage until the workforce it needs is filled.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the employer or the group. |
required |
wage
|
Annotated[object, closed(0, 2)]
|
The daily wage the employer offers, the minimum wage being 1. |
1.0
|
workforce
|
Annotated[object, NN]
|
The number of workers the employer needs every day. |
50.0
|
employed
|
Annotated[object, NN]
|
The number of workers the employer has hired today. |
0.0
|
area
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
The area of the farm, 0 near the first slum and 1 near the second. |
0.0
|
size
|
int | None
|
The number of members, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import FarmerElement
>>> FarmerElement('farmer', wage=1.5).wage
1.5
Source code in src/skcomplex/systems/social/organizations/_wages.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
FarmerView
Bases: AgentViewProtocol, Protocol
View of an employer of Ajani's Choice, with its states as attributes.
GravityContactInteraction(label, *, target, reach, gamma=1.0)
Bases: Interaction
Contacts of every resident.
They are the sum of r^-gamma over the others within a reach.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of residents. |
required |
reach
|
float
|
The largest distance of a contact, which the diameter of a city covers. |
required |
gamma
|
Annotated[float, open(0, oo)]
|
The decay exponent of an interaction with the distance. |
1.0
|
Examples:
>>> from skcomplex.systems.social.organizations import GravityContactInteraction
>>> GravityContactInteraction('contact', target='residents', reach=30.0, gamma=1.5).gamma
1.5
Source code in src/skcomplex/systems/social/organizations/_urban_scaling.py
97 98 99 100 101 102 103 104 105 106 107 108 | |
GravityUrbanScalingSystem(population=400, *, alpha=1.0, gamma=1.0, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The residents of a city at uniform positions in a disc.
Each resident interacts with the others as r^-gamma. The disc has the area N^alpha, so the total interaction of
a city grows as N^(2 - alpha gamma / 2) for gamma < 2, which with the population dimension D_P = 2 / alpha is
the exponent 2 - gamma / D_P of Ribeiro and Netto (2024 §4). A sweep varies population and fits the exponent
with scaling(kind='power'). The system has the positions residents.x and residents.y, the states
residents.contacts, and the observable
total_contacts of the catalog, which a run passes in observables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
population
|
int
|
The number of residents |
400
|
alpha
|
float
|
The exponent of the area of the city with its population. |
1.0
|
gamma
|
float
|
The decay exponent of an interaction with the distance. |
1.0
|
random_state
|
int | Generator | None
|
The seed or generator of the positions. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import GravityUrbanScalingSystem
>>> GravityUrbanScalingSystem(100).prepare().system_.elements[0].size
100
Source code in src/skcomplex/systems/social/organizations/_urban_scaling.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
HarvestInteraction(label, *, employers, workers, asks=1, chat=3, adjustment=0.2)
Bases: Interaction
Working day of Ajani's Choice.
Hiring happens in the morning, and wage adjustment and chat among employers in the evening. Every worker asks the
employers of its local area, the area of its slum, and moves to the other slum when its area has none. In each of
asks rounds every worker without work, in random order, asks a random employer it has not asked yet, and an
employer whose workforce is not filled offers its wage. The worker accepts if the wage is at least the minimum wage
1, if it did not work yesterday for at least the minimum wage, or if no employer is left to ask. In the evening
every employer lowers its wage by adjustment if it filled its workforce and raises it otherwise, within
[0.1, 2], and then, in random order, sets its wage to the mean wage of chat random employers. The interaction
reports the number of workers paid below the minimum wage, slaves, and of workers paid at least the minimum wage,
in_work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
employers
|
Role
|
The path of the group of employers. |
required |
workers
|
Role
|
The path of the group of workers. |
required |
asks
|
Annotated[int, NN]
|
The number of employers a worker asks for work in a day. |
1
|
chat
|
Annotated[int, NN]
|
The number of employers whose wages an employer averages in the evening. |
3
|
adjustment
|
Annotated[float, closed_open(0, oo)]
|
The change of the wage of an employer after a day. |
0.2
|
Examples:
>>> from skcomplex.systems.social.organizations import HarvestInteraction
>>> HarvestInteraction('day', employers='employers', workers='workers').chat
3
Source code in src/skcomplex/systems/social/organizations/_wages.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
work(system)
Run one working day.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_wages.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
HarvesterElement(label, *, slum=0.0, working=0.0, pay=0.0, total_pay=0.0, size=None)
Bases: Element
Migrant worker of Ajani's Choice.
It asks the employers near its slum for a day of work.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the worker or the group. |
required |
slum
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
The slum the worker lives in, 0 or 1. |
0.0
|
working
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
Whether the worker works today. |
0.0
|
pay
|
Annotated[object, closed_open(0, oo)]
|
The pay of the worker today. |
0.0
|
total_pay
|
Annotated[object, closed_open(0, oo)]
|
The pay the worker has earned so far. |
0.0
|
size
|
int | None
|
The number of members, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import HarvesterElement
>>> HarvesterElement('worker', slum=1.0).slum
1.0
Source code in src/skcomplex/systems/social/organizations/_wages.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
HarvesterView
Bases: AgentViewProtocol, Protocol
View of a worker of Ajani's Choice, with its states as attributes.
InsiderSabotageSystem(size=20, *, n_employees=130, n_supervisors=3, turnover=0.15, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The insider sabotage system of employees whose risk of sabotage builds up.
The risk builds up over the days of a year. The system has the groups employees and supervisors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
The number of rows and columns of the torus. |
20
|
n_employees
|
int
|
The number of employees. |
130
|
n_supervisors
|
int
|
The number of supervisors. |
3
|
turnover
|
float
|
The yearly share of employees who leave. |
0.15
|
random_state
|
int | Generator | None
|
The seed or generator of the predispositions and affects. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import InsiderSabotageSystem
>>> [group.size for group in InsiderSabotageSystem(n_employees=20, n_supervisors=2).prepare().system_.elements]
[20, 2]
Source code in src/skcomplex/systems/social/organizations/_sabotage.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
KauaiPopulationSystem(populations=None, *, layers=None, n_topics=2, weighted_share=0.5, events=((1, 0, 0.8),), convergence=1.0, event_rate=0.05, cell_size=1000.0, partners=15, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
One agent per resident of the census regions of a map.
The agents move between home, work, and favourite places. Every resident starts at a uniform point of its census
region, its home, and has a facility of work and a favourite place drawn uniformly. It commutes between the three in
a cycle of three steps. Its sentiment follows the rules of Zanbaka et al. in Carmichael et al. (2019 ch. 3 §4.3):
the response to events (Eq. 5) and the interaction with a partner it chooses from its grid cell (Eqs. 1, 2, and 4),
through SentimentInteraction. The default map is a synthetic island, and the occupations follow Table 1 of the
chapter. This system leaves out the base security interactions (Eq. 7), physical security information, adverse
agents, and the many favourite places and the weekly cycle of the chapter. The chapter gives the 15 partners, the
grid of 1 km, and the event rate 0.05 of its example, and it gives no value of CR, the initial sentiments, the
topic weights, or the demographics, which are choices of this system.
The system has the group residents, its states sentiment, weights, home, census, work, favourite,
visits, race, gender, occupation, and age, and the region layers in its space, where every census region
is the named region census_<k> that its residents start in.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
populations
|
Sequence[int] | None
|
The number of residents of every census region, or |
None
|
layers
|
Mapping[str, Sequence[Polygon]] | None
|
The polygons of the layers |
None
|
n_topics
|
int
|
The number of topics. |
2
|
weighted_share
|
float
|
The share of residents that weight a topic above zero. |
0.5
|
events
|
Sequence[tuple[int, int, float]]
|
The entries of the events as |
((1, 0, 0.8),)
|
convergence
|
float
|
The convergence parameter |
1.0
|
event_rate
|
float
|
The convergence rate |
0.05
|
cell_size
|
float
|
The side of the grid cells within which residents meet, in the units of the coordinates. |
1000.0
|
partners
|
int
|
The largest number of residents drawn from the grid cell as possible partners, where 0 turns the interaction off. |
15
|
random_state
|
int | Generator | None
|
The seed or generator of the initial sentiments, the weights, the demographics, the work, and the favourite places. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The populations do not name one number per census region. |
Examples:
>>> from skcomplex.systems.social.organizations import KauaiPopulationSystem
>>> KauaiPopulationSystem((3, 2, 0)).prepare().system_.elements[0].size
5
Source code in src/skcomplex/systems/social/organizations/_kauai.py
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 | |
ObesitySystem(n_people=100, *, n_places=20, size=280.0, reach=30.0, activity=1.55, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The obesity system of adults who eat near home and work, one step per day.
Homes, workplaces, and restaurants of three kinds lie at random, and the eating habits are split equally. At home,
at work, and at home again a person eats one meal at a random restaurant within reach, or at the nearest
restaurant when none is within reach, so that access changes what is eaten but never skips a meal. The system has
the groups people and restaurants.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_people
|
int
|
The number of people. |
100
|
n_places
|
int
|
The number of homes, of workplaces, and of restaurants. |
20
|
size
|
float
|
The side of the square the places lie in. |
280.0
|
reach
|
float
|
The distance within which a person looks for a restaurant. |
30.0
|
activity
|
float
|
The factor of the basal metabolic rate a person spends a day, 1.55 for moderate activity. |
1.55
|
random_state
|
int | Generator | None
|
The seed or generator of the places and the people. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import ObesitySystem
>>> [group.size for group in ObesitySystem(10, n_places=4, random_state=0).prepare().system_.elements]
[10, 4]
Source code in src/skcomplex/systems/social/organizations/_obesity.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | |
PerformanceElement(label, *, performance=1.0, perceived=1.0, desired=1.0, bias=0.1, perception_time=2.0, correction_time=2.0, goal_time=5.0, erosion=1.0)
Bases: Element
Performance element.
Source code in src/skcomplex/systems/social/organizations/_traps.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
PlaceVisitsInteraction(label, *, target)
Bases: Interaction
Count of the steps every resident stands in its favourite place.
The place is read from the regions of the layer places.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the group of residents. |
required |
Examples:
>>> from skcomplex.systems.social.organizations import PlaceVisitsInteraction
>>> PlaceVisitsInteraction('visits', target='residents').target
'residents'
Source code in src/skcomplex/systems/social/organizations/_kauai.py
267 268 269 | |
PolicyResistanceSystem(stock=50.0, *, goals=(80.0, 20.0, 50.0), strengths=(0.1, 0.1, 0.1), intensification_time=10.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Meadows' policy resistance trap.
Three actors pull one stock toward inconsistent goals. Every actor compares the stock with its own goal and pulls the stock toward it, in proportion to the discrepancy and to its strength, and intensifies its effort while the discrepancy persists, the ratchet of the book. The book's example is the drug supply on the streets, which addicts want high, enforcement agencies want low, and pushers want in the middle. The countermoves produce a standoff: the stock settles at the mean of the goals weighted by the strengths, which none of the actors wants, while the efforts of the actors above and below it grow without bound. When one actor lets up, its strength set to zero, the others drag the stock toward their own goals. The book gives the structure only, as a narrative, so the corrective rules and the parameters are a documented choice.
The system has the stock standoff.stock and the efforts standoff.effort_a, standoff.effort_b, and
standoff.effort_c, and the flows standoff.push, standoff.intensify_a, standoff.intensify_b, and
standoff.intensify_c. The observable of the system is standoff.compromise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stock
|
float
|
The initial stock. |
50.0
|
goals
|
tuple[float, float, float]
|
The goals of the three actors. |
(80.0, 20.0, 50.0)
|
strengths
|
tuple[float, float, float]
|
The rates at which the three actors pull the stock toward their goals, per unit of discrepancy. |
(0.1, 0.1, 0.1)
|
intensification_time
|
float
|
The time over which an actor doubles its effort against a persistent discrepancy. |
10.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import PolicyResistanceSystem
>>> PolicyResistanceSystem(strengths=(0.1, 0.0, 0.1)).prepare().system_.elements[0].strength_b
0.0
Source code in src/skcomplex/systems/social/organizations/_traps.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
PremisesElement(label, *, brothel=0.0, bills=0.0, last_bills=0.0, efficiency=1.0, day=0.0, values=None, size=None, space=None)
Bases: Element
House or brothel of the brothel movement system.
Its energy bills grow with the people inside. Every day the bills grow by 1 / (1 + exp(x0 - n)) for the n people
in the premises' cell, and every quarter they are recorded and reset. In TraffickingSystem, maps of the bills read
the counts of the women by cell every day, and maps in a phase of a period of 90 days record and reset them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
brothel
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
Whether the premises are a brothel, 1, or a house, 0. |
0.0
|
bills
|
Annotated[object, closed_open(0, oo)]
|
The bills of the current quarter. |
0.0
|
last_bills
|
Annotated[object, closed_open(0, oo)]
|
The bills of the last full quarter. |
0.0
|
efficiency
|
object
|
The midpoint |
1.0
|
day
|
Annotated[object, NN]
|
The number of days run. |
0.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the cell |
None
|
size
|
int | None
|
The number of members, or |
None
|
space
|
BaseSpace | None
|
The grid whose axes |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import PremisesElement
>>> group = PremisesElement('premises', brothel=1.0, size=3)
>>> group.label, group.size
('premises', 3)
Source code in src/skcomplex/systems/social/organizations/_trafficking.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
PremisesView
Bases: AgentViewProtocol, Protocol
View of a premises of the trafficking system.
Its states and parameters are attributes.
PriorityQueuesSystem(n_tasks=2, *, greed=0.99999, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The Barabási priority queue.
Its waiting times follow a power law as the choice becomes greedy. The system has the group tasks and the
execution execution, which reports the waiting time of the task it executes at every step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_tasks
|
int
|
The length of the list of tasks. |
2
|
greed
|
float
|
The probability that the highest priority task is executed rather than a random one. |
0.99999
|
random_state
|
int | Generator | None
|
The seed or generator of the initial priorities. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import PriorityQueuesSystem
>>> PriorityQueuesSystem(3, random_state=0).prepare().system_.elements[0].size
3
Source code in src/skcomplex/systems/social/organizations/_queues.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
ResidentElement(label, *, sentiment=0.0, weights=(0.0,), home=(math.nan, math.nan), census=0.0, work=0.0, favourite=0.0, visits=0.0, race=0.0, gender=0.0, occupation=0.0, age=0.0, convergence=1.0, event_rate=0.05, cell_size=1000.0, partners=15.0, values=None, size=None, space=None)
Bases: Element
Resident of the Kauai population system.
The resident lives, works, and spends time at points of a map. A resident starts at its home, a point of its census
region, which the value region names, such as values={'region': 'census_0'}. It holds a sentiment between -1 and
1, one weight per topic of the events that move the sentiment, and the demographic scalars of Carmichael et al.
(2019 ch. 3 §4.2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
sentiment
|
Annotated[object, closed(-1, 1)]
|
The initial sentiment. |
0.0
|
weights
|
ArrayLike
|
The weight of every topic. |
(0.0,)
|
home
|
ArrayLike
|
The point of the home, which the first commute sets to the initial location. |
(nan, nan)
|
census
|
object
|
The index of the census region of the home. |
0.0
|
work
|
object
|
The index of the facility of the work. |
0.0
|
favourite
|
object
|
The index of the favourite place. |
0.0
|
visits
|
object
|
The number of steps the resident stood in its favourite place. |
0.0
|
race
|
object
|
The index of the race. |
0.0
|
gender
|
object
|
The index of the gender. |
0.0
|
occupation
|
object
|
The index of the occupation. |
0.0
|
age
|
object
|
The age in years. |
0.0
|
convergence
|
Annotated[object, closed(0, 1)]
|
The immutable convergence parameter |
1.0
|
event_rate
|
Annotated[object, closed(0, 1)]
|
The convergence rate |
0.05
|
cell_size
|
Annotated[object, open(0, oo)]
|
The side of the grid cells of the space within which residents meet. |
1000.0
|
partners
|
Annotated[object, closed_open(0, oo)]
|
The largest number of residents drawn from the grid cell as possible partners. |
15.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the region |
None
|
size
|
int | None
|
The number of residents, or |
None
|
space
|
BaseSpace | None
|
The continuous space the residents live in, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import ResidentElement
>>> ResidentElement('residents', size=10).size
10
Source code in src/skcomplex/systems/social/organizations/_kauai.py
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 | |
ResidentView
Bases: AgentViewProtocol, Protocol
View of a resident of the Kauai population system.
Its states and parameters are attributes.
RestaurantElement(label, *, kind=0.0, sold=0.0, sold_high=0.0, values=None, size=None, space=None)
Bases: Element
Restaurant of the obesity system.
It is a market at 0, a restaurant at 1, or a fast food outlet at 2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
kind
|
Annotated[object, NN]
|
The kind of restaurant. |
0.0
|
sold
|
Annotated[object, NN]
|
The number of meals sold. |
0.0
|
sold_high
|
Annotated[object, NN]
|
The number of meals sold from the top half of the restaurant's calorie range. |
0.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the position |
None
|
size
|
int | None
|
The number of members, or |
None
|
space
|
BaseSpace | None
|
The plane whose axes |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import RestaurantElement
>>> group = RestaurantElement('restaurants', kind=2.0, size=3)
>>> group.label, group.size
('restaurants', 3)
Source code in src/skcomplex/systems/social/organizations/_obesity.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
RestaurantView
Bases: AgentViewProtocol, Protocol
View of a restaurant of the obesity system.
Its states and parameters are attributes.
SentimentInteraction(label, *, target, events=())
Bases: Interaction
Sentiment of every resident.
It responds to events and to the partner the resident chooses at each step. The rules are those of Zanbaka et al. in
Carmichael et al. (2019 ch. 3 §4.3). An event is one or more entries (time, topic, weight), and it changes the
sentiment S to S + sum(mu A_T (E_T - S)) over its topics, with mu the parameter event_rate of the resident,
A_T its weight of the topic, and E_T the weight of the event (Eq. 5). The partner is the most likely of at most
partners residents drawn from the grid cell of the resident, by P = DSS / 2 + STI / 2, with DSS the mean of
five similarities and STI the share of topics both weigh (Eqs. 1 and 2). The two sentiments then change at once to
a1 + mu1 (a2 - a1) and a2 + mu2 (a1 - a2), with mu = 1 - |a| CR of each and CR its parameter convergence
(Eq. 4). The chapter prints no definition of the terms of DSS, so here race, gender, and occupation count 1 when
equal and 0 otherwise, and age and sentiment count one minus their distance over their range. A sentiment stays
between -1 and 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction, unique among the components of its system. |
required |
target
|
Role
|
The path of the group of residents. |
required |
events
|
Sequence[tuple[int, int, float]]
|
The entries of the events as |
()
|
Examples:
>>> from skcomplex.systems.social.organizations import SentimentInteraction
>>> SentimentInteraction('sentiment', target='residents', events=[(1, 0, 0.5)]).events
[(1, 0, 0.5)]
Source code in src/skcomplex/systems/social/organizations/_kauai.py
320 321 322 323 324 325 326 327 328 329 | |
ShiftingTheBurdenSystem(capability=0.5, intervention=0.0, *, desired=1.0, fix_rate=1.0, build_time=5.0, solution_delay=2.0, erosion=0.5, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Meadows' shifting the burden trap.
A quick fix relieves a symptom and erodes the system's capability. The symptom is the gap between the desired state
and the state that the capability of the system and an outside intervention deliver together. The intervention grows
quickly with the symptom. The capability grows slowly with the symptom, perceived over the solution delay, and the
intervention erodes it as a side effect. With a quick fix the intervention takes over and the capability withers
away, an addiction. Without one, fix_rate = 0, the capability grows to the desired state. The book gives the
structure only, so the parameters are a documented choice.
The system has the capability burden.capability and the intervention burden.intervention in years, the flows
burden.fixing, burden.building, and burden.erosion. The observable of the system is burden.symptom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
capability
|
float
|
The initial capability of the system to deliver the desired state on its own. |
0.5
|
intervention
|
float
|
The initial level of the intervention. |
0.0
|
desired
|
float
|
The desired state. |
1.0
|
fix_rate
|
float
|
The rate at which the intervention grows per unit of symptom, 0 for no quick fix. |
1.0
|
build_time
|
float
|
The time the fundamental solution needs to close a perceived symptom. |
5.0
|
solution_delay
|
float
|
The time over which the fundamental solution perceives the symptom. |
2.0
|
erosion
|
float
|
The rate at which a unit of intervention erodes the capability. |
0.5
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import ShiftingTheBurdenSystem
>>> ShiftingTheBurdenSystem(fix_rate=0.0).prepare().system_.elements[0].fix_rate
0.0
Source code in src/skcomplex/systems/social/organizations/_traps.py
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
StandoffElement(label, *, stock=50.0, effort_a=0.0, effort_b=0.0, effort_c=0.0, goal_a=80.0, goal_b=20.0, goal_c=50.0, strength_a=0.1, strength_b=0.1, strength_c=0.1, intensification_time=10.0)
Bases: Element
Standoff element.
Source code in src/skcomplex/systems/social/organizations/_traps.py
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 | |
SuccessToTheSuccessfulSystem(a=55.0, b=45.0, *, budget=10.0, lifetime=10.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Meadows' success to the successful trap.
Two competitors share a budget by their past success. Each competitor holds a stock of resources that its share of the budget fills and that depreciates over its lifetime. The share of the first competitor is a table function of its success, its fraction of all resources, that gives more than a proportional share to the more successful one. The two reinforcing loops make the symmetric state unstable, so the competitor that starts larger ends with the whole budget and the other one disappears. The book gives the structure only, so the table and the parameters are a documented choice.
The system has the resources contest.a and contest.b in years, the flows contest.allocation_a,
contest.allocation_b, contest.depreciation_a, and contest.depreciation_b. The observables of the system are
contest.success and contest.allocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
The initial resources of the first competitor. |
55.0
|
b
|
float
|
The initial resources of the second competitor. |
45.0
|
budget
|
float
|
The resources allocated per year. |
10.0
|
lifetime
|
float
|
The average lifetime of resources, in years. |
10.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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import SuccessToTheSuccessfulSystem
>>> SuccessToTheSuccessfulSystem(a=60.0).prepare().system_.elements[0].a
60.0
Source code in src/skcomplex/systems/social/organizations/_traps.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
SupplierElement(label, *, adopted=0.0, inflow=0.0, outflow=0.0, size=None)
Bases: Element
Firm of a supply chain, a buyer or a factory.
It holds the value of the goods that flow into and out of it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the firm or the group. |
required |
adopted
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
Whether the firm has adopted good working conditions. |
0.0
|
inflow
|
Annotated[object, closed_open(0, oo)]
|
The total value |
0.0
|
outflow
|
Annotated[object, closed_open(0, oo)]
|
The total value |
0.0
|
size
|
int | None
|
The number of members, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import SupplierElement
>>> SupplierElement('factory', outflow=6.0).outflow
6.0
Source code in src/skcomplex/systems/social/organizations/_supply_chains.py
70 71 72 73 74 75 76 77 78 79 80 81 82 | |
SupplierView
Bases: AgentViewProtocol, Protocol
View of a firm of the supply chain diffusion system.
Its states are attributes.
SupplyChainDiffusionSystem(graph=None, *, buyers=3, factories=40, seeds=2, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Chesney's Namrata's Family.
Buyers push good working conditions down their supply network. Goods flow from suppliers to buyers along the
weighted edges of a directed network, w_ji from j to i. A buyer i that has adopted forces a supplier j to
adopt when it is less beholden to the supplier than the supplier is to it,
V_ij = w_ji / w_->i < V_ji = w_ji / w_j->, where w_->i is the total value that flows into i and w_j-> the
total value that flows out of j, with a strict inequality since factories resist by default (Chesney 2021 sections
4.9 and 4.10). A seed group of buyers adopts at the start, and in every time period the firms that adopted in the
previous one push their suppliers. Since the condition reads w_->i > w_j->, a buyer with a single supplier never
forces it, so diffusion needs buyers with two or more suppliers (section 4.11). The default network has buyers
buyers and factories factories, every factory supplying one to three random firms listed before it with values
from 1 to 10.
The system has the group firms on the nodes of the network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
object
|
A NetworkX directed graph of the supply network with the values of the goods as the edge attribute
|
None
|
buyers
|
int
|
The number of buyers, the first nodes, of the default network. |
3
|
factories
|
int
|
The number of factories of the default network. |
40
|
seeds
|
int
|
The number of the first nodes that adopt at the start. |
2
|
random_state
|
int | Generator | None
|
The seed or generator of the default network. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import SupplyChainDiffusionSystem
>>> SupplyChainDiffusionSystem(factories=10).prepare().system_.elements[0].size
13
Source code in src/skcomplex/systems/social/organizations/_supply_chains.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
TaskElement(label, *, priority=0.5, age=0.0, wait=0.0, greed=0.99999, size=None)
Bases: Element
Task of the Barabási priority queue.
It holds a priority, an age, and the waiting time when it was last executed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
priority
|
Annotated[object, closed_open(0, oo)]
|
The priority, uniform on 0 to 1 for a new task. |
0.5
|
age
|
Annotated[object, NN]
|
The number of steps the task has waited. |
0.0
|
wait
|
Annotated[object, NN]
|
The waiting time of the last task executed from this slot of the list. |
0.0
|
greed
|
Annotated[object, closed_open(0, oo)]
|
The probability that the highest priority task is executed rather than a random one. |
0.99999
|
size
|
int | None
|
The number of members, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import TaskElement
>>> group = TaskElement('tasks', priority=[0.2, 0.7], size=2)
>>> group.label, type(group).__name__, group.size
('tasks', 'TaskElement', 2)
Source code in src/skcomplex/systems/social/organizations/_queues.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
TaskView
Bases: AgentViewProtocol, Protocol
View of a task of the priority queue system.
Its states and parameters are attributes.
TraffickingSystem(width=30, height=30, *, n_cities=3, n_houses=40, n_brothels=3, n_victims=12, n_free=30, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
The brothel movement system.
Victims moved between brothels leave traces in bills and train trips. The system has the groups premises and
women.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
int
|
The number of columns of the grid. |
30
|
height
|
int
|
The number of rows of the grid. |
30
|
n_cities
|
int
|
The number of cities, vertical bands of equal width. |
3
|
n_houses
|
int
|
The number of houses. |
40
|
n_brothels
|
int
|
The number of brothels. |
3
|
n_victims
|
int
|
The number of victims, spread over the brothels. |
12
|
n_free
|
int
|
The number of women who travel freely. |
30
|
random_state
|
int | Generator | None
|
The seed or generator of the places, the women, and the efficiencies. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import TraffickingSystem
>>> system = TraffickingSystem(n_houses=5, n_brothels=2, n_victims=4, n_free=3).prepare().system_
>>> [group.size for group in system.elements]
[7, 7]
Source code in src/skcomplex/systems/social/organizations/_trafficking.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | |
TravellerElement(label, *, victim=0.0, trips=0.0, values=None, size=None, space=None)
Bases: Element
Woman of the brothel movement system.
She is a trafficking victim, or a woman who travels freely.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
victim
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
Whether the woman is a trafficking victim, 1, or not, 0. |
0.0
|
trips
|
Annotated[object, NN]
|
The number of train trips between cities. |
0.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the cell |
None
|
size
|
int | None
|
The number of members, or |
None
|
space
|
BaseSpace | None
|
The grid whose axes |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import TravellerElement
>>> group = TravellerElement('women', victim=1.0, size=4)
>>> group.label, group.size
('women', 4)
Source code in src/skcomplex/systems/social/organizations/_trafficking.py
161 162 163 164 165 166 167 168 169 170 171 172 173 | |
TravellerView
Bases: AgentViewProtocol, Protocol
View of a woman of the trafficking system.
Its states and parameters are attributes.
UrbanScalingInteractionsSystem(population=300, *, edges=2, internal=0.002, meeting=0.5, exponent=2.5, temperature=0.2, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A city that grows by residents and internal links.
Its meetings grow faster than its population. Every step a resident joins at a uniform angle and adds edges links
to residents drawn in proportion to the Fermi-Dirac probability of their hyperbolic distance, as in
popularity-similarity growth (Papadopoulos et al. 2012). Every resident also adds an internal link with the
probability internal per step, toward the same weight, so the links per step and the mean degree grow with the
size. This rate per resident is the assumption of this system, since Papadopoulos et al. (2015) add a fixed number
of internal links per step and keep the mean degree constant. Every resident meets each neighbour with the
probability meeting per step. The growth and the internal links stop when the city holds population residents,
so one run time reaches every size. A sweep varies population, and scaling(kind='allometric') fits the
exponent of the meetings, which Ribeiro and Netto (2024) review near 1.15 for socioeconomic quantities, and which
the rate internal sets here.
The system has the groups residents and links, the states residents.angle, residents.age,
residents.degree, and residents.meetings, and the observable total_meetings of the catalog, which a run passes
in observables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
population
|
int
|
The number of residents the city holds room for. |
300
|
edges
|
int
|
The number of links of every new resident, and one less than the residents of the complete seed city. |
2
|
internal
|
float
|
The probability per step that a resident adds an internal link. |
0.002
|
meeting
|
float
|
The probability per step that a resident meets one neighbour. |
0.5
|
exponent
|
float
|
The exponent of the distribution of the links of the growth without internal links, above 2. |
2.5
|
temperature
|
float
|
The temperature of the network, between 0 and 1. |
0.2
|
random_state
|
int | Generator | None
|
The seed or generator of the angles of the seed city. |
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The exponent is not above 2, or the temperature is not between 0 and 1. |
Examples:
>>> from skcomplex.systems.social.organizations import UrbanScalingInteractionsSystem
>>> trajectory = UrbanScalingInteractionsSystem(13, internal=0.0).prepare().simulate(until=10, random_state=0)
>>> int(trajectory.get_network(-1).sources.size)
23
Source code in src/skcomplex/systems/social/organizations/_urban_interactions.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
WanderInteraction(label, *, target)
Bases: Interaction
Wander and fight of the contenders of the Bonabeau system.
Every step every contender relaxes its strength by the fraction relaxation, then steps into a random neighbouring
cell, and when the cell is occupied it fights the occupant, winning with the probability
1 / (1 + exp(eta (s_occupant - s_agent))). The winner gains one unit of strength and takes the cell, and the loser
loses one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of contenders. |
required |
Examples:
>>> from skcomplex.systems.social.organizations import WanderInteraction
>>> WanderInteraction('wander', target='contenders').target
'contenders'
Source code in src/skcomplex/systems/social/organizations/_hierarchies.py
125 126 127 | |
wander(agent, system)
Relax the strength, then step into a random neighbouring cell.
An occupied cell makes the agent fight its occupant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
ContenderView
|
The contender. |
required |
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/social/organizations/_hierarchies.py
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 | |
WatchmakerElement(label, *, progress=0.0, done=0.0, watches=0.0, task_size=10.0, tasks=111.0, size=None)
Bases: Element
Watchmaker who assembles a watch.
The watch is a number of tasks of a number of actions each.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the watchmaker or the group. |
required |
progress
|
Annotated[object, NN]
|
The number of actions done on the task in hand, which an interruption undoes. |
0.0
|
done
|
Annotated[object, NN]
|
The number of stable tasks done on the watch in hand. |
0.0
|
watches
|
Annotated[object, NN]
|
The number of finished watches. |
0.0
|
task_size
|
Annotated[object, NN]
|
The number of actions of a task, the parts or subassemblies put together into a stable assembly. |
10.0
|
tasks
|
Annotated[object, NN]
|
The number of tasks of a watch. |
111.0
|
size
|
int | None
|
The number of members, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import WatchmakerElement
>>> WatchmakerElement('tempus', task_size=1000.0, tasks=1.0).task_size
1000.0
Source code in src/skcomplex/systems/social/organizations/_watchmakers.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
WatchmakerView
Bases: AgentViewProtocol, Protocol
View of a watchmaker of the Hora and Tempus fable.
Its states and parameters are attributes.
WatchmakersSystem(parts=1000, *, subassembly=10, interruption=0.01, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Simon's fable of the watchmakers Hora and Tempus, told by Meadows.
The watchmakers work with and without stable subassemblies. Both watchmakers build watches of parts parts. Tempus
puts all of them together at once, so an interruption, a customer's call, makes the unfinished watch fall to pieces.
Hora puts together stable subassemblies of subassembly elements, then assemblies of those, up to the whole watch,
so an interruption loses only the assembly in hand. Hora has more actions to take, parts - 1 divided by
subassembly - 1 tasks of subassembly actions each, 111 tasks of 10 actions for 1000 parts. A task of k actions
interrupted with the probability p at every action takes ((1 - p)^-k - 1) / p actions on average, so at
p = 0.01 Hora finishes a watch every 1173 steps and Tempus one every 2.3 million steps. The book tells the fable
as a narrative, so the step of one action and the interruption at every action follow Simon's original telling.
The system has the group watchmakers, Hora first and Tempus second.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parts
|
int
|
The number of parts of a watch, a power of |
1000
|
subassembly
|
int
|
The number of elements of a stable assembly of Hora. |
10
|
interruption
|
float
|
The probability that a watchmaker is interrupted at an action. |
0.01
|
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'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.social.organizations import WatchmakersSystem
>>> WatchmakersSystem().prepare().system_.elements[0].size
2
Source code in src/skcomplex/systems/social/organizations/_watchmakers.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
WorkplaceElement(label, *, colour=0, employer=0, space=None)
Bases: Element
Cell of the employment takeover system.
It is an employer, white 0 or black 1, or a worker, red 0 or blue 1. Employers and workers alternate like the
squares of a checkerboard. Every step each worker first takes the colour of the employer to its right, at x + 1.
Then each employer turns black when at least three of its four workers are blue, stays as it is when two are, and
turns white otherwise. The two phases are local rule interactions of the lattice, which EmploymentTakeoverSystem
adds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the cell or the lattice group. |
required |
colour
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
The initial colour, 0 or 1. |
0
|
employer
|
Annotated[object, FiniteEnumeratedSet([0, 1])]
|
Whether the cell is an employer, 1, or a worker, 0. |
0
|
space
|
BaseSpace | None
|
The space with one member per site, or |
None
|
Examples:
>>> from skcomplex.systems.social.organizations import WorkplaceElement
>>> WorkplaceElement('cell', employer=1).employer
1
Source code in src/skcomplex/systems/social/organizations/_employment.py
59 60 61 62 63 64 65 66 67 68 69 | |
basal_metabolic_rate(weight, height, age, male)
Return the daily basal metabolic rate of the revised Harris-Benedict equation.
It is in kilocalories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight
|
float
|
The weight in kilograms. |
required |
height
|
float
|
The height in centimetres. |
required |
age
|
float
|
The age in years. |
required |
male
|
float
|
1 for a man and 0 for a woman. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
rate |
float
|
The basal metabolic rate per day. |
Examples:
>>> from skcomplex.systems.social.organizations import basal_metabolic_rate
>>> round(basal_metabolic_rate(70.0, 175.0, 30.0, 1.0))
1696
Source code in src/skcomplex/systems/social/organizations/_obesity.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
load_island_layers()
Return the polygons of every layer of the synthetic island.
They are in a metric coordinate system.
Returns:
| Name | Type | Description |
|---|---|---|
layers |
dict[str, list[Polygon]]
|
The polygons of the layers |
Examples:
>>> from skcomplex.systems.social.organizations import load_island_layers
>>> {layer: len(polygons) for layer, polygons in load_island_layers().items()}
{'boundary': 1, 'census': 3, 'places': 3, 'facilities': 2}
Source code in src/skcomplex/systems/social/organizations/_kauai.py
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
load_island_populations()
Return the number of residents of every census region of the synthetic island.
The regions are those of the census layer.
Returns:
| Name | Type | Description |
|---|---|---|
populations |
list[int]
|
The population of every census region, in the order of the regions of the layer. |
Examples:
>>> from skcomplex.systems.social.organizations import load_island_populations
>>> load_island_populations()
[100, 50, 0]
Source code in src/skcomplex/systems/social/organizations/_kauai.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |