Resources
Natural resources: harvesting, extracting, and cultivating stocks.
The stocks are renewable and nonrenewable.
BidRentInteraction(label, *, target, yields, prices, costs, rates)
Bases: Interaction
Land use of highest bid rent.
Crop i bids Y_i (p_i - c_i) - Y_i f_i d at the distance d of a market. A cell grows the crop of the highest
positive bid, and lies idle as crop 0 when no bid is positive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the field of cells, whose members hold |
required |
yields
|
Sequence[float]
|
The yield |
required |
prices
|
Sequence[float]
|
The price |
required |
costs
|
Sequence[float]
|
The cost |
required |
rates
|
Sequence[float]
|
The transport rate |
required |
Raises:
| Type | Description |
|---|---|
ValidationError
|
The four sequences do not have one value per crop, raised by |
Examples:
>>> from skcomplex.systems.economics.resources import BidRentInteraction
>>> bid = BidRentInteraction('bid', target='plain', yields=(2.0,), prices=(3.0,), costs=(1.0,), rates=(0.1,))
>>> bid.rates
(0.1,)
Source code in src/skcomplex/systems/economics/resources/_land_use.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
CatchInteraction(label, *, target, resource='land/stock.n', effort='harvest.effort')
Bases: Interaction
Catch of every farmer, who adds the effort times the resource stock to its wealth.
The farmers read the stock from another subsystem at its last synchronisation point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the group of farmers. |
required |
resource
|
str
|
The dotted name of the resource stock. |
'land/stock.n'
|
effort
|
str
|
The dotted name of the harvest effort per farmer. |
'harvest.effort'
|
Examples:
>>> from skcomplex.systems.economics.resources import CatchInteraction
>>> CatchInteraction('catch', target='farmers').resource
'land/stock.n'
Source code in src/skcomplex/systems/economics/resources/_harvesting.py
172 173 174 175 176 177 178 179 180 181 182 183 | |
catch(agent, system)
Add the effort times the resource stock to the wealth.
The stock is read at the last synchronisation point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
FarmerView
|
The farmer. |
required |
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/economics/resources/_harvesting.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
CocoaSystem(area=10.0, *, price=40.0, cost=100.0, insect_growth=0.6, subsidy=0.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A cocoa production system, plantations that boom and bust.
They boom with their profit and bust with the insects they invite. The planted area moves towards a desired area, the current area times a table function of the profit margin, so a profitable crop expands it. Farmers thin the shading trees, which raises the yield through an intensification table but lets the insects multiply. Insect attack lowers the yield through an ecological table, and the area is abandoned at a rate that falls with the yield and the profit through two more tables. Abandoned land is converted to oil palm. A subsidy for shade conservation and pest control slows the thinning and controls the insects. Land is conserved, so the area booms while the yield is high and busts once the insects take over, unless a subsidy keeps the shade. The structure and the five table functions follow the boom and bust of cocoa in Malaysia of Bala, Arshad and Noh (2017, Chapter 8), and the rates, the price, and the costs are illustrative, with the area in thousands of hectares, the yield in hundreds of kilograms per hectare, the money in ringgit per hundred kilograms and per hectare, the shade removal and the insect attack as indices from 0 to 100, and time in years.
The system has the land stocks cocoa.area and cocoa.abandoned, the indices cocoa.shade_removal and
cocoa.insects, and the flows cocoa.planting, cocoa.abandonment, and cocoa.conversion per year, over years.
The observables of the system are cocoa.cocoa_yield, cocoa.profit_per_area, and cocoa.profitability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area
|
float
|
The initial planted area. |
10.0
|
price
|
float
|
The farm price of cocoa. |
40.0
|
cost
|
float
|
The operating cost per hectare. |
100.0
|
insect_growth
|
float
|
The largest relative growth rate of the insect attack, reached with all shade removed. |
0.6
|
subsidy
|
float
|
The coverage of the subsidy and extension programme, from 0 to 1. |
0.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.economics.resources import CocoaSystem
>>> CocoaSystem(subsidy=1.0).prepare().system_.elements[0].subsidy
1.0
Source code in src/skcomplex/systems/economics/resources/_plantations.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
CowElement(label, *, owner=-1.0, energy=4.0, values=None, size=None, space=None)
Bases: Element
Cow of a herder that gains the energy of the grass it eats.
It burns its metabolism, and starves without food.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
owner
|
Annotated[object, Member(herders)]
|
The herder that owns the cow among the herders. |
-1.0
|
energy
|
object
|
The energy of the cow. |
4.0
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the cells |
None
|
size
|
int | None
|
The number of cows, or |
None
|
space
|
BaseSpace | None
|
The meadow the cows live on, whose axes |
None
|
Examples:
>>> from skcomplex.systems.economics.resources import CowElement
>>> CowElement('cows', energy=4.0, size=3).size
3
Source code in src/skcomplex/systems/economics/resources/_commons.py
154 155 156 157 158 159 160 161 162 163 164 165 166 | |
CropLivestockHouseholdSystem(wealth=10000.0, livestock=4.0, *, crop_area=0.5, yield_normal=3.2, price=50000.0, unit_price=35000.0, purchase_price=15000.0, household_consumption=75000.0, max_livestock=8.0, sale_fraction=0.2, label='system', solver='auto', backend='auto')
Bases: DynamicalSystem
Bala's crop livestock model.
A farming household adds livestock rearing to its crop income. A household with a fixed crop area and a grant or
loan to start rearing livestock earns the crop production times the price and the sales of animals, and spends on
its consumption and on buying animals. Every year it sells the integer part of a fraction of its herd and buys as
many animals as its wealth affords when the herd has room for them, and the animals it buys join the herd after
three years. The equations and the defaults are those of the STELLA model of Bala et al. (2017, Section 4.11.6),
whose DELAY(purchase_of_livestock, 3) is a pipeline of three years and whose INT truncates, so the model is a
yearly map. The effects of the cropping intensity and the regeneration on the yield are zero. Livestock raises the
income of the household considerably, but only after the maturation delay.
The system has the stocks household.wealth, household.livestock, and household.yield_multiplier, and the
purchases of the previous year household.purchases, over years. The observables of the system are
household.crop_production, household.income_from_crop, household.income_from_livestock, household.sale, and
household.purchase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wealth
|
float
|
The initial wealth of the household. |
10000.0
|
livestock
|
float
|
The initial herd. |
4.0
|
crop_area
|
float
|
The crop area, in hectares. |
0.5
|
yield_normal
|
float
|
The normal crop yield, in tonnes per hectare. |
3.2
|
price
|
float
|
The price of a tonne of crop. |
50000.0
|
unit_price
|
float
|
The price an animal sells for. |
35000.0
|
purchase_price
|
float
|
The price of an animal bought. |
15000.0
|
household_consumption
|
float
|
The consumption of the household per year. |
75000.0
|
max_livestock
|
float
|
The largest herd the household can rear. |
8.0
|
sale_fraction
|
float
|
The fraction of the herd sold every year. |
0.2
|
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.economics.resources import CropLivestockHouseholdSystem
>>> CropLivestockHouseholdSystem(wealth=20000.0).prepare().system_.elements[0].values['wealth']
20000.0
Source code in src/skcomplex/systems/economics/resources/_crop_livestock.py
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 | |
FarmerElement(label, *, wealth=0.0, values=None, size=None, space=None)
Bases: Element
Farmer who adds the catch of every step to its wealth, by CatchInteraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
wealth
|
Annotated[object, closed_open(0, oo)]
|
The initial wealth. |
0.0
|
values
|
Mapping[str, object] | None
|
Further values by name, or |
None
|
size
|
int | None
|
The number of farmers, or |
None
|
space
|
BaseSpace | None
|
The space of the farmers, or |
None
|
Examples:
>>> from skcomplex.systems.economics.resources import FarmerElement
>>> FarmerElement('farmers', size=10).size
10
Source code in src/skcomplex/systems/economics/resources/_harvesting.py
133 134 135 136 137 138 139 140 141 142 143 | |
FisheryCapitalSystem(resource=1000.0, capital=5.0, *, cost=1.0, growth_goal=0.1, lifetime=20.0, yield_table=FISH_YIELD, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Meadows' fishing fleet, capital that grows on a renewable resource.
The capital can overshoot the resource. The capital grows while the harvest pays, and the outcome depends on the
yield per unit of capital. With the default yield, which falls with the square of the stock, the fleet and the stock
settle at an equilibrium. A technology that keeps the yield high at low stocks lets the fleet overshoot, and the
stock and then the fleet collapse. The system has the resource fishery.resource and the capital fishery.capital.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
float
|
The initial resource stock. |
1000.0
|
capital
|
float
|
The initial capital. |
5.0
|
cost
|
float
|
The operating cost per unit of capital. |
1.0
|
growth_goal
|
float
|
The largest investment per unit of capital. |
0.1
|
lifetime
|
float
|
The average lifetime of the capital. |
20.0
|
yield_table
|
Sequence[float]
|
The yield per unit of capital at the resource levels 0, 100, ..., 1000. |
FISH_YIELD
|
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.economics.resources import FisheryCapitalSystem
>>> FisheryCapitalSystem(lifetime=10.0).prepare().system_.elements[0].lifetime
10.0
Source code in src/skcomplex/systems/economics/resources/_extraction.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
FisheryElement(label, *, resource=1000.0, capital=5.0, cost=1.0, growth_goal=0.1, lifetime=20.0, yield_table=FISH_YIELD, regeneration_table=REGENERATION, price_table=PRICE_BY_YIELD)
Bases: Element
Capital that harvests a regenerating resource.
Its price rises as the yield falls. The resource regenerates at a rate per unit of stock that is a hump-shaped table of the stock, zero when it is empty or full. The harvest is the capital times the yield per unit of capital, a table of the stock. The fishery holds the stocks, the parameters, and the tables, and transfers within it of the system move the resource and the capital.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the fishery. |
required |
resource
|
Annotated[float, closed_open(0, oo), Quantity(fish)]
|
The initial resource stock. |
1000.0
|
capital
|
Annotated[float, closed_open(0, oo), Quantity(capital)]
|
The initial capital. |
5.0
|
cost
|
Annotated[float, closed_open(0, oo)]
|
The operating cost per unit of capital. |
1.0
|
growth_goal
|
Annotated[float, closed_open(0, oo)]
|
The largest investment per unit of capital. |
0.1
|
lifetime
|
Annotated[float, open(0, oo)]
|
The average lifetime of the capital. |
20.0
|
yield_table
|
Sequence[float]
|
The yield per unit of capital at the resource levels 0, 100, ..., 1000. |
FISH_YIELD
|
regeneration_table
|
Sequence[float]
|
The regeneration rate at the resource levels 0, 100, ..., 1000. |
REGENERATION
|
price_table
|
Sequence[float]
|
The price at the yields 0, 0.1, 0.2, 0.4, 0.6, 0.8, and 1. |
PRICE_BY_YIELD
|
Examples:
>>> from skcomplex.systems.economics.resources import FisheryElement
>>> FisheryElement('fishery', lifetime=15.0).lifetime
15.0
Source code in src/skcomplex/systems/economics/resources/_extraction.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
FisheryMeasurementErrorsSystem(n_fisheries=200, *, x=0.5, r0=1.0, sigma_r=1.0, K=1.0, error=0.0, step=0.01, restocking=False, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Independent fisheries whose quota is set from a measurement of the stock.
The measurement has a Gaussian error. The fish stock grows logistically with a growth rate R0 + sigma_R W(t) that
white noise W makes random, and the fishermen harvest the quota gamma(x~) = x~ - K / 2 from their measurement
x~ = x + e(t), Problem 14.8 of Argun et al. (2021). The harvest of the deterministic system peaks at x = K / 2,
at R0 K / 4, and the quota rule holds the stock at K / sqrt(2), where the growth R0 x (1 - x / K) equals the
quota. The problem asks whether the extinction probability can fall as the measurement error grows, after Argun et
al. (2016). A quota is a catch, so it is floored at zero, and restocking lets a negative quota release fish as the
formula of the source does. Every member of the group fisheries is an independent replica, so the share of extinct
stocks estimates the extinction probability, and a step is an Euler-Maruyama step of length step.
The system has the group fisheries of the stocks fisheries.x and the quotas fisheries.catch. The observables
of the system are the share of extinct stocks extinct, the mean stock mean_stock, and the mean quota
mean_catch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_fisheries
|
int
|
The number of independent fisheries. |
200
|
x
|
float
|
The initial stock. |
0.5
|
r0
|
float
|
The mean growth rate. |
1.0
|
sigma_r
|
float
|
The standard deviation of the noise of the growth rate. |
1.0
|
K
|
float
|
The carrying capacity. |
1.0
|
error
|
float
|
The standard deviation of the measurement error. |
0.0
|
step
|
float
|
The length of a step in units of time. |
0.01
|
restocking
|
bool
|
Whether a negative quota releases fish. |
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.economics.resources import FisheryMeasurementErrorsSystem
>>> FisheryMeasurementErrorsSystem(10).prepare().system_.elements[0].size
10
Source code in src/skcomplex/systems/economics/resources/_measurement_errors.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
FoodSecuritySystem(*, subsidy=0.67, bio_target=0.0, research=0.0, training_target=0.0, intensity_target=1.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A food security system, the rice self-sufficiency of a country.
The country acts by subsidy, research, and extension. The land suitable for rice is developed into rice area over eight years, and the rice area is discarded for housing, roads, and industry at a small fraction per year. The production is the milled share of the productivity times the area times the cropping intensity. The productivity is the potential yield, which research raises towards a limit, times a table of the input ratio, the soil quality, which chemical fertiliser degrades and fallow regenerates, and the farming practice, which training and extension improve through a learning table. The input ratio is the share of the recommended fertiliser that the farmers apply, which the subsidy raises, and a target share of bio-fertiliser replaces the chemical one without degrading the soil. The requirement is the per capita consumption of a population growing exponentially, and the self-sufficiency level is the production over the requirement. Land is conserved, so the rice area peaks once the suitable land is developed and then declines, and without research and extension the self-sufficiency falls as the population grows. The structure and the initial values follow the food security system of Malaysia of Bala, Arshad and Noh (2017, Chapter 10), and the table functions and the rates are illustrative, with the land in millions of hectares, the population in millions, the productivity in tonnes of paddy per hectare, the rice in millions of tonnes, and time in years.
The system has the land stocks rice.available_land and rice.rice_area, the population rice.population, the
factors rice.potential, rice.soil_quality, rice.practice, rice.training, rice.bio_fraction, and
rice.cropping_intensity, and the flows rice.development, rice.discard, and rice.population_growth per year,
over years. The observables of the system are rice.input_ratio, rice.productivity, rice.production,
rice.requirement, and rice.self_sufficiency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subsidy
|
float
|
The share of the recommended fertiliser that the subsidy pays for. |
0.67
|
bio_target
|
float
|
The target share of bio-fertiliser in the inputs. |
0.0
|
research
|
float
|
The funding of research for high-yielding varieties, relative to its normal level. |
0.0
|
training_target
|
float
|
The target coverage of the farmers by training and extension, from 0 to 1. |
0.0
|
intensity_target
|
float
|
The target cropping intensity, the crops per year on the rice area. |
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.economics.resources import FoodSecuritySystem
>>> FoodSecuritySystem(subsidy=0.0).prepare().system_.elements[0].subsidy
0.0
Source code in src/skcomplex/systems/economics/resources/_food.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
GrazingInteraction(label, *, requesters, providers, rule=RandomSearchSpec(), phase='grazing', herders, appetite=1.0, metabolism=0.5, milk=1.0)
Bases: MatchingInteraction[SystemView]
Grazing of the meadow, a matching of the cows with the pastures.
After the matching every cow eats and burns energy. The rule of the matching pairs the cows with the pastures, such
as PartnerMatchingSpec('local', 'score', score=GrazingInteraction.score, value='provider'), which pairs every cow,
in random order, with the free pasture of most grass in its cell or the cells around it, ties broken at random. A
pasture takes one cow, its default quantity of one unit. Every matched cow moves to its pasture and eats up to its
appetite as a transfer of grass to its energy, and its herder earns milk for what it ate. Then every cow burns its
metabolism and counts in the herd of its herder, and a cow whose energy runs out dies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the grazing. |
required |
requesters
|
Role
|
The path of the group of cows. |
required |
providers
|
Role
|
The path of the group of pastures. |
required |
rule
|
MatchingRule
|
The spec of the algorithm that pairs the cows with the pastures. |
RandomSearchSpec()
|
phase
|
str | None
|
The phase the grazing runs in. |
'grazing'
|
herders
|
Role
|
The path of the group of herders. |
required |
appetite
|
Annotated[float, closed_open(0, oo)]
|
The most grass a cow eats in a step. |
1.0
|
metabolism
|
Annotated[float, closed_open(0, oo)]
|
The energy a cow burns in a step. |
0.5
|
milk
|
Annotated[float, closed_open(0, oo)]
|
The income of a herder per unit of grass its cows eat. |
1.0
|
Examples:
>>> from skcomplex.systems.economics.resources import GrazingInteraction
>>> GrazingInteraction('grazing', requesters='cows', providers='meadow', herders='herders').appetite
1.0
Source code in src/skcomplex/systems/economics/resources/_commons.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 | |
match(system)
Pair and feed the cows, then let every cow burn its metabolism.
Every cow is counted in its herd, and it starves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system view of the grazing. |
required |
Source code in src/skcomplex/systems/economics/resources/_commons.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
score(cow, pasture)
staticmethod
Return the score of a pasture for a cow, the grass on the pasture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cow
|
object
|
The agent view of the cow. |
required |
pasture
|
object
|
The agent view of the pasture. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
score |
float
|
The grass on the pasture, or minus infinity for an agent that is not a pasture. |
Source code in src/skcomplex/systems/economics/resources/_commons.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
HarvestInteraction(label, *, target, harvesters, effort=0.05, state='n')
Bases: Interaction
Harvest of a stock proportional to the stock and to the number of harvesters.
The rate is -effort * N * n, a rate on the state n of the target whose coefficient counts the members of the
group of harvesters, which may live in another subsystem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the harvested stock. |
required |
harvesters
|
Role
|
The path of the group of harvesters, which the harvest counts. |
required |
effort
|
Annotated[float, closed_open(0, oo)]
|
The harvest rate per harvester and unit of stock. |
0.05
|
state
|
str
|
The name of the state of the target that holds the stock. |
'n'
|
Examples:
>>> from skcomplex.systems.economics.resources import HarvestInteraction
>>> HarvestInteraction('harvest', target='land/stock', harvesters='village/farmers', effort=0.05).effort
0.05
Source code in src/skcomplex/systems/economics/resources/_harvesting.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
HarvestingSystem(farmers=10, *, effort=0.05, r=1.0, K=1000.0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A socio-ecological system of farmer agents harvesting a resource.
The resource regrows logistically. The resource settles at K * (1 - effort * farmers / r) when
effort * farmers < r, and collapses otherwise. The system has the ODE subsystem land and the agent subsystem
village.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
farmers
|
int
|
The number of farmers. |
10
|
effort
|
float
|
The harvest rate per farmer and unit of stock. |
0.05
|
r
|
float
|
The growth rate of the resource. |
1.0
|
K
|
float
|
The carrying capacity of the resource. |
1000.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.economics.resources import HarvestingSystem
>>> [subsystem.label for subsystem in HarvestingSystem().prepare().system_.systems]
['land', 'village']
Source code in src/skcomplex/systems/economics/resources/_harvesting.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
HerderElement(label, *, income=0.0, herd=0.0, upkeep=0.3, newborn=4.0, quota=UNLIMITED, values=None, size=None, space=None)
Bases: Element
Herder who adds a cow whenever a cow earned more than its upkeep.
It sells one when the herd exceeds its quota. The life cycle investment of the system buys a cow, at a random
cell, or sells the first cow the herder owns, and two maps clear the income and the herd the grazing tallies, all
member interactions in the phase of herding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
income
|
Annotated[object, closed_open(0, oo)]
|
The milk income of the herder in the last step. |
0.0
|
herd
|
Annotated[object, closed_open(0, oo)]
|
The number of cows of the herder in the last step. |
0.0
|
upkeep
|
Annotated[object, closed_open(0, oo)]
|
The cost of keeping a cow for a step. |
0.3
|
newborn
|
Annotated[object, open(0, oo)]
|
The energy of a new cow. |
4.0
|
quota
|
Annotated[object, open(0, oo)]
|
The largest herd of a herder, which a regulator may change. |
UNLIMITED
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the cells |
None
|
size
|
int | None
|
The number of herders, or |
None
|
space
|
BaseSpace | None
|
The meadow the herders live on, whose axes |
None
|
Examples:
>>> from skcomplex.systems.economics.resources import HerderElement
>>> HerderElement('herders', size=5).size
5
Source code in src/skcomplex/systems/economics/resources/_commons.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
HilsaElement(label, *, eggs=0.0, larvae=0.0, juveniles=0.0, yearlings=0.0, adults=0.0, migrants=0.0, spawners=375.0, female_fraction=FEMALE_FRACTION, eggs_per_nest=200000.0, max_nests=MAX_NESTS, spawning_time=SPAWNING_TIME, hatching_time=1.0, larval_time=2.0, river_time=8.0, ocean_time=12.0, adult_ocean_time=12.0, migration_time=2.0, egg_loss=0.99, larval_loss=0.8, juvenile_loss=0.4, first_year_loss=0.3, second_year_loss=0.5, migration_loss=0.25, juvenile_harvest=0.48, adult_harvest=0.8, weight_per_adult=0.82, weight_per_juvenile=0.09)
Bases: Element
Life cycle of the hilsa, with one stock of fish per stage.
It holds the parameters of the stages and the catch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the element. |
required |
eggs
|
Annotated[float, closed_open(0, oo), Quantity(fish)]
|
The eggs in the nests, in millions of fish. |
0.0
|
larvae
|
Annotated[float, closed_open(0, oo), Quantity(fish)]
|
The larvae in the rivers, in millions of fish. |
0.0
|
juveniles
|
Annotated[float, closed_open(0, oo), Quantity(fish)]
|
The juveniles in the rivers, in millions of fish. |
0.0
|
yearlings
|
Annotated[float, closed_open(0, oo), Quantity(fish)]
|
The fish in their first year in the ocean, in millions of fish. |
0.0
|
adults
|
Annotated[float, closed_open(0, oo), Quantity(fish)]
|
The fish in their second year in the ocean, in millions of fish. |
0.0
|
migrants
|
Annotated[float, closed_open(0, oo), Quantity(fish)]
|
The adults migrating back to the rivers, in millions of fish. |
0.0
|
spawners
|
Annotated[float, closed_open(0, oo), Quantity(fish)]
|
The adults about to spawn, in millions of fish. |
375.0
|
female_fraction
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the spawners that are female and build a nest. |
FEMALE_FRACTION
|
eggs_per_nest
|
Annotated[float, closed_open(0, oo)]
|
The number of eggs per nest. |
200000.0
|
max_nests
|
Annotated[float, closed_open(0, oo)]
|
The most nests the spawning grounds hold. |
MAX_NESTS
|
spawning_time
|
Annotated[float, open(0, oo)]
|
The duration of the spawning, in months. |
SPAWNING_TIME
|
hatching_time
|
Annotated[float, open(0, oo)]
|
The time the eggs take to hatch, in months. |
1.0
|
larval_time
|
Annotated[float, open(0, oo)]
|
The time the larvae take to become juveniles, in months. |
2.0
|
river_time
|
Annotated[float, open(0, oo)]
|
The time the juveniles stay in the rivers, in months. |
8.0
|
ocean_time
|
Annotated[float, open(0, oo)]
|
The time the fish spend in their first year in the ocean, in months. |
12.0
|
adult_ocean_time
|
Annotated[float, open(0, oo)]
|
The time the fish spend in their second year in the ocean, in months. |
12.0
|
migration_time
|
Annotated[float, open(0, oo)]
|
The time the migration back to the rivers takes, in months. |
2.0
|
egg_loss
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the eggs lost to natural mortality. |
0.99
|
larval_loss
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the larvae lost to natural mortality. |
0.8
|
juvenile_loss
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the juveniles lost to natural mortality. |
0.4
|
first_year_loss
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the fish lost to natural mortality in their first year in the ocean. |
0.3
|
second_year_loss
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the fish lost to natural mortality in their second year in the ocean. |
0.5
|
migration_loss
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the adults lost during their migration to the rivers. |
0.25
|
juvenile_harvest
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the juveniles leaving the rivers that the fishery catches. |
0.48
|
adult_harvest
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the adults about to spawn that the fishery catches. |
0.8
|
weight_per_adult
|
Annotated[float, closed_open(0, oo)]
|
The weight of an adult, in kilograms. |
0.82
|
weight_per_juvenile
|
Annotated[float, closed_open(0, oo)]
|
The weight of a juvenile, in kilograms. |
0.09
|
Source code in src/skcomplex/systems/economics/resources/_fisheries.py
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 | |
HilsaFisherySystem(spawners=375.0, *, eggs_per_nest=200000.0, juvenile_harvest=0.48, adult_harvest=0.8, migration_loss=0.25, label='system', solver='auto', backend='auto')
Bases: BaseSystem
A hilsa fishery, the life cycle of a migratory fish.
The catch of juveniles and spawners depletes it. Spawning adults lay eggs in nests in the rivers, and the number of nests is limited by the spawning grounds. The eggs hatch into larvae within a month, the larvae become juveniles within two months, and the juveniles stay in the rivers for eight months before they enter the ocean. The fish mature in the ocean over two years, migrate back to the rivers, and spawn. Every stage drains over its duration, and a fixed fraction of its outflow is lost to natural mortality, to the catch of juveniles, or to the catch of spawning adults, while the rest enters the next stage. Fish are conserved, every change of a stage is a flow, and the population settles where the spawning grounds fill, unless the catch keeps the reproduction below replacement. The stages, the durations, and the loss fractions follow the hilsa system of Bala, Arshad and Noh (2017, Chapter 9), with the stocks in millions of fish and time in months.
The system has the stages hilsa.eggs, hilsa.larvae, hilsa.juveniles, hilsa.yearlings, hilsa.adults,
hilsa.migrants, and hilsa.spawners, and the flows between the stages, among them hilsa.egg_deposition,
hilsa.young_entering_ocean_catch, and hilsa.adult_catch, per month, over months. The observables of the system
are the nests hilsa.nests, and the weights hilsa.adult_weight and hilsa.juvenile_weight in tonnes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spawners
|
float
|
The initial number of adults about to spawn. |
375.0
|
eggs_per_nest
|
float
|
The number of eggs per nest. |
200000.0
|
juvenile_harvest
|
float
|
The fraction of the juveniles leaving the rivers that the fishery catches. |
0.48
|
adult_harvest
|
float
|
The fraction of the adults about to spawn that the fishery catches. |
0.8
|
migration_loss
|
float
|
The fraction of the adults lost during their migration to the rivers. |
0.25
|
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.economics.resources import HilsaFisherySystem
>>> HilsaFisherySystem(adult_harvest=0.5).prepare().system_.elements[0].adult_harvest
0.5
Source code in src/skcomplex/systems/economics/resources/_fisheries.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
LandCellElement(label, *, crop=0.0, distance=0.0, values=None, size=None, space=None)
Bases: Element
Cell of a plain that grows one crop, numbered from 1, or lies idle as crop 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the cell or the field. |
required |
crop
|
object
|
The initial guess of the crop, which the equation replaces. |
0.0
|
distance
|
object
|
The distance from the market. |
0.0
|
values
|
Mapping[str, object] | None
|
Further values by name, or |
None
|
size
|
int | None
|
The number of cells, or |
None
|
space
|
BaseSpace | None
|
The plain with one cell per site, or |
None
|
Examples:
>>> from skcomplex.systems.economics.resources import LandCellElement
>>> LandCellElement('cell', distance=3.0).distance
3.0
Source code in src/skcomplex/systems/economics/resources/_land_use.py
53 54 55 56 57 58 59 60 61 62 63 64 65 | |
MeasuredFisheryElement(label, *, x=0.5, catch=0.0, r0=1.0, sigma_r=1.0, K=1.0, error=0.0, step=0.01, restocking=0.0, size=None)
Bases: Element
Logistic fish stock with a noisy growth rate, harvested by a quota by QuotaHarvestInteraction.
The quota is set from a measurement with an error. Every step of length step is an Euler-Maruyama step of
dx = (R0 + sigma_R W) x (1 - x / K) dt - gamma dt, where W is white noise. The fishermen measure x~ = x + e,
with a Gaussian error e of standard deviation error, and set the quota gamma = x~ - K / 2, which is never
negative unless restocking lets a negative quota release fish. A stock that reaches zero is extinct and stays at
zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the fishery. |
required |
x
|
Annotated[object, closed_open(0, oo)]
|
The fish stock. |
0.5
|
catch
|
object
|
The quota of the last step, per unit of time. |
0.0
|
r0
|
Annotated[object, open(0, oo)]
|
The mean growth rate |
1.0
|
sigma_r
|
Annotated[object, closed_open(0, oo)]
|
The standard deviation |
1.0
|
K
|
Annotated[object, open(0, oo)]
|
The carrying capacity. |
1.0
|
error
|
Annotated[object, closed_open(0, oo)]
|
The standard deviation of the measurement error. |
0.0
|
step
|
Annotated[object, open(0, oo)]
|
The length of a step in units of time. |
0.01
|
restocking
|
Annotated[object, closed(0, 1)]
|
1 to let a negative quota release fish into the stock, 0 to floor the quota at zero. |
0.0
|
size
|
int | None
|
The number of fisheries, or |
None
|
Examples:
>>> from skcomplex.systems.economics.resources import MeasuredFisheryElement
>>> MeasuredFisheryElement('fishery', error=0.1).error
0.1
Source code in src/skcomplex/systems/economics/resources/_measurement_errors.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
OilEconomySystem(resource=1000.0, capital=5.0, *, price=3.0, cost=0.1, growth_goal=0.1, lifetime=20.0, price_table=None, label='system', solver='auto', backend='auto')
Bases: StockFlowSystem
Meadows' oil economy, capital that grows on a nonrenewable resource.
The capital collapses as the resource runs out. The capital grows exponentially while extraction is cheap, peaks as
falling yields cut the profit, and declines with depreciation, leaving part of the resource in the ground. The
system has the resource oil.resource and the capital oil.capital.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resource
|
float
|
The initial resource stock. |
1000.0
|
capital
|
float
|
The initial capital. |
5.0
|
price
|
float
|
The price of the resource, used without a price table. |
3.0
|
cost
|
float
|
The operating cost per unit of capital. |
0.1
|
growth_goal
|
float
|
The largest investment per unit of capital. |
0.1
|
lifetime
|
float
|
The average lifetime of the capital. |
20.0
|
price_table
|
Sequence[float] | None
|
The price at the yields 0, 0.1, 0.2, 0.4, 0.6, 0.8, and 1, or |
None
|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
solver
|
BaseSolver | str
|
The solver of the problem, or |
'auto'
|
backend
|
BaseBackend | str
|
The backend that evaluates the compiled functions, or |
'auto'
|
Examples:
>>> from skcomplex.systems.economics.resources import OilEconomySystem
>>> OilEconomySystem(resource=2000.0).prepare().system_.elements[0].values['resource']
2000.0
Source code in src/skcomplex/systems/economics/resources/_extraction.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | |
OptimalHarvestingSystem(x=1.0, *, r=1.0, K=1.0, q=1.0, p=1.0, c=0.2, delta=0.1, label='system', solver='auto', backend='auto')
Bases: DynamicalSystem
A logistic resource harvested with the effort that maximises its profit.
The profit is discounted, and the objective law ObjectiveLaw(-profit, controls=[s.target.effort]) maximises it
over the effort, which lies between 0 and 1. Run with an optimal control solver, the effort starts at a bound,
drives the stock to the level x* where r (1 - 2 x* / K) + c r (1 - x* / K) / (p q x* - c) = delta, holds it
there with the effort r (1 - x* / K) / q, and rises to its largest value at the end of the horizon, when the stock
left has no value. The system has the stock resource.x, the effort resource.effort, and the observable catch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
The initial stock. |
1.0
|
r
|
float
|
The intrinsic growth rate. |
1.0
|
K
|
float
|
The carrying capacity. |
1.0
|
q
|
float
|
The catchability. |
1.0
|
p
|
float
|
The price per unit of catch. |
1.0
|
c
|
float
|
The cost per unit of effort. |
0.2
|
delta
|
float
|
The discount rate. |
0.1
|
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.economics.resources import OptimalHarvestingSystem
>>> OptimalHarvestingSystem(delta=0.05).prepare().system_.elements[0].get_params()['delta']
0.05
Source code in src/skcomplex/systems/economics/resources/_optimal_harvesting.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
PartialAdjustmentInteraction(label, *, target, state='x', goal=0.0, time=1.0, noise=None)
Bases: Interaction
Partial adjustment of a quantity towards a target over an adjustment time.
Economics names it partial adjustment, as of a policy or an investment that closes a gap to its target at a rate.
The rate is (goal(ns) - x) / time(ns) of a state x of a target, with optional noise. With a constant goal and
time and an additive noise of amplitude sigma, the state follows the Ornstein-Uhlenbeck process dx = (goal - x) /
time dt + sigma dW, whose stationary variance is sigma**2 time / 2. A goal, a time, or a noise function takes the
namespace of the interaction, whose target holds the values of the target, and a number stands for a constant. A
goal that is a number applies to every component of a vector state.
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 element or group whose state relaxes. |
required |
state
|
str
|
The name of the state of the target that relaxes. |
'x'
|
goal
|
Callable[[SimpleNamespace], object] | float
|
A function of the namespace that returns the goal, or a number. |
0.0
|
time
|
Callable[[SimpleNamespace], object] | float
|
A function of the namespace that returns the relaxation time, or a positive number. |
1.0
|
noise
|
Callable[[SimpleNamespace], object] | float | None
|
A function of the namespace that returns the amplitude of the noise, a number, or |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
The state is not a name, or a function is neither callable nor a number. |
Examples:
>>> from skcomplex.systems.general.elements import NonnegativeElement
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.economics.resources import PartialAdjustmentInteraction
>>> relaxation = PartialAdjustmentInteraction('relaxation', target='stock', goal=10.0, time=0.5)
>>> system = System(elements=[NonnegativeElement('stock')], interactions=[relaxation])
>>> trajectory = system.prepare().simulate(until=5.0, dt=0.01)
>>> round(float(trajectory.get_values('stock.x')[-1]), 3)
10.0
Source code in src/skcomplex/systems/economics/resources/_food.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
PastureElement(label, *, grass=2.0, capacity=2.0, regrowth=0.2, seed=0.05, values=None, size=None, space=None)
Bases: Element
Cell of the meadow whose grass grows back logistically by RegrassingInteraction.
When it is grazed bare, the grass grows from a seed bank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the agent or group. |
required |
grass
|
Annotated[object, closed_open(0, oo)]
|
The grass on the cell. |
2.0
|
capacity
|
Annotated[object, open(0, oo)]
|
The most grass the cell holds. |
2.0
|
regrowth
|
Annotated[object, closed_open(0, oo)]
|
The logistic growth rate of the grass. |
0.2
|
seed
|
Annotated[object, closed_open(0, oo)]
|
The share of the capacity that grows back as if it stood on a bare cell. |
0.05
|
values
|
Mapping[str, object] | None
|
Further values by name, such as the cells |
None
|
size
|
int | None
|
The number of pastures, or |
None
|
space
|
BaseSpace | None
|
The meadow the pastures live on, whose axes |
None
|
Examples:
>>> from skcomplex.systems.economics.resources import PastureElement
>>> PastureElement('meadow', capacity=2.0, size=4).size
4
Source code in src/skcomplex/systems/economics/resources/_commons.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | |
PlantationElement(label, *, forest=490.0, area=10.0, abandoned=0.0, shade_removal=5.0, insects=1.0, yield_normal=5.0, price=40.0, cost=100.0, thinning_cost=20.0, adjustment_time=3.0, abandon_time=4.0, conversion_time=3.0, palm_margin=0.4, thinning_time=8.0, insect_growth=0.6, insect_control=0.3, subsidy=0.0)
Bases: Element
Cocoa land in forest, planted, and abandoned stocks.
The shade is thinned and lets the insects in. Farmers plant forest towards a desired area that grows with the profitability of cocoa, abandon plantations whose yield and profit fall, and leave abandoned land to the forest or convert it to oil palm when cocoa pays less than palm. Removing shade raises the yield and lets the insects grow logistically, and the subsidy keeps the shade and controls the insects. The land flows are transfers within the plantation of the system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the plantation. |
required |
forest
|
Annotated[object, closed_open(0, oo), Quantity(land)]
|
The initial forest land. |
490.0
|
area
|
Annotated[object, closed_open(0, oo), Quantity(land)]
|
The initial cocoa area. |
10.0
|
abandoned
|
Annotated[object, closed_open(0, oo), Quantity(land)]
|
The initial abandoned land. |
0.0
|
shade_removal
|
Annotated[object, closed_open(0, oo)]
|
The initial index of shade removal, from 0 to 100. |
5.0
|
insects
|
Annotated[object, closed_open(0, oo)]
|
The initial index of insect attack, from 0 to 100. |
1.0
|
yield_normal
|
Annotated[object, closed_open(0, oo)]
|
The yield per area without insects or thinning. |
5.0
|
price
|
Annotated[object, closed_open(0, oo)]
|
The farm price of cocoa. |
40.0
|
cost
|
Annotated[object, closed_open(0, oo)]
|
The operating cost per area. |
100.0
|
thinning_cost
|
Annotated[object, closed_open(0, oo)]
|
The cost per area of removing all shade. |
20.0
|
adjustment_time
|
Annotated[object, open(0, oo)]
|
The time to plant towards the desired area. |
3.0
|
abandon_time
|
Annotated[object, open(0, oo)]
|
The average time before a plantation is abandoned. |
4.0
|
conversion_time
|
Annotated[object, open(0, oo)]
|
The time abandoned land stays before it returns to forest or turns to oil palm. |
3.0
|
palm_margin
|
Annotated[object, open(0, oo)]
|
The profitability of oil palm, against which abandoned land converts. |
0.4
|
thinning_time
|
Annotated[object, open(0, oo)]
|
The time to remove the shade. |
8.0
|
insect_growth
|
Annotated[object, closed_open(0, oo)]
|
The largest relative growth rate of the insects, reached with all shade removed. |
0.6
|
insect_control
|
Annotated[object, closed_open(0, oo)]
|
The rate at which the subsidy controls the insects. |
0.3
|
subsidy
|
Annotated[object, closed_open(0, oo)]
|
The coverage of the subsidy and extension programme, from 0 to 1. |
0.0
|
Examples:
>>> from skcomplex.systems.economics.resources import PlantationElement
>>> PlantationElement('cocoa', subsidy=0.5).subsidy
0.5
Source code in src/skcomplex/systems/economics/resources/_plantations.py
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 | |
QuotaHarvestInteraction(label, *, target)
Bases: Interaction
Noisy logistic growth of a fish stock harvested by a quota set from a noisy measurement.
Every step of length step is an Euler-Maruyama step of dx = (R0 + sigma_R W) x (1 - x / K) dt - gamma dt, with
the quota gamma = x~ - K / 2 of the measured stock x~ = x + e. All the values are those of the fishery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the fishery or of the group of fisheries. |
required |
Examples:
>>> from skcomplex.systems.economics.resources import QuotaHarvestInteraction
>>> QuotaHarvestInteraction('harvest', target='fisheries').target
'fisheries'
Source code in src/skcomplex/systems/economics/resources/_measurement_errors.py
122 123 124 | |
QuotaRegulatorInteraction(label, *, rule=None, phase=None, regulated=0.0, low=0.5, high=0.8)
Bases: PolicyRuleInteraction[SystemView]
Regulator of the quota of cows per herder.
It halves the quota when the grass runs short and raises it when it recovers. The quota is the value quota of
every herder. It halves, down to one cow, when the grass falls below the share low of the capacity of
the meadow, and grows by one cow when the grass is above the share high. Without regulation it stays as it is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the regulator. |
required |
rule
|
Callable[[SystemView], None] | None
|
Unused, since the regulator overrides |
None
|
phase
|
str | None
|
The phase the regulator acts in. |
None
|
regulated
|
Annotated[float, closed_open(0, oo)]
|
One when the regulator changes the quota, zero otherwise. |
0.0
|
low
|
Annotated[float, closed_open(0, oo)]
|
The share of the capacity of the meadow below which the quota halves. |
0.5
|
high
|
Annotated[float, closed_open(0, oo)]
|
The share of the capacity of the meadow above which the quota rises by one cow. |
0.8
|
Examples:
>>> from skcomplex.systems.economics.resources import QuotaRegulatorInteraction
>>> QuotaRegulatorInteraction('regulator', regulated=1.0).regulated
1.0
Source code in src/skcomplex/systems/economics/resources/_commons.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
act(system)
Change the quota with the share of grass left on the meadow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
SystemView
|
The system view of the regulator. |
required |
Source code in src/skcomplex/systems/economics/resources/_commons.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
RegrassingInteraction(label, *, target='meadow', phase=None)
Bases: Interaction
Logistic regrowth of the grass of every pasture, from a seed bank when it is bare.
The grass G of a pasture of capacity K grows by r S (1 - S / K) up to K, with the stand S the larger of
G and the seed share of the capacity, so a bare cell grows back. The rates r and the seed share are the values
regrowth and seed of each pasture.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The pastures whose grass grows. |
'meadow'
|
phase
|
str | None
|
The phase the grass grows in, or |
None
|
Examples:
>>> from skcomplex.systems.economics.resources import RegrassingInteraction
>>> RegrassingInteraction('regrowth', phase='growth').phase
'growth'
Source code in src/skcomplex/systems/economics/resources/_commons.py
264 265 266 267 | |
grow(agent, system)
Grow the grass logistically up to the capacity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
PastureView
|
The pasture. |
required |
system
|
SystemView
|
The system. |
required |
Source code in src/skcomplex/systems/economics/resources/_commons.py
279 280 281 282 283 284 285 286 287 288 289 290 291 | |
RiceBalanceElement(label, *, area_cultivated=68000.0, population=2800000.0, total_land_available=120000.0, planning_time=15.0, land_fraction_lost=0.00085, crop_yield=3.2, birth_fraction=0.025, life_expectancy=65.0, food_per_capita=0.18)
Bases: Element
Rice land and population of a region.
It holds the land available for rice and the rice each person needs. The area cultivated grows towards the land available over a planning time and loses a fraction to housing, roads, and industry, and the population grows by births and falls by deaths, through labelled flows of the system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the region. |
required |
area_cultivated
|
Annotated[float, closed_open(0, oo), Quantity(land)]
|
The area under rice, in hectares. |
68000.0
|
population
|
Annotated[float, closed_open(0, oo), Quantity(people)]
|
The population. |
2800000.0
|
total_land_available
|
Annotated[float, open(0, oo)]
|
The land suitable for rice, in hectares. |
120000.0
|
planning_time
|
Annotated[float, open(0, oo)]
|
The years over which the land suitable for rice is to be covered. |
15.0
|
land_fraction_lost
|
Annotated[float, closed_open(0, oo)]
|
The fraction of the area cultivated lost every year. |
0.00085
|
crop_yield
|
Annotated[float, closed_open(0, oo)]
|
The yield of rice, in tonnes per hectare. |
3.2
|
birth_fraction
|
Annotated[float, closed_open(0, oo)]
|
The births per person and year. |
0.025
|
life_expectancy
|
Annotated[float, open(0, oo)]
|
The life expectancy, in years. |
65.0
|
food_per_capita
|
Annotated[float, open(0, oo)]
|
The rice each person needs, in tonnes per year. |
0.18
|
Examples:
>>> from skcomplex.systems.economics.resources import RiceBalanceElement
>>> RiceBalanceElement('region', crop_yield=4.0).crop_yield
4.0
Source code in src/skcomplex/systems/economics/resources/_food_balance.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
RiceFoodBalanceSystem(area_cultivated=68000.0, population=2800000.0, *, total_land_available=120000.0, planning_time=15.0, land_fraction_lost=0.00085, crop_yield=3.2, birth_fraction=0.025, life_expectancy=65.0, food_per_capita=0.18, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Bala's food security model.
Rice land grows towards the land available against a growing population. The area cultivated grows at
MAX((total_land_available - area_cultivated) / planning_time, 0) and loses land_fraction_lost of itself every
year to housing, roads, and industry. The population grows by birth_fraction per person and falls by one over the
life expectancy. The food security level is the rice available, the area times the yield, over the rice required,
the population times the rice per capita, and below 1 the region is short of rice. The structure, the equations, and
the defaults are those of the STELLA model of Bala et al. (2017, Section 4.11.3), in hectares, people, tonnes, and
years. The area rises for about fifty years towards the land available, and the food security rises for about
twenty-five years and then falls as the population grows.
The system has the stocks region.area_cultivated and region.population, and the flows
region.area_increase_rate, region.land_lost, region.birth_rate, and region.death_rate per year. The
observables of the system are region.food_available, region.food_required, and region.food_security.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
area_cultivated
|
float
|
The initial area under rice, in hectares. |
68000.0
|
population
|
float
|
The initial population. |
2800000.0
|
total_land_available
|
float
|
The land suitable for rice, in hectares. |
120000.0
|
planning_time
|
float
|
The years over which the land suitable for rice is to be covered. |
15.0
|
land_fraction_lost
|
float
|
The fraction of the area cultivated lost every year. |
0.00085
|
crop_yield
|
float
|
The yield of rice, in tonnes per hectare. |
3.2
|
birth_fraction
|
float
|
The births per person and year. |
0.025
|
life_expectancy
|
float
|
The life expectancy, in years. |
65.0
|
food_per_capita
|
float
|
The rice each person needs, in tonnes per year. |
0.18
|
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.economics.resources import RiceFoodBalanceSystem
>>> RiceFoodBalanceSystem(planning_time=10.0).prepare().system_.elements[0].planning_time
10.0
Source code in src/skcomplex/systems/economics/resources/_food_balance.py
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 | |
RiceSectorElement(label, *, available_land=0.088, rice_area=0.680647, population=18.1024, potential=6.0, soil_quality=0.99, practice=0.61, training=0.0, bio_fraction=0.0, cropping_intensity=1.0, conversion_time=8.0, discard_rate=0.0085, growth_rate=0.021, consumption=80.0, milling_rate=0.65, subsidy=0.67, farmer_inputs=0.3, research=0.0, potential_limit=10.0, research_time=20.0, regeneration_time=10.0, degradation=0.002, learning_time=5.0, training_target=0.0, extension_time=5.0, bio_target=0.0, transition_time=10.0, intensity_target=1.0, implementation_time=10.0)
Bases: Element
Rice sector of a country.
It holds its land, population, and the factors of the productivity of its rice land. The suitable land is developed into rice area and the rice area is discarded, and the population grows exponentially, through transfers within the sector of the system. Research raises the potential yield towards a limit, chemical fertiliser degrades the soil and fallow regenerates it, and training improves the farming practice through a learning table. The training, the share of bio-fertiliser, and the cropping intensity relax towards their targets through relaxation interactions of the system, which read the targets and times of the sector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the sector. |
required |
available_land
|
Annotated[object, closed_open(0, oo), Quantity(land)]
|
The initial land suitable for rice and not yet developed. |
0.088
|
rice_area
|
Annotated[object, closed_open(0, oo), Quantity(land)]
|
The initial rice area. |
0.680647
|
population
|
Annotated[object, closed_open(0, oo), Quantity(people)]
|
The initial population. |
18.1024
|
potential
|
Annotated[object, closed_open(0, oo)]
|
The initial potential yield. |
6.0
|
soil_quality
|
Annotated[object, closed_open(0, oo)]
|
The initial soil quality, from 0 to 1. |
0.99
|
practice
|
Annotated[object, closed_open(0, oo)]
|
The initial quality of the farming practice, from 0 to 1. |
0.61
|
training
|
Annotated[object, closed_open(0, oo)]
|
The initial coverage of the farmers by training and extension, from 0 to 1. |
0.0
|
bio_fraction
|
Annotated[object, closed_open(0, oo)]
|
The initial share of bio-fertiliser in the inputs. |
0.0
|
cropping_intensity
|
Annotated[object, closed_open(0, oo)]
|
The initial number of crops per year on the rice area. |
1.0
|
conversion_time
|
Annotated[object, open(0, oo)]
|
The time to develop the suitable land. |
8.0
|
discard_rate
|
Annotated[object, closed_open(0, oo)]
|
The fraction of the rice area discarded per year. |
0.0085
|
growth_rate
|
object
|
The growth rate of the population. |
0.021
|
consumption
|
Annotated[object, closed_open(0, oo)]
|
The rice consumption per capita, in kilograms per year. |
80.0
|
milling_rate
|
Annotated[object, closed_open(0, oo)]
|
The share of paddy that milling turns into rice. |
0.65
|
subsidy
|
Annotated[object, closed_open(0, oo)]
|
The share of the recommended fertiliser that the subsidy pays for. |
0.67
|
farmer_inputs
|
Annotated[object, closed_open(0, oo)]
|
The share of the unsubsidised fertiliser that the farmers buy. |
0.3
|
research
|
Annotated[object, closed_open(0, oo)]
|
The funding of research for high-yielding varieties, relative to its normal level. |
0.0
|
potential_limit
|
Annotated[object, open(0, oo)]
|
The potential yield that research approaches. |
10.0
|
research_time
|
Annotated[object, open(0, oo)]
|
The time research takes to reach the limit at its normal funding. |
20.0
|
regeneration_time
|
Annotated[object, open(0, oo)]
|
The time fallow takes to regenerate the soil. |
10.0
|
degradation
|
Annotated[object, closed_open(0, oo)]
|
The rate at which chemical fertiliser degrades the soil. |
0.002
|
learning_time
|
Annotated[object, open(0, oo)]
|
The time training takes to improve the practice. |
5.0
|
training_target
|
Annotated[object, closed_open(0, oo)]
|
The target coverage of training and extension. |
0.0
|
extension_time
|
Annotated[object, open(0, oo)]
|
The time the training takes to reach its target. |
5.0
|
bio_target
|
Annotated[object, closed_open(0, oo)]
|
The target share of bio-fertiliser. |
0.0
|
transition_time
|
Annotated[object, open(0, oo)]
|
The time the share of bio-fertiliser takes to reach its target. |
10.0
|
intensity_target
|
Annotated[object, open(0, oo)]
|
The target cropping intensity. |
1.0
|
implementation_time
|
Annotated[object, open(0, oo)]
|
The time the cropping intensity takes to reach its target. |
10.0
|
Examples:
>>> from skcomplex.systems.economics.resources import RiceSectorElement
>>> RiceSectorElement('rice', subsidy=0.5).subsidy
0.5
Source code in src/skcomplex/systems/economics/resources/_food.py
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 | |
StockElement(label, *, n=1000.0, r=1.0, K=1000.0)
Bases: Element
Renewable stock n with the growth rate r and the carrying capacity K.
StockGrowthInteraction grows it logistically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the stock. |
required |
n
|
Annotated[object, closed_open(0, oo)]
|
The initial stock. |
1000.0
|
r
|
Annotated[object, closed_open(0, oo)]
|
The intrinsic growth rate. |
1.0
|
K
|
Annotated[object, open(0, oo)]
|
The carrying capacity. |
1000.0
|
Examples:
>>> from skcomplex.systems.economics.resources import StockElement
>>> StockElement('stock', n=500.0).n
500.0
Source code in src/skcomplex/systems/economics/resources/_harvesting.py
52 53 54 55 56 57 58 59 60 61 62 63 | |
StockGrowthInteraction(label, *, target)
Bases: Interaction
Logistic growth of a renewable stock, n' = r n (1 - n / K).
The rate r and the capacity K are the values of the stock.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the interaction. |
required |
target
|
Role
|
The path of the stock. |
required |
Examples:
>>> from skcomplex.systems.economics.resources import StockGrowthInteraction
>>> StockGrowthInteraction('growth', target='stock').target
'stock'
Source code in src/skcomplex/systems/economics/resources/_harvesting.py
86 87 88 | |
TragedyOfTheCommonsSystem(n_herders=20, *, width=20, height=20, cows=1, quota=None, regrowth=0.2, capacity=2.0, upkeep=0.3, random_state=0, label='system', solver='auto', backend='auto')
Bases: BaseSystem
Herders whose cows graze a shared meadow, until the grass collapses.
Each herder adds cows while a cow pays. Every step every cow moves to the richest pasture it can reach, eats, and earns its herder milk, and the grass grows back logistically. Every herder adds a cow whenever a cow earned more than its upkeep, since the gain of a cow goes to its herder while the cost of the grass it eats falls on all. With more herders than the meadow carries, the herd grows past what the grass sustains, the grass collapses below a tenth of its capacity, and the cows starve, so the herd shrinks after it. A regulator with an adaptive quota of cows per herder, lowered when the grass runs short and raised when it recovers, keeps the meadow from collapse (Hamill and Gilbert 2016 sec. 10.2).
The system has the groups meadow, cows, and herders, whose adaptive parameter quota the regulator
regulator changes, and the grazing grazing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_herders
|
int
|
The number of herders. |
20
|
width
|
int
|
The number of columns of the meadow. |
20
|
height
|
int
|
The number of rows of the meadow. |
20
|
cows
|
int
|
The initial number of cows of every herder. |
1
|
quota
|
float | None
|
The initial quota of cows per herder of a regulator that adapts it, or |
None
|
regrowth
|
float
|
The logistic growth rate of the grass. |
0.2
|
capacity
|
float
|
The most grass a cell holds. |
2.0
|
upkeep
|
float
|
The cost of keeping a cow for a step. |
0.3
|
random_state
|
int | Generator | None
|
The seed or generator of the cells of the cows. |
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.economics.resources import TragedyOfTheCommonsSystem
>>> [group.size for group in TragedyOfTheCommonsSystem(4, width=5, height=5).prepare().system_.elements]
[25, 4, 4]
Source code in src/skcomplex/systems/economics/resources/_commons.py
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 | |
VonThunenSystem(size=41, *, yields=(4.0, 2.0, 1.0), prices=(3.0, 3.0, 3.5), costs=(1.0, 0.5, 0.5), rates=(0.2, 0.2, 0.2), label='system', solver='auto', backend='auto')
Bases: BaseSystem
A square plain around one market at its centre.
Every cell grows the crop of highest bid rent. A crop of a high yield per cell bids most near the market, and its
bid falls fastest with distance, so the land use forms concentric rings whose boundaries lie where the bids of
neighbouring crops are equal (Giordano 2024 §7). The system has the states plain.crop and plain.distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int
|
The side of the plain in cells, one unit of distance each. |
41
|
yields
|
Sequence[float]
|
The yield of every crop per cell. |
(4.0, 2.0, 1.0)
|
prices
|
Sequence[float]
|
The price of every crop at the market. |
(3.0, 3.0, 3.5)
|
costs
|
Sequence[float]
|
The cost of every crop per unit of yield. |
(1.0, 0.5, 0.5)
|
rates
|
Sequence[float]
|
The transport rate of every crop per unit of yield and of distance. |
(0.2, 0.2, 0.2)
|
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.economics.resources import VonThunenSystem
>>> trajectory = VonThunenSystem().prepare().simulate(until=1.0)
>>> sorted(set(trajectory.get_values('plain.crop')[0].ravel().tolist()))
[0.0, 1.0, 2.0, 3.0]
Source code in src/skcomplex/systems/economics/resources/_land_use.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |