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

LocalConnectivityConstraint

Extends:

ConstraintHardConstraint → LocalConnectivityConstraint
this class is experimental.

Version of the ConnectivityConstraint which only checks local connectivity.

Test:

Constructor Summary

Public Constructor
public

The constructor of the LocalConnectivityConstraint requires a conf object with one parameter.

Method Summary

Public Methods
public

checkConnected(tgt_i: IndexCoordinate, src_type: CellId, tgt_type: CellId): *

This method checks if the connectivity still holds after pixel tgt_i is changed from tgt_type to src_type.

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

Get the connected components of a set of pixels.

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.

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 LocalConnectivityConstraint requires a conf object with one parameter.

Override:

Constraint#constructor

Params:

NameTypeAttributeDescription
conf object

parameter object for this constraint.

conf.CONNECTED PerKindBoolean

should the cellkind be connected or not?

Public Methods

public checkConnected(tgt_i: IndexCoordinate, src_type: CellId, tgt_type: CellId): * source

This method checks if the connectivity still holds after pixel tgt_i is changed from tgt_type to src_type.

Params:

NameTypeAttributeDescription
tgt_i IndexCoordinate

the pixel to change.

src_type CellId

the new cell for this pixel.

tgt_type CellId

the cell the pixel belonged to previously.

Return:

*

Test:

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

Test:

public connectedComponentsOf(pixelObject: object): object source

Get the connected components of a set of pixels.

Params:

NameTypeAttributeDescription
pixelObject object

an object with as keys the IndexCoordinates of the pixels to check.

Return:

object

an array with an element for every connected component, which is in turn an array of the ArrayCoordinates of the pixels belonging to that component.

Test:

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.

Test: