-
- All Implemented Interfaces:
-
java.io.Serializable
,java.lang.Iterable
public interface Environment<T, P extends Position<out P>> implements Serializable, Iterable<Node<T>>
Interface for an environment. Every environment must implement this specification.
-
-
Method Summary
Modifier and Type Method Description abstract void
addLayer(Molecule m, Layer<T, P> l)
Add a Layer to the Environment. abstract void
addNode(Node<T> node, P p)
This method allows to add a new node to this environment. abstract void
addTerminator(Predicate<Environment<T, P>> terminator)
abstract int
getDimensions()
The number of dimensions of this environment. abstract double
getDistanceBetweenNodes(Node<T> n1, Node<T> n2)
Measures the distance between two nodes in the environment. abstract Incarnation<T, P>
getIncarnation()
abstract Optional<Layer<T, P>>
getLayer(Molecule m)
Get the layer associate to the given molecule. abstract ListSet<Layer<T, P>>
getLayers()
Return all the Layers in this Environment. abstract LinkingRule<T, P>
getLinkingRule()
abstract Neighborhood<T>
getNeighborhood(Node<T> center)
Given a node, this method returns its neighborhood. abstract Node<T>
getNodeByID(int id)
Allows to access a node known its id. abstract ListSet<Node<T>>
getNodes()
All the nodes that exist in current environment. abstract int
getNodeCount()
abstract ListSet<Node<T>>
getNodesWithinRange(Node<T> center, double range)
Given a node (center) this method returns a list of all the surroundings nodes within the given range. abstract ListSet<Node<T>>
getNodesWithinRange(P center, double range)
Given a Position(center) this method returns a list of all the surroundings nodes within the given range. abstract Array<double>
getOffset()
This method allows to know which are the smallest coordinates represented. abstract P
getPosition(Node<T> node)
Calculates the position of a node. abstract Simulation<T, P>
getSimulation()
abstract Array<double>
getSize()
This method returns the size of the environment as an array of length getDimensions. abstract Array<double>
getSizeInDistanceUnits()
This method returns the size of the environment as an array of length getDimensions. abstract boolean
isTerminated()
abstract P
makePosition(Array<Number> coordinates)
abstract void
moveNodeToPosition(Node<T> node, P position)
This method moves a node in the environment to some position. abstract void
removeNode(Node<T> node)
This method allows to remove a node. abstract void
setLinkingRule(LinkingRule<T, P> rule)
abstract void
setSimulation(Simulation<T, P> s)
-
-
Method Detail
-
addNode
abstract void addNode(Node<T> node, P p)
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.
- Parameters:
node
- The node to addp
- The position where to place it
-
addTerminator
abstract void addTerminator(Predicate<Environment<T, P>> terminator)
- Parameters:
terminator
- a Predicate indicating whether the simulation should be considered finished
-
getDimensions
abstract int getDimensions()
The number of dimensions of this environment.
-
getDistanceBetweenNodes
abstract double getDistanceBetweenNodes(Node<T> n1, Node<T> n2)
Measures the distance between two nodes in the environment.
- Parameters:
n1
- the first noden2
- the second node
-
getIncarnation
@Nonnull() abstract Incarnation<T, P> getIncarnation()
-
getLayer
abstract Optional<Layer<T, P>> getLayer(Molecule m)
Get the layer associate to the given molecule. If no Layer is associated with the given molecule, return an empty optional.
- Parameters:
m
- the Molecule
-
getLayers
abstract ListSet<Layer<T, P>> getLayers()
Return all the Layers in this Environment.
-
getLinkingRule
abstract LinkingRule<T, P> getLinkingRule()
-
getNeighborhood
abstract Neighborhood<T> getNeighborhood(Node<T> center)
Given a node, this method returns its neighborhood.
- Parameters:
center
- The node you want the neighbors to be found
-
getNodeByID
abstract Node<T> getNodeByID(int id)
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).
- Parameters:
id
- the node's ID
-
getNodeCount
abstract int getNodeCount()
-
getNodesWithinRange
abstract ListSet<Node<T>> getNodesWithinRange(Node<T> center, double range)
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 getNeighborhood and filter the neighborhood if you are sure that all the nodes within the range are connected to the center.
- Parameters:
center
- the node to consider as centerrange
- the exploration range
-
getNodesWithinRange
abstract ListSet<Node<T>> getNodesWithinRange(P center, double range)
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.
- Parameters:
center
- the Position to consider as centerrange
- the exploration range
-
getOffset
abstract Array<double> getOffset()
This method allows to know which are the smallest coordinates represented.
-
getPosition
@Nonnull() abstract P getPosition(Node<T> node)
Calculates the position of a node.
- Parameters:
node
- the node you want to know the position
-
getSimulation
abstract Simulation<T, P> getSimulation()
-
getSize
abstract Array<double> 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.
-
getSizeInDistanceUnits
abstract Array<double> 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
-
isTerminated
abstract boolean isTerminated()
-
makePosition
abstract P makePosition(Array<Number> coordinates)
- Parameters:
coordinates
- the coordinates of the point
-
moveNodeToPosition
abstract void moveNodeToPosition(Node<T> node, P position)
This method moves a node in the environment to some position. If node move is unsupported, it does nothing.
- Parameters:
node
- The node to moveposition
- The absolute position in which this node will be moved.
-
removeNode
abstract void removeNode(Node<T> node)
This method allows to remove a node. If node removal is unsupported, it does nothing.
- Parameters:
node
- the node to remove
-
setLinkingRule
abstract void setLinkingRule(LinkingRule<T, P> rule)
- Parameters:
rule
- the rule to set
-
setSimulation
abstract void setSimulation(Simulation<T, P> s)
- Parameters:
s
- the simulation
-
-
-
-