alchemist-interfaces / it.unibo.alchemist.model.interfaces / Environment

Environment

interface Environment<T : Any!, P : Position<out P>!> : Serializable, MutableIterable<Node<T>!>

Interface for an environment. Every environment must implement this specification.

Functions

addLayer

Add a Layer to the Environment.

abstract fun addLayer(m: Molecule!, l: Layer<T, P>!): Unit

addNode

This method allows to add a new node to this environment. The environment is responsible to call the right method of the simulation in order to ensure that the reaction is properly scheduled.

abstract fun addNode(node: Node<T>!, p: P): Unit

addTerminator

abstract fun addTerminator(terminator: Predicate<Environment<T, P>!>!): Unit

getDimensions

The number of dimensions of this environment.

abstract fun getDimensions(): Int

getDistanceBetweenNodes

Measures the distance between two nodes in the environment.

abstract fun getDistanceBetweenNodes(n1: Node<T>!, n2: Node<T>!): Double

getIncarnation

abstract fun getIncarnation(): Optional<Incarnation<T, P>!>!

getLayer

Get the layer associate to the given molecule. If no Layer is associated with the given molecule, return an empty optional.

abstract fun getLayer(m: Molecule!): Optional<Layer<T, P>!>!

getLayers

Return all the Layers in this Environment.

abstract fun getLayers(): ListSet<Layer<T, P>!>!

getLinkingRule

abstract fun getLinkingRule(): LinkingRule<T, P>!

getNeighborhood

Given a node, this method returns its neighborhood.

abstract fun getNeighborhood(center: Node<T>!): Neighborhood<T>!

getNodeByID

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

abstract fun getNodeByID(id: Int): Node<T>!

getNodes

All the nodes that exist in current environment.

abstract fun getNodes(): ListSet<Node<T>!>!

getNodesNumber

abstract fun getNodesNumber(): Int

getNodesWithinRange

Given a node (center) this method returns a list of all the surroundings 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#getNeighborhood(Node) and filter the neighborhood if you are sure that all the nodes within the range are connected to the center.

abstract fun getNodesWithinRange(center: Node<T>!, range: Double): ListSet<Node<T>!>!

Given a Position(center) this method returns a list of all the surroundings nodes within the given range. Note that this method (depending on the implementation) might be not optimized.

abstract fun getNodesWithinRange(center: P, range: Double): ListSet<Node<T>!>!

getOffset

This method allows to know which are the smallest coordinates represented.

abstract fun getOffset(): DoubleArray!

getPosition

Calculates the position of a node.

abstract fun getPosition(node: Node<T>!): P

getSimulation

abstract fun getSimulation(): Simulation<T, P>!

getSize

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 by the positions. No non-euclidean distance metrics are allowed.

abstract fun getSize(): DoubleArray!

getSizeInDistanceUnits

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()

abstract fun getSizeInDistanceUnits(): DoubleArray!

isTerminated

abstract fun isTerminated(): Boolean

makePosition

abstract fun makePosition(vararg coordinates: Number!): P

moveNode

This method moves a node in the environment toward some direction. If node move is unsupported, it does nothing.

abstract fun moveNode(node: Node<T>!, direction: P): Unit

moveNodeToPosition

This method moves a node in the environment to some position. If node move is unsupported, it does nothing.

abstract fun moveNodeToPosition(node: Node<T>!, position: P): Unit

removeNode

This method allows to remove a node. If node removal is unsupported, it does nothing.

abstract fun removeNode(node: Node<T>!): Unit

setIncarnation

abstract fun setIncarnation(incarnation: Incarnation<T, P>!): Unit

setLinkingRule

abstract fun setLinkingRule(rule: LinkingRule<T, P>!): Unit

setSimulation

abstract fun setSimulation(s: Simulation<T, P>!): Unit

Inheritors

BenchmarkableEnvironment

An environment which provides a mean to get infos about its performances.

interface BenchmarkableEnvironment<T : Any!, P : Position<out P>!> : Environment<T, P>

Environment2DWithObstacles

interface Environment2DWithObstacles<W : Obstacle2D!, T : Any!, P : Position<out P>!> : Environment<T, P>