BioRect2DEnvironmentNoOverlap

Implements a limited environment supporting cells with a defined shape, avoiding any overlapping among them.

Constructors

Link copied to clipboard
constructor(incarnation: BiochemistryIncarnation)
Returns an infinite BioRect2DEnvironment.
constructor(incarnation: BiochemistryIncarnation, minX: Double, maxX: Double, minY: Double, maxY: Double)
Returns a limited rectangular BioRect2DEnvironment.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
abstract fun addLayer(molecule: Molecule, layer: Layer<T, P>)
open fun addLayer(molecule: Molecule, layer: Layer<T, P>)

Associates layer with molecule. Layers are part of the environment setup: association fails once the environment is attached to a simulation, and a molecule cannot be associated with more than one layer.

Link copied to clipboard
abstract fun addNode(node: Node<T>, position: P): Boolean
open fun addNode(node: Node<T>, position: P): Boolean

Adds a new node to this environment in a specific position. The environment is responsible for calling the right method of the simulation to ensure that the reaction is properly scheduled. The function returns true if the node is added to the environment.

Link copied to clipboard
abstract fun addReaction(reaction: Reaction<T>)
open fun addReaction(reaction: Reaction<T>)

Registers reaction and notifies the running simulation when it was not already present. Fails if this is not the Reaction.host of reaction.

Link copied to clipboard
abstract fun addTerminator(terminator: TerminationPredicate<T, P>)

Add a terminator indicating whether the simulation should be considered finished. The simulation finishes as soon as any of the terminators is satisfied.

open fun addTerminator(terminator: TerminationPredicate<T, P>)

Adds to the simulation a predicate that determines whether a simulation should be terminated.

Link copied to clipboard
fun <T> Environment<T, *>.allShortestHopPaths(): SymmetricMatrix<Double>

Calculates the shortest paths using the Floyd-Warshall algorithm calculating the Hop Distance between nodes.

Link copied to clipboard
fun <T> Environment<T, *>.allSubNetworks(computeDistance: (Node<T>, Node<T>) -> Double = environmentMetricDistance()): Set<Network<T>>

Computes the diameter of all subnetworks in the environment. The diameter is the longest shortest path between any two nodes. Returns a Map containing the subnetwork related to each Node of the environment.

Link copied to clipboard
fun <T> Environment<T, *>.allSubNetworksByNode(computeDistance: (Node<T>, Node<T>) -> Double = environmentMetricDistance()): Map<Node<T>, Network<T>>

Computes the diameter of all subnetworks in the environment. The diameter is the longest shortest path between any two nodes. Returns a Map mapping each node to the subnetwork it belongs to.

Link copied to clipboard

Computes the diameter of all subnetworks in the environment. The diameter is the longest shortest path between any two nodes, evaluated using the allShortestHopPaths method. Returns a Set containing the subnetworks.

Link copied to clipboard

Computes the diameter of all subnetworks in the environment. The diameter is the longest shortest path between any two nodes, evaluated using the allShortestHopPaths method. Returns a Set containing the subnetworks.

Link copied to clipboard
open fun contains(node: Node<T>): Boolean
open fun contains(node: Node<T>): Boolean

Whether node is part of this environment.

Link copied to clipboard
open fun currentPositionOf(node: Node<T>): P
open fun currentPositionOf(node: Node<T>): P

Retrieves node's current position.

Link copied to clipboard
abstract fun distanceBetween(n1: Node<T>, n2: Node<T>): Double
open fun distanceBetween(n1: Node<T>, n2: Node<T>): Double

Measures the distance between two nodes (n1, n2) in the environment.

Link copied to clipboard
open fun distanceTo($this$distanceTo: Node<T>, other: Node<T>): Double

The distance between this node and other, see distanceBetween.

Link copied to clipboard
Circular cells stop before overlapping other circular cells, within the limits of the environment.
open fun farthestReachablePosition(node: Node<T>, desired: P): P

Movements are unconstrained: subclasses constraining them override this function, starting from the position that it returns.

Link copied to clipboard
open fun getCurrentPosition($this$currentPosition: Node<T>): P

The current position of this node, see currentPositionOf.

Link copied to clipboard
abstract fun getHeading(node: Node<T>): P

Gets the heading of a node as a direction vector.

Link copied to clipboard
abstract fun getIncarnation(): Incarnation<T, P>

Return the Incarnation used to initialize the entities of this Environment, if it has been set.

