import SoftLocalConnectivityConstraint from 'Artistoo/src/hamiltonian/SoftLocalConnectivityConstraint.js'
SoftLocalConnectivityConstraint
Extends:
Soft version of the ConnectivityConstraint which only checks local connectivity.
Constructor Summary
Public Constructor | ||
public |
constructor(conf: object) The constructor of the SoftLocalConnectivityConstraint requires a conf object with one or two parameters. |
Member Summary
Public Members | ||
public set |
The set CPM method attaches the CPM to the constraint. |
|
public |
Should a Neumann or Moore neighborhood be used for determining connectivity? See SoftLocalConnectivityConstraint#constructor for details. |
Method Summary
Public Methods | ||
public |
checkConnected(tgt_i: IndexCoordinate, src_type: CellId, tgt_type: CellId): number 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 |
connectedComponentsOf(pixelobject: object): object Get the connected components of a set of pixels. |
|
public |
deltaH(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 |
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 SoftLocalConnectivityConstraint requires a conf object with one or two parameters.
Override:
Constraint#constructorParams:
Name | Type | Attribute | Description |
conf | object | parameter object for this constraint. |
|
conf.LAMBDA_CONNECTIVITY | PerKindBoolean | strength of the penalty for breaking connectivity. #param {string} conf.NBH_TYPE - should a Neumann (default) or Moore neighborhood be used to determine whether the cell locally stays connected? The default is Neumann since the Moore neighborhood tends to give artefacts. Also, LAMBDA should be much higher if the Moore neighborhood is used. |
Public Members
public set CPM source
The set CPM method attaches the CPM to the constraint. It checks whether the CPM is 2D or 3D, because this constraint is currently only tested in 2D.
Override:
Constraint#CPMpublic nbhtype: string source
Should a Neumann or Moore neighborhood be used for determining connectivity? See SoftLocalConnectivityConstraint#constructor for details.
Public Methods
public checkConnected(tgt_i: IndexCoordinate, src_type: CellId, tgt_type: CellId): number source
This method checks if the connectivity still holds after pixel tgt_i is changed from tgt_type to src_type.
Params:
Name | Type | Attribute | Description |
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. |
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 connectedComponentsOf(pixelobject: object): object source
Get the connected components of a set of pixels.
Params:
Name | Type | Attribute | Description |
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. |
public deltaH(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:
SoftConstraint#deltaHParams:
Name | Type | Attribute | Description |
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. |