Growth
dissmodel.models.ca.growth.Growth
Bases: CellularAutomaton
Stochastic cellular automaton simulating spatial growth from a seed.
A single live cell is placed at the center of the grid at initialization.
At each step, empty cells adjacent to at least one live cell become alive
with probability :attr:probability.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
GeoDataFrame
|
GeoDataFrame with geometries and a |
required |
**kwargs
|
Any
|
Extra keyword arguments forwarded to
:class: |
{}
|
Examples:
>>> from dissmodel.geo import regular_grid
>>> from dissmodel.core import Environment
>>> gdf = regular_grid(dimension=(20, 20), resolution=1, attrs={"state": 0})
>>> env = Environment(end_time=15)
>>> growth = Growth(gdf=gdf, dim=20)
>>> growth.initialize()
Source code in dissmodel/models/ca/growth.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
initialize()
Place a single live cell at the center of the grid.
All other cells start as empty.
Source code in dissmodel/models/ca/growth.py
71 72 73 74 75 76 77 78 79 80 81 | |
rule(idx)
Apply the stochastic growth rule to cell idx.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
any
|
Index of the cell being evaluated. |
required |
Returns:
| Type | Description |
|---|---|
int
|
New state for the cell:
|
Source code in dissmodel/models/ca/growth.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
setup(probability=0.15)
Configure the model and build the neighborhood.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probability
|
float
|
Probability of colonization per step for empty cells adjacent to at least one live cell, by default 0.15. |
0.15
|
Source code in dissmodel/models/ca/growth.py
58 59 60 61 62 63 64 65 66 67 68 69 | |
dissmodel.models.ca.growth.GrowthState
Bases: IntEnum
Possible states for a cell in :class:Growth.
Attributes:
| Name | Type | Description |
|---|---|---|
EMPTY |
int
|
Empty cell, not yet colonized. |
ALIVE |
int
|
Live cell, can spread to neighbors. |
Source code in dissmodel/models/ca/growth.py
12 13 14 15 16 17 18 19 20 21 22 23 24 | |