public class | source

Adhesion

Extends:

ConstraintSoftConstraint → Adhesion

Implements the adhesion constraint of Potts models. Each pair of neighboring pixels [n,m] gets a positive energy penalty deltaH if n and m do not belong to the same CellId.

Example:

// Build a CPM and add the constraint
let CPM = require( "path/to/build" )
let C = new CPM.CPM( [200,200], { T : 20 } )
C.add( new CPM.Adhesion( { J : [[0,20],[20,10]] } ) )

// Or add automatically by entering the parameters in the CPM
let C2 = new CPM.CPM( [200,200], {
	T : 20,
	J : [[0,20],[20,10]]
})

Constructor Summary

Public Constructor
public

The constructor of Adhesion requires a conf object with a single parameter J.

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.

Private Methods
private

Returns the Hamiltonian around a pixel i with cellid tp by checking all its neighbors that belong to a different cellid.

private

J(t1: CellId, t2: CellId): number

Get adhesion between two cells t1,t2 from "conf".

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 Adhesion requires a conf object with a single parameter J.

Override:

Constraint#constructor

Params:

NameTypeAttributeDescription
conf object

parameter object for this constraint

conf.J CellKindInteractionMatrix

J[n][m] gives the adhesion energy between a pixel of CellKind n and a pixel of CellKind m. J[n][n] is only non-zero when the pixels in question are of the same CellKind, but a different CellId. Energies are given as non-negative numbers.

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.

Return:

number

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

Private Methods

private H(i: IndexCoordinate, tp: CellId): number source

Returns the Hamiltonian around a pixel i with cellid tp by checking all its neighbors that belong to a different cellid.

Params:

NameTypeAttributeDescription
i IndexCoordinate

coordinate of the pixel to evaluate hamiltonian at.

tp CellId

cellid of this pixel.

Return:

number

sum over all neighbors of adhesion energies (only non-zero for neighbors belonging to a different cellid).

private J(t1: CellId, t2: CellId): number source

Get adhesion between two cells t1,t2 from "conf".

Params:

NameTypeAttributeDescription
t1 CellId

cellid of the first cell.

t2 CellId

cellid of the second cell.

Return:

number

adhesion between a pixel of t1 and one of t2.