import GridBasedModel from 'Artistoo/src/models/GridBasedModel.js'
public class

GridBasedModel

Indirect Subclass:

CPMEvol

Base class for grid-based models. This class is not used by itself; see CPM for a Cellular Potts Model and CA for a Cellular Automaton.

Constructor Summary

 Public Constructor public constructor(extents: GridSize, conf: object, seed: number) The constructor of a GridBasedModel automatically attaches a grid of class Grid2D or Grid3D, depending on the grid dimensions given in the 'extents' parameter.

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 * cellIDs(): CellId Iterator for all the CellIds that are currently on the grid. public cellKind(t: CellId): CellKind Get the CellKind of the cell with CellId t. public getStat(s: Stat): anything 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 Get CellId of the pixel at coordinates p. public ran(incl_min: number, incl_max: number): number Get a random integer number between incl_min and incl_max, uniformly sampled. public random(): number 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

publicconstructor(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[] optional default: [true,true,...] should the grid have linked borders? conf.hexGrid boolean optional default: false should the grid be hexagonal? Grids are square by default. seed number optional seed for the random number generator. If left unspecified, a random number from the Math.random() generator is used to make one.

Public Members

publiccellvolume: *[] source

This tracks the volumes of all non-background cells on the grid. cellvolumes will be added with key = CellId, value = volume. @type{number[]}

publicconf: object source

Input parameter settings; see the constructor of subclasses documentation.

publicextents: GridSize source

Size of the grid.

publicfield_size: object source

Size of the grid in object format.

publicmidpoint: ArrayCoordinate source

Midpoint of the grid.

publicmt: MersenneTwister source

Attach a random number generation with a seed.

publicndim: number source

Dimensionality of the grid

publicneighi: function source

The Grid2D#neighi or Grid3D#neighi iterator function of the underlying grid.

publicpixels: function source

The Grid2D#pixels or Grid3D#pixels iterator function of the underlying grid.

publicpixti: function source

The Grid#pixti iterator function of the underlying grid.

publicstat_values: object source

Cached values of these stats. Object with stat name as key and its cached value as value. The cache must be cleared when the grid changes!

publicstats: Stat source

Objects of class Stat that have been computed on this model.

publictime: number source

Tracks the elapsed time in MCS

Public Methods

public*cellIDs(): CellId source

Iterator for all the CellIds that are currently on the grid.

publiccellKind(t: CellId): CellKind source

Get the CellKind of the cell with CellId t. For this model, they are just the same.

Params:

 Name Type Attribute Description t CellId id of the cell to get kind of.

Return:

 CellKind the cellkind.

publicgetStat(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.

Return:

 anything the value of the computed stat. This is often a CellObject or a CellArrayObject.

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 )

publicneigh(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[] optional default: [true,true,...] Does the grid have linked borders? If left unspecified, this is determined by this.conf.torus.

 *

publicpixt(p: ArrayCoordinate): CellId source

Get CellId of the pixel at coordinates p.

Params:

 Name Type Attribute Description p ArrayCoordinate pixel to get cellid of.

Return:

 CellId ID of the cell p belongs to.

publicran(incl_min: number, incl_max: number): number source

Get a random integer number between incl_min and incl_max, uniformly sampled.

Params:

 Name Type Attribute Description incl_min number lower end of the sampling range. incl_max number upper end of the sampling range.

Return:

 number the randomly sampled integer.

publicrandom(): number source

Get a random number from the seeded number generator.

Return:

 number a random number between 0 and 1, uniformly sampled.

publicsetpix(p: ArrayCoordinate, t: CellId) source

Change the pixel at position p into CellId t. This just calls the setpixi method internally.

Params:

 Name Type Attribute Description p ArrayCoordinate coordinate of pixel to change. t CellId cellid to change this pixel into.

publicsetpixi(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.