import PersistenceConstraint from 'Artistoo/src/hamiltonian/PersistenceConstraint.js'
PersistenceConstraint
Extends:
This is a constraint in which each cell has a preferred direction of migration. This direction is only dependent on the cell, not on the specific pixel of a cell.
This constraint works with torus as long as the field size is large enough.
Constructor Summary
Public Constructor | ||
public |
constructor(conf: object) The constructor of the PersistenceConstraint requires a conf object with parameters. |
Member Summary
Public Members | ||
public set |
Set the CPM attached to this constraint. |
|
public |
Cache centroids over the previous conf.DELTA_T MCS to determine directions. |
|
public |
Target direction of movement of each cell. |
Method Summary
Public Methods | ||
public |
This method checks that all required parameters are present in the object supplied to the constructor, and that they are of the right format. |
|
public |
deltaH(sourcei: IndexCoordinate, targeti: IndexCoordinate, src_type: CellId, tgt_type: CellId): number Method to compute the Hamiltonian for this constraint. |
|
public |
After each MCS, update the target direction of each cell based on its actual direction over the last {conf.DELTA_T[cellkind]} steps, and some angular noise depending on {conf.PERSIST[cellkind]}. |
|
public |
This function samples a random direction vector with length 1 |
|
public |
setDirection(t: CellId, dx: number[]) Change the target direction of a cell to a given vector. |
Private Methods | ||
private |
Normalize a vector a by its length. |
|
private |
sampleNorm(mu: number, sigma: number): number this function samples a random number from a normal distribution |
Inherited Summary
From class Constraint | ||
public get abstract |
This method is actually implemented in the subclass. |
|
public set |
This function attaches the relevant CPM to this constraint, so that information about this cpm can be requested from the constraint. |
|
public get |
parameters: object: * Get the parameters of this constraint from the conf object. |
|
public |
CPM on which this constraint acts. |
|
public |
Configuration object for this constraint. |
|
public abstract |
cellParameter(param: string, cid: CellId): any Get a cellid or cellkind-specific parameter for a constraint. |
|
public abstract |
The optional confChecker method should verify that all the required conf parameters are actually present in the conf object and have the right format. |
|
public |
paramOfCell(param: string, cid: CellId): any Get a cellId specific parameter, only used if CPMEvol is used: looks whether the requested parameter is overwritten in an @object Cell and otherwise returns @function paramOfKind |
|
public |
paramOfKind(param: string, cid: CellId): any Returns a cellKind specfic variable: Assumes that the parameter is indexable by cellkind. |
From class SoftConstraint | ||
public get |
Let the CPM know that this is a soft constraint, so return 'soft'. |
|
public abstract |
deltaH(src_i: IndexCoordinate, tgt_i: IndexCoordinate, src_type: CellId, tgt_type: CellId): number Soft constraints must have a deltaH method to compute the Hamiltonian. |
Public Constructors
public constructor(conf: object) source
The constructor of the PersistenceConstraint requires a conf object with parameters.
Override:
Constraint#constructorParams:
Name | Type | Attribute | Description |
conf | object | parameter object for this constraint |
|
conf.LAMBDA_DIR | PerKindNonNegative | strength of the persistenceconstraint per cellkind. |
|
conf.DELTA_T | PerKindNonNegative |
|
the number of MCS over which the current direction is determined. Eg if DELTA_T = 10 for a cellkind, then its current direction is given by the vector from its centroid 10 MCS ago to its centroid now. |
conf.PERSIST | PerKindProb | persistence per cellkind. If this is 1, its new target direction is exactly equal to its current direction. If it is lower than 1, angular noise is added accordingly. |
Public Members
public cellcentroidlists: CellObject source
Cache centroids over the previous conf.DELTA_T MCS to determine directions.
Public Methods
public confChecker() source
This method checks that all required parameters are present in the object supplied to the constructor, and that they are of the right format. It throws an error when this is not the case.
Override:
Constraint#confCheckerpublic deltaH(sourcei: IndexCoordinate, targeti: IndexCoordinate, src_type: CellId, tgt_type: CellId): number source
Method to compute the Hamiltonian for this constraint.
Override:
SoftConstraint#deltaHParams:
Name | Type | Attribute | Description |
sourcei | IndexCoordinate | coordinate of the source pixel that tries to copy. |
|
targeti | IndexCoordinate | coordinate of the target pixel the source is trying to copy into. |
|
src_type | CellId | cellid of the source pixel. |
|
tgt_type | CellId | cellid of the target pixel. This argument is not used by this method, but is supplied for consistency with other SoftConstraints. The CPM will always call this method supplying the tgt_type as fourth argument. |
public postMCSListener() source
After each MCS, update the target direction of each cell based on its actual direction over the last {conf.DELTA_T[cellkind]} steps, and some angular noise depending on {conf.PERSIST[cellkind]}.
Listen:
because when the CPM has finished an MCS, cells have new centroids and their direction must be updated. |
public randDir(n: number): number[] source
This function samples a random direction vector with length 1
Params:
Name | Type | Attribute | Description |
n | number |
|
number of dimensions of the space to make the vector in. |
public setDirection(t: CellId, dx: number[]) source
Change the target direction of a cell to a given vector.
Private Methods
private normalize(a: number[]): number[] source
Normalize a vector a by its length.
Params:
Name | Type | Attribute | Description |
a | number[] | vector to normalize. |