Package 

Interface Environment

  • 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.

    • Constructor Detail

    • 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 add
        p - The position where to place it
      • 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 node
        n2 - the second node
      • 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
      • 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
      • getNodes

         abstract ListSet<Node<T>> getNodes()

        All the nodes that exist in current 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
      • 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
      • 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
      • 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

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