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

BorderConstraint

Extends:

ConstraintHardConstraint → BorderConstraint

This constraint allows a set of "barrier" background pixels, into which copy attempts are forbidden.

Example:

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

// Build a barrier and add the border constraint
let border = []
let channelwidth = 10
for( let x = 0; x < C.extents[0]; x++ ){
	let ymin = Math.floor( C.extents[1]/2 )
 let ymax = ymin + channelwidth
 border.push( [x,ymin] )
 border.push( [x,ymax] )
}

C.add( new CPM.BorderConstraint( {
	BARRIER_VOXELS : border
} ) )

// Seed a cell
let gm = new CPM.GridManipulator( C )
gm.seedCell(1)

Constructor Summary

Public Constructor
public

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

Member Summary

Public Members
public

Store which pixels are barrier pixels.

public

Track if this.barriervoxels has been set.

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

fulfilled(src_i: IndexCoordinate, tgt_i: IndexCoordinate, src_type: CellId, tgt_type: CellId): boolean

Method for hard constraints to compute whether the copy attempt fulfills the rule.

public

Get the background voxels from input argument or the conf object and store them in a correct format in this.barriervoxels.

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 HardConstraint
public get

Let the CPM know that this is a soft constraint, so return 'soft'.

public abstract

fulfilled(src_i: IndexCoordinate, tgt_i: IndexCoordinate, src_type: CellId, tgt_type: CellId): boolean

Hard constraints must have a 'fulfilled' method to compute whether the copy attempt fulfills the rule.

Public Constructors

public constructor(conf: object) source

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

Override:

Constraint#constructor

Params:

NameTypeAttributeDescription
conf object

parameter object for this constraint

conf.ACT_MEAN string
  • optional
  • default: "geometric"

should local mean activity be measured with an "arithmetic" or a "geometric" mean?

conf.LAMBDA_ACT_MBG PerKindArray

strength of the activityconstraint per cellkind and per background.

conf.MAX_ACT PerKindNonNegative

how long do pixels remember their activity? Given per cellkind.

conf.BACKGROUND_VOXELS Array

an array where each element represents a different background type. This is again an array of {@ArrayCoordinate}s of the pixels belonging to that backgroundtype. These pixels will have the LAMBDA_ACT_MBG value of that backgroundtype, instead of the standard value.

Public Members

public barriervoxels: object source

Store which pixels are barrier pixels. Each entry has key the {@IndexCoordinate} of the pixel, and value equal to true.

public setup: boolean source

Track if this.barriervoxels has been set.

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 fulfilled(src_i: IndexCoordinate, tgt_i: IndexCoordinate, src_type: CellId, tgt_type: CellId): boolean source

Method for hard constraints to compute whether the copy attempt fulfills the rule.

Override:

HardConstraint#fulfilled

Params:

NameTypeAttributeDescription
src_i IndexCoordinate

coordinate of the source pixel that tries to copy.

tgt_i 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:

boolean

whether the copy attempt satisfies the constraint.

public setBarrierVoxels(voxels: ArrayCoordinate[]) source

Get the background voxels from input argument or the conf object and store them in a correct format in this.barriervoxels. This only has to be done once, but can be called from outside to change the background voxels during a simulation (eg in a HTML page).

Params:

NameTypeAttributeDescription
voxels ArrayCoordinate[]

the pixels that should act as barrier.