Link copied to clipboard
abstract fun getLayers(): Map<Molecule, Layer<T, P>>

Return all the Layers in this Environment.

The biggest diameter among the unstressed deformable cells, or zero if there are none.
Link copied to clipboard
open fun getNeighborhood($this$neighborhood: Node<T>): Observable<Neighborhood<T>>

The observable neighborhood of this node, see neighborhoodOf.

Link copied to clipboard
abstract fun getNetworkModel(): NetworkModel<T>

The current NetworkModel, which must be bound to this environment. Assigning a new model publishes the neighborhood it provides for every node in the environment.

Link copied to clipboard

Returns an Observable view of the number of Nodes currently in the Environment.

Link copied to clipboard
abstract fun getNodes(): ObservableList<Node<T>>

An ordered Observable view of all the Nodes that exist in current Environment.

Link copied to clipboard
abstract fun getNodesWithin(shape: Shape<P, A>): List<Node<T>>

Gets all nodes whose shape.intersect is true for the given shape.

Link copied to clipboard
abstract fun getOffset(): Array<Double>

This method allows to know which are the smallest coordinates represented. Return an array of length dimensions containing the smallest coordinates for each dimension.

Link copied to clipboard
open fun getOrigin(): P

Create a position corresponding to the origin of this environment.

Link copied to clipboard
open fun getPosition($this$position: Node<T>): Observable<P>

The observable position of this node, see positionOf.

Link copied to clipboard

The reactions registered with this host, in registration order; ObservableList.current is a snapshot.

Link copied to clipboard
abstract fun getShape(node: Node<T>): Shape<P, A>

Gets the shape of a node relatively to its position and heading in the environment.

Link copied to clipboard
abstract fun getShapeFactory(): F

A factory of shapes compatible with this environment.

Link copied to clipboard
abstract fun getSimulation(): Simulation<T, P>

Return the current Simulation, if present, or throws an IllegalStateException otherwise.

Link copied to clipboard
abstract fun getSimulationOrNull(): Simulation<T, P>

Return the current Simulation, if present, or null otherwise.

Link copied to clipboard
abstract fun getSize(): Array<Double>

The size of the environment as an array of length getDimensions(). This method must return distance measured with the same unit used by the positions. No non-euclidean distance metrics are allowed.

Link copied to clipboard

This method returns the size of the environment as an array of length .getDimensions. This method must return distance measured with the same unit used for measuring distances. It may or may not return the same result of .getSize.

Override this property if units measuring distance do not match with units used for coordinates. For instance, if your space is non-Euclidean, or if you are using polar coordinates. A notable example is using geographical latitude-longitude as y-x coordinates and meters as distance measure.

Link copied to clipboard

Returns true the network is segmented, false otherwise.

Link copied to clipboard
abstract fun isTerminated(): Boolean
open fun isTerminated(): Boolean

Whether any of the terminators is satisfied.

Link copied to clipboard
abstract fun layerFor(molecule: Molecule): Layer<T, P>
open fun layerFor(molecule: Molecule): Layer<T, P>

Get the Layer associate to the given molecule. If no Layer is associated with the given molecule, return null.

Link copied to clipboard
abstract fun makePosition(coordinates: Array<Number>): P

Given the coordinates of the point, returns a Position compatible with this environment.

Creates a new Euclidean2DPosition.

open fun makePosition(coordinates: Array<Number>): Euclidean2DPosition

Creates an euclidean position from the given coordinates.

Link copied to clipboard
open fun moveBy($this$moveBy: Node<T>, displacement: P)

Moves this node by displacement, relative to its current position, see moveNodeBy.

Link copied to clipboard
open fun moveNodeBy(node: Node<T>, displacement: P)

Moves node by displacement, relative to its current position, through moveNodeTo. Environments constraining movements should override moveNodeTo rather than this function, so that their constraints apply to absolute movements as well.

Link copied to clipboard
abstract fun moveNodeTo(node: Node<T>, position: P)

Moves node to position. If node movement is unsupported, it does nothing.

open fun moveNodeTo(node: Node<Double>, position: Euclidean2DPosition)

Only cells move. After a cell moves, its junctions with nodes that are no longer neighbors are removed.

Link copied to clipboard
open fun moveTo($this$moveTo: Node<T>, position: P)

Moves this node to position, see moveNodeTo.

Link copied to clipboard
abstract fun neighborhoodOf(node: Node<T>): Observable<Neighborhood<T>>

Given a node, this method returns an observable view of its neighborhood.

