GridBasedModel
Indirect Subclass:
Constructor Summary
Public Constructor | ||
public |
constructor(extents: GridSize, conf: object, seed: number) |
Member Summary
Public Members | ||
public |
cellvolume: *[] This tracks the volumes of all non-background cells on the grid. |
|
public |
Input parameter settings; see the constructor of subclasses documentation. |
|
public |
Size of the grid. |
|
public |
Size of the grid in object format. |
|
public |
grid: * |
|
public |
Midpoint of the grid. |
|
public |
Attach a random number generation with a seed. |
|
public |
Dimensionality of the grid |
|
public |
The Grid2D#neighi or Grid3D#neighi iterator function of the underlying grid. |
|
public |
The Grid2D#pixels or Grid3D#pixels iterator function of the underlying grid. |
|
public |
The Grid#pixti iterator function of the underlying grid. |
|
public |
Cached values of these stats. |
|
public |
Objects of class Stat that have been computed on this model. |
|
public |
Tracks the elapsed time in MCS |
Method Summary
Public Methods | ||
public |
Iterator for all the CellIds that are currently on the grid. |
|
public | ||
public |
Compute a statistic on this model. |
|
public |
neigh(p: ArrayCoordinate, torus: boolean[]): * Get neighbourhood of position p, using neighborhood functions of the underlying grid class. |
|
public |
pixt(p: ArrayCoordinate): CellId Get CellId of the pixel at coordinates p. |
|
public |
Get a random integer number between incl_min and incl_max, uniformly sampled. |
|
public |
Get a random number from the seeded number generator. |
|
public |
setpix(p: ArrayCoordinate, t: CellId) Change the pixel at position p into CellId t. |
|
public |
setpixi(i: IndexCoordinate, t: CellId) Change the pixel at position i into CellId t. |
|
public abstract |
timeStep() Update the grid in one timestep. |
Public Constructors
public constructor(extents: GridSize, conf: object, seed: number) source
The constructor of a GridBasedModel automatically attaches a grid of class Grid2D or Grid3D, depending on the grid dimensions given in the 'extents' parameter. Configuration options for the model can be supplied in 'conf'.
Params:
Name | Type | Attribute | Description |
extents | GridSize | the size of the grid of the model. |
|
conf | object | configuration options. See below for its elements, but subclasses can have more. |
|
conf.torus | boolean[] |
|
should the grid have linked borders? |
conf.hexGrid | boolean |
|
should the grid be hexagonal? Grids are square by default. |
seed | number |
|
seed for the random number generator. If left unspecified, a random number from the Math.random() generator is used to make one. |
Public Members
public cellvolume: *[] source
This tracks the volumes of all non-background cells on the grid. cellvolumes will be added with key = CellId, value = volume. @type{number[]}
public conf: object source
Input parameter settings; see the constructor of subclasses documentation.
public grid: * source
public neighi: function source
The Grid2D#neighi or Grid3D#neighi iterator function of the underlying grid.
public pixels: function source
The Grid2D#pixels or Grid3D#pixels iterator function of the underlying grid.
Public Methods
public cellKind(t: CellId): CellKind source
Params:
Name | Type | Attribute | Description |
t | CellId | id of the cell to get kind of. |
public getStat(s: Stat): anything source
Compute a statistic on this model. If necessary, this produces an object of the right Stat subclass and runs the compute method. Stats are cached because many stats use each other; this prevents that 'expensive' stats are computed twice.
Params:
Name | Type | Attribute | Description |
s | Stat | the stat to compute. |
Example:
let CPM = require( "path/to/dir")
let C = new CPM.CPM( [200,200], {T:20, torus:[false,false]} )
let gm = new CPM.GridManipulator( C )
gm.seedCell( 1 )
gm.seedCell( 1 )
C.getStat( Centroids )
public neigh(p: ArrayCoordinate, torus: boolean[]): * source
Get neighbourhood of position p, using neighborhood functions of the underlying grid class.
Params:
Name | Type | Attribute | Description |
p | ArrayCoordinate | coordinate of a pixel to get the neighborhood of. |
|
torus | boolean[] |
|
Does the grid have linked borders? If left unspecified, this is determined by this.conf.torus. |
Return:
* |
public pixt(p: ArrayCoordinate): CellId source
Get CellId of the pixel at coordinates p.
Params:
Name | Type | Attribute | Description |
p | ArrayCoordinate | pixel to get cellid of. |
public ran(incl_min: number, incl_max: number): number source
Get a random integer number between incl_min and incl_max, uniformly sampled.
public setpix(p: ArrayCoordinate, t: CellId) source
Params:
Name | Type | Attribute | Description |
p | ArrayCoordinate | coordinate of pixel to change. |
|
t | CellId | cellid to change this pixel into. |
public setpixi(i: IndexCoordinate, t: CellId) source
Change the pixel at position i into CellId t. This standard implementation also keeps track of cell volumes for all nonzero cell IDs. Subclasses may want to do more, such as also keeping track of perimeters or even centroids. In that case, this method needs to be overridden.
See also setpix for a method working with ArrayCoordinates.
Params:
Name | Type | Attribute | Description |
i | IndexCoordinate | coordinate of pixel to change. |
|
t | CellId | cellid to change this pixel into. |
public abstract timeStep() source
Update the grid in one timestep. This method is model-dependent and must be implemented in the subclass.