import PersistenceConstraint from 'Artistoo/src/hamiltonian/PersistenceConstraint.js'
public class | source

PersistenceConstraint

Extends:

ConstraintSoftConstraint → PersistenceConstraint

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.

Test:

Constructor Summary

Public Constructor
public

The constructor of the PersistenceConstraint requires a conf object with parameters.

Member Summary

Public Members
public set

CPM(C: CPM)

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

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

CPM(C: CPM)

This function attaches the relevant CPM to this constraint, so that information about this cpm can be requested from the constraint.

public get

Get the parameters of this constraint from the conf object.

public

C: CPM

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#constructor

Params:

NameTypeAttributeDescription
conf object

parameter object for this constraint

conf.LAMBDA_DIR PerKindNonNegative

strength of the persistenceconstraint per cellkind.

conf.DELTA_T PerKindNonNegative
  • optional
  • default: [10,10,...]

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 set CPM(C: CPM) source

Set the CPM attached to this constraint.

Override:

Constraint#CPM

public cellcentroidlists: CellObject source

Cache centroids over the previous conf.DELTA_T MCS to determine directions.

public celldirections: CellObject source

Target direction of movement of each cell.

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#confChecker

public deltaH(sourcei: IndexCoordinate, targeti: IndexCoordinate, src_type: CellId, tgt_type: CellId): number source

Method to compute the Hamiltonian for this constraint.

Override:

SoftConstraint#deltaH

Params:

NameTypeAttributeDescription
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.

Return:

number

the change in Hamiltonian for this copy attempt and this constraint.

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:

timeStep

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:

NameTypeAttributeDescription
n number
  • optional
  • default: 3

number of dimensions of the space to make the vector in.

Return:

number[]

a normalized direction vector.

public setDirection(t: CellId, dx: number[]) source

Change the target direction of a cell to a given vector.

Params:

NameTypeAttributeDescription
t CellId

the cellid of the cell to change the direction of.

dx number[]

the new direction this cell should get.

Private Methods

private normalize(a: number[]): number[] source

Normalize a vector a by its length.

Params:

NameTypeAttributeDescription
a number[]

vector to normalize.

Return:

number[]

normalized version of this vector.

private sampleNorm(mu: number, sigma: number): number source

this function samples a random number from a normal distribution

Params:

NameTypeAttributeDescription
mu number
  • optional
  • default: 0

mean of the normal distribution.

sigma number
  • optional
  • default: 1

SD of the normal distribution.

Return:

number

the random number generated.