Link copied to clipboard

Returns the diameter of the network in environment units if it is not segmented, and NaN otherwise.

Link copied to clipboard

Returns the hop-distance diameter of the network if it is not segmented, and NaN otherwise.

Computes the network diameter of the segment containing node.

Link copied to clipboard
abstract fun nodesAround(node: Node<T>, range: Double): List<Node<T>>
open fun nodesAround(node: Node<T>, range: Double): List<Node<T>>

Given a node this method returns a list of all the surrounding nodes within the given range. Note that this method (depending on the implementation) might be not optimized, and it's consequently much better to use Environment.neighborhoodOf and filter the neighborhood if you are sure that all the nodes within the range are connected to the center.

Link copied to clipboard
open fun nodesInRange($this$nodesInRange: Node<T>, range: Double): List<Node<T>>

The nodes within range of this node, see nodesAround.

Link copied to clipboard
abstract fun nodeWithId(id: Int): Node<T>
open fun nodeWithId(id: Int): Node<T>

Allows accessing a Node in this Environment known its id. Depending on the implementation, this method may or may not be optimized (namely, id could run in constant or linear time with the number of nodes).

Link copied to clipboard
abstract fun observeLayerValue(molecule: Molecule, node: Node<T>): Observable<T>
open fun observeLayerValue(molecule: Molecule, node: Node<T>): Observable<T>

Observes the value of the Layer associated with molecule at the position of node. The observable emits when node moves to a position where the value differs, and when the layer changes the value at the current position of node. Its value is null while no layer is associated with molecule, and it emits when one is: observables created during setup follow layers associated later.

Link copied to clipboard
abstract fun observeNodesAround(node: Node<T>, range: Double): ObservableSet<Node<T>>
open fun observeNodesAround(node: Node<T>, range: Double): ObservableSet<Node<T>>

An Observable alternative to nodesAround.

Link copied to clipboard
open fun observeNodesInRange($this$observeNodesInRange: Node<T>, range: Double): ObservableSet<Node<T>>

Observes the nodes within range of this node, see observeNodesAround.

Link copied to clipboard
abstract fun positionOf(node: Node<T>): Observable<P>
open fun positionOf(node: Node<T>): Observable<P>

Observe the position of a node.

Link copied to clipboard
open fun remove($this$remove: Node<T>)

Removes this node, see removeNode.

Link copied to clipboard
abstract fun removeNode(node: Node<T>)
open fun removeNode(node: Node<T>)

Removes node. If node removal is unsupported, it does nothing.

Link copied to clipboard
abstract fun removeReaction(reaction: Reaction<T>)
open fun removeReaction(reaction: Reaction<T>)

Unregisters reaction and notifies the running simulation when it was actually present.

Link copied to clipboard
abstract fun setHeading(node: Node<T>, direction: P)
open fun setHeading(node: Node<T>, direction: Euclidean2DPosition)

Sets the heading of a node.

Link copied to clipboard
abstract fun setNetworkModel(<set-?>: NetworkModel<T>)

The current NetworkModel, which must be bound to this environment. Assigning a new model publishes the neighborhood it provides for every node in the environment.

Link copied to clipboard
abstract fun setSimulation(<set-?>: Simulation<T, P>)
fun setSimulation(value: Simulation<T, P>)

Return the current Simulation, if present, or throws an IllegalStateException otherwise.

Link copied to clipboard
infix fun <T, P : Position<P>> Environment<T, P>.shouldEqual(other: Environment<T, P>)
Link copied to clipboard
fun <T, P : Position<out P>, TS : Any> Environment<T, P>.toEnvironmentSurrogate(toConcentrationSurrogate: (T) -> TS): EnvironmentSurrogate<TS, PositionSurrogate>

A function that maps an Environment to its surrogate class (EnvironmentSurrogate). Use the toSuitablePositionSurrogate strategy for PositionSurrogate mapping.

fun <T, P : Position<out P>, TS : Any, PS : PositionSurrogate> Environment<T, P>.toEnvironmentSurrogate(toConcentrationSurrogate: (T) -> TS, toPositionSurrogate: (P) -> PS): EnvironmentSurrogate<TS, PS>

A function that maps an Environment to its surrogate class (EnvironmentSurrogate).

Link copied to clipboard
open fun toPosition($this$toPosition: Array<Double>): P

A position with these coordinates, see makePosition.

Link copied to clipboard
open fun toString(): String

Not used internally. Override as you please.