Abstract2DEnvironment

Models a bidimensional environment.

Parameters

incarnation

the incarnation to be used.

Type Parameters

T

concentration type

Inheritors

Properties

Link copied to clipboard
open val Node<T>.currentPosition: P

The current position of this node, see currentPositionOf.

Link copied to clipboard
override val dimensions: Int = 2

The number of dimensions of this environment.

Link copied to clipboard
override val incarnation: Incarnation<T, P>

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

Link copied to clipboard
open override val isTerminated: Boolean

Whether any of the terminators is satisfied.

Link copied to clipboard
override val layers: Map<Molecule, Layer<T, P>>

Return all the Layers in this Environment.

Link copied to clipboard

The observable neighborhood of this node, see neighborhoodOf.

Link copied to clipboard
override var networkModel: 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
override val nodeCount: Observable<Int>

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

Link copied to clipboard
open override val nodes: ObservableList<Node<T>>

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

Link copied to clipboard
override val offset: DoubleArray

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 val Node<T>.position: Observable<P>

The observable position of this node, see positionOf.

Link copied to clipboard
open override val reactions: ObservableList<Reaction<T>>

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

Link copied to clipboard
override var simulation: Simulation<T, P>

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

Link copied to clipboard
override var simulationOrNull: Simulation<T, P>?

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

Link copied to clipboard
override val size: DoubleArray

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
open override val sizeInDistanceUnits: DoubleArray

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.

Functions

Link copied to clipboard
open override 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
open override 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
open override 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
open fun addTerminator(terminator: (Environment<T, P>) -> Boolean)

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

open override 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 operator override fun contains(node: Node<T>): Boolean

Whether node is part of this environment.

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

Retrieves node's current position.

Link copied to clipboard
open override 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 Node<T>.distanceTo(other: Node<T>): Double

The distance between this node and other, see distanceBetween.

Link copied to clipboard
open override 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

Returns true the network is segmented, false otherwise.

Link copied to clipboard
open override 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: DoubleArray): P
open fun makePosition(coordinates: List<Number>): P
abstract fun makePosition(vararg coordinates: Number): P

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

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

Moves node to the farthestReachablePosition towards position, extending the environment to include it.

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

Moves this node to position, see moveNodeTo.

Link copied to clipboard
open override 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
open override fun nodesAround(position: P, range: Double): List<Node<T>>

Given a position 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.

open override 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 P.nodesInRange(range: Double): List<Node<T>>

The nodes within range of this position, see nodesAround.

open fun Node<T>.nodesInRange(range: Double): List<Node<T>>

The nodes within range of this node, see nodesAround.

Link copied to clipboard
open override 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
open override 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
open override fun observeNodesAround(position: P, range: Double): ObservableSet<Node<T>>
open override fun observeNodesAround(node: Node<T>, range: Double): ObservableSet<Node<T>>

An Observable alternative to nodesAround.

Link copied to clipboard

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

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

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

Observe the position of a node.

Link copied to clipboard
open fun Node<T>.remove()

Removes this node, see removeNode.

open fun Reaction<T>.remove()

Unregisters this reaction from its host, see removeReaction.

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

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

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

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

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

A position with these coordinates, see makePosition.

Link copied to clipboard
open override fun toString(): String

Not used internally. Override as you please.