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.

    • Constructor Detail

    • Method Detail

      • 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 add
        p - The position where to place it
        Returns:

        true if node is added in the environment

      • 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 node
        n2 - the second node
        Returns:

        the distance between the two nodes

      • 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
        Returns:

        the Optional containing the Layer associated with the requested molecule

      • 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 center
        range - 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 center
        range - 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

      • 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 move
        position - 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