Class RectangularGridModel

  • All Implemented Interfaces:
    ObservableIfc, GetNameIfc, IdentityIfc

    public class RectangularGridModel
    extends SchedulingElement
    This class can be used to hold ModelElements that can be in a RectangularGridSpatialModel2D. This defines a model element with the ability to schedule that has a RectangularGridSpatialModel2D spatial model. Sub-classes can builder on this.
    • Constructor Detail

      • RectangularGridModel

        public RectangularGridModel​(ModelElement parent,
                                    double width,
                                    double height,
                                    int numRows,
                                    int numCols)
        Can be used by sub-classes to redefine the grid ULHC x = 0.0, ULHC y = 0.0
        Parameters:
        parent - the parent model element
        width - the width of the grid
        height - the height of the grid
        numRows - the number of rows in the grid
        numCols - the number of columns in the grid
      • RectangularGridModel

        public RectangularGridModel​(ModelElement parent,
                                    double x,
                                    double y,
                                    double width,
                                    double height,
                                    int numRows,
                                    int numCols,
                                    java.lang.String name)
        Can be used by sub-classes to redefine the grid
        Parameters:
        parent - the parent model element
        x - the ULHC x
        y - the ULHC y
        width - the width of the grid
        height - the height of the grid
        numRows - the number of rows in the grid
        numCols - the number of columns in the grid
        name - the name of the model element
    • Method Detail

      • randInt

        public final int randInt​(int i,
                                 int j)
        Randomly generates an integer between i and j
        Parameters:
        i - the lower limit
        j - the upper limit
        Returns:
        the random integer
      • setGrid

        protected final void setGrid​(double x,
                                     double y,
                                     double width,
                                     double height,
                                     int numRows,
                                     int numCols)
        Can be used by sub-classes to redefine the grid
        Parameters:
        x - the ULHC x
        y - the ULHC y
        width - the width of the grid
        height - the height of the grid
        numRows - the number of rows in the grid
        numCols - the number of columns in the grid
      • getRandomCoordinate

        public CoordinateIfc getRandomCoordinate()
        Returns:
        a uniformly picked coordinate in the grid
      • getRandomCoordinateInCell

        public CoordinateIfc getRandomCoordinateInCell​(RectangularCell2D cell)
        Parameters:
        cell - the cell to be within
        Returns:
        a random point in the cell
      • getRandomCell

        public RectangularCell2D getRandomCell​(java.util.List<RectangularCell2D> cells)
        Uniformly picks a cell from the list of cells. The supplied list of cells must not contain null members
        Parameters:
        cells - the cells to pick from
        Returns:
        the picked cell
      • getRandomCell

        public RectangularCell2D getRandomCell()
        Uniformly picks a cell from the grid
        Returns:
        the picked cell
      • cellTransition

        protected void cellTransition​(SpatialElementIfc element,
                                      RectangularCell2D cCell,
                                      RectangularCell2D pCell)
        Sub-classes can use this when an element transition from cells
        Parameters:
        element - the element involved in the transition
        cCell - the elements current cell
        pCell - the elements previous cell
      • positionUpdate

        protected void positionUpdate​(SpatialElementIfc element)
        Sub-classes can use this when an element moves its position
        Parameters:
        element -