Interface Environment
-
- All Implemented Interfaces:
-
java.io.Serializable
,java.lang.Iterable
public interface Environment<T, P extends Position<out P>> implements Serializable, Iterable<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
addGlobalReaction(GlobalReaction<T> reaction)
Add a GlobalReaction to the Environment. abstract void
removeGlobalReaction(GlobalReaction<T> reaction)
Remove a GlobalReaction from the Environment. abstract ListSet<GlobalReaction<T>>
getGlobalReactions()
Get the Environment's GlobalReactions. abstract boolean
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 void
setLinkingRule(LinkingRule<T, P> rule)
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 void
setSimulation(Simulation<T, P> s)
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(@Nonnull() Node<T> node, @Nonnull() 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. -
-
Method Detail
-
addGlobalReaction
abstract void addGlobalReaction(GlobalReaction<T> reaction)
Add a GlobalReaction to the Environment.
- Parameters:
reaction
- the GlobalReaction to add.
-
removeGlobalReaction
abstract void removeGlobalReaction(GlobalReaction<T> reaction)
Remove a GlobalReaction from the Environment.
- Parameters:
reaction
- GlobalReaction to remove.
-
getGlobalReactions
abstract ListSet<GlobalReaction<T>> getGlobalReactions()
Get the Environment's GlobalReactions.
- Returns:
the list of GlobalReactions in this Environment.
-
addNode
abstract boolean 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- Returns:
true if node is added in the environment
-
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.
- Returns:
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- Returns:
the distance between the two nodes
-
getIncarnation
@Nonnull() abstract Incarnation<T, P> getIncarnation()
- Returns:
the Incarnation used to initialize the entities of this Environment, if it has been set.
-
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.
-
getLayers
abstract ListSet<Layer<T, P>> getLayers()
Return all the Layers in this Environment.
- Returns:
a ListSet of Layer.
-
getLinkingRule
abstract LinkingRule<T, P> getLinkingRule()
- Returns:
the current linking rule
-
setLinkingRule
abstract void setLinkingRule(LinkingRule<T, P> rule)
- Parameters:
rule
- the rule to set
-
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- Returns:
the neighborhood
-
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- Returns:
the node with that id, or null if it does not exist in this environment
-
getNodes
abstract ListSet<Node<T>> getNodes()
All the nodes that exist in current environment.
- Returns:
All the nodes that exist in current environment
-
getNodeCount
abstract int getNodeCount()
- Returns:
the number of nodes currently in the environment
-
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- Returns:
the list of nodes within the 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- Returns:
the list of nodes within the range
-
getOffset
abstract Array<double> getOffset()
This method allows to know which are the smallest coordinates represented.
- Returns:
an array of length getDimensions() containing the smallest coordinates for each dimension.
-
getPosition
@Nonnull() abstract P getPosition(Node<T> node)
Calculates the position of a node.
- Parameters:
node
- the node you want to know the position- Returns:
The position
-
getSimulation
abstract Simulation<T, P> getSimulation()
- Returns:
the current simulation, if present, or throws an IllegalStateException otherwise
-
setSimulation
abstract void setSimulation(Simulation<T, P> s)
- Parameters:
s
- the simulation
-
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.
- Returns:
the size of this environment
-
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
- Returns:
the size of this environment
-
isTerminated
abstract boolean isTerminated()
- Returns:
true if all the terminators are true
-
makePosition
abstract P makePosition(Array<Number> coordinates)
- Parameters:
coordinates
- the coordinates of the point- Returns:
a Position compatible with this environment
-
moveNodeToPosition
@Nonnull() abstract void moveNodeToPosition(@Nonnull() Node<T> node, @Nonnull() 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
-
-
-
-