Package jsl.modeling.elements.spatial
Class RectangularGridModel
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.spatial.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.simulation.ModelElement
ModelElement.EventBuilderIfc<T>, ModelElement.EventScheduler<T>, ModelElement.ModelElementComparator, ModelElement.RequestBuilder, ModelElement.RequestDurationIfc, ModelElement.RequestTimeIfc, ModelElement.RequestUsingIfc, ModelElement.TimedUpdateEventAction, ModelElement.TimeUnitIfc<T>, ModelElement.WarmUpEventAction
-
-
Field Summary
Fields Modifier and Type Field Description protected RectangularGridSpatialModel2D
myGrid
protected RandomVariable
myUniformRV
-
Fields inherited from class jsl.simulation.ModelElement
AFTER_EXPERIMENT, AFTER_REPLICATION, BEFORE_EXPERIMENT, BEFORE_REPLICATION, CONDITIONAL_ACTION_REGISTRATION, DEFAULT_TIMED_EVENT_PRIORITY, INITIALIZED, MONTE_CARLO, myAfterExperimentOption, myAfterReplicationOption, myBeforeExperimentOption, myBeforeReplicationOption, myInitializationOption, myLengthOfWarmUp, myModelElements, myMonteCarloOption, myObservableComponent, myReplicationEndedOption, myTimedUpdateActionListener, myTimedUpdateEvent, myTimedUpdateInterval, myTimedUpdateOption, myTimedUpdatePriority, myWarmUpActionListener, myWarmUpEvent, myWarmUpIndicator, myWarmUpOption, myWarmUpPriority, NONE, REMOVED_FROM_MODEL, REPLICATION_ENDED, TIME_UNIT_DAY, TIME_UNIT_HOUR, TIME_UNIT_MILLISECOND, TIME_UNIT_MINUTE, TIME_UNIT_SECOND, TIME_UNIT_WEEK, TIMED_UPDATE, UPDATE, WARMUP
-
-
Constructor Summary
Constructors Constructor Description 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 gridRectangularGridModel(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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cellTransition(SpatialElementIfc element, RectangularCell2D cCell, RectangularCell2D pCell)
Sub-classes can use this when an element transition from cellsRectangularGridSpatialModel2D
getGrid()
RectangularCell2D
getRandomCell()
Uniformly picks a cell from the gridRectangularCell2D
getRandomCell(java.util.List<RectangularCell2D> cells)
Uniformly picks a cell from the list of cells.CoordinateIfc
getRandomCoordinate()
CoordinateIfc
getRandomCoordinateInCell(RectangularCell2D cell)
protected void
positionUpdate(SpatialElementIfc element)
Sub-classes can use this when an element moves its positionint
randInt(int i, int j)
Randomly generates an integer between i and jprotected void
setGrid(double x, double y, double width, double height, int numRows, int numCols)
Can be used by sub-classes to redefine the grid-
Methods inherited from class jsl.simulation.SchedulingElement
cancelEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, rescheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent, scheduleEvent
-
Methods inherited from class jsl.simulation.ModelElement
addObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication, afterReplication_, asString, beforeExperiment, beforeExperiment_, beforeReplication, beforeReplication_, buildEventGenerator, cancelTimedUpdateEvent, cancelWarmUpEvent, changeParentModelElement, checkForAfterExperiment, checkForAfterReplication, checkForBeforeExperiment, checkForBeforeReplication, checkForConditionalActionRegistration, checkForInitialize, checkForMonteCarlo, checkForRemoveFromModel, checkForReplicationEnded, checkForTimedUpdate, checkForUpdate, checkForWarmUp, checkObserverState, checkWarmUpOption, clearModelElementObservers, contains, countObservers, createEntity, createEntity, createQObject, day, deleteObserver, deleteObserverFromModelElements, deleteObservers, findModelElementWithWarmUpEvent, getAfterExperimentOption, getAfterReplicationOption, getAllCounters, getAllModelElements, getAllRandomElements, getAllResponseVariables, getAllVariables, getBeforeExperimentOption, getBeforeReplicationOption, getChildModelElementIterator, getCurrentReplicationNumber, getDefaultEntityType, getExecutive, getExperiment, getId, getInitializationOption, getInitializationOrderAsString, getLeftPreOrderTraversalCount, getLengthOfWarmUp, getModel, getModelElementCompartor, getModelElementsAsString, getModelElementsAsString, getModelElementsAsString, getMonteCarloOption, getName, getNumberOfModelElements, getObserverState, getParentModelElement, getPreviousObserverState, getReplicationEndedOption, getRightPreOrderTraversalCount, getSimulation, getSpatialModel, getStringLabel, getThisElementsCounters, getThisElementsModelElements, getThisElementsRandomVariables, getThisElementsResponseVariables, getThisElementsVariables, getTime, getTimedUpdateInterval, getTimedUpdateOption, getUpdateNotificationFlag, getVariable, getWarmUpEventTime, getWarmUpOption, hour, indent, initialize, initialize_, isTimedUpdateEventScheduled, isWarmedUp, isWarmUpEventScheduled, isWarmUpScheduled, millisecond, minute, montecarlo, montecarlo_, notifyAfterExperimentObservers, notifyAfterReplicationObservers, notifyBeforeExperimentObservers, notifyBeforeReplicationObservers, notifyConditionalActionRegistrationObservers, notifyInitializationObservers, notifyMonteCarloObservers, notifyObservers, notifyObservers, notifyRemovingFromModelObservers, notifyReplicationEndedObservers, notifyTimedUpdateObservers, notifyUpdateObservers, notifyWarmUpObservers, registerConditionalActions, registerConditionalActions_, removedFromModel, removeFromModel, replicationEnded, replicationEnded_, schedule, second, seize, setAfterExperimentOption, setAfterExperimentOptionForModelElements, setAfterReplicationOption, setAfterReplicationOptionForModelElements, setBeforeExperimentOption, setBeforeExperimentOptionForModelElements, setBeforeReplicationOption, setBeforeReplicationOptionForModelElements, setInitializationOption, setInitializationOptionForModelElements, setLengthOfWarmUp, setModel, setMonteCarloOption, setMonteCarloOptionForModelElements, setName, setObserverState, setParentModelElement, setReplicationEndedOption, setReplicationEndedOptionForModelElements, setSpatialModel, setStringLabel, setTimedUpdateInterval, setTimedUpdateOption, setTimedUpdateOptionForModelElements, setUpdateNotificationFlag, setWarmUpOption, setWarmUpOptionForModelElements, stopExecutive, stopExecutive, timedUpdate, timedUpdate_, toString, update, useControls, warmUp, warmUp_, week
-
-
-
-
Field Detail
-
myGrid
protected RectangularGridSpatialModel2D myGrid
-
myUniformRV
protected RandomVariable myUniformRV
-
-
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 elementwidth
- the width of the gridheight
- the height of the gridnumRows
- the number of rows in the gridnumCols
- 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 elementx
- the ULHC xy
- the ULHC ywidth
- the width of the gridheight
- the height of the gridnumRows
- the number of rows in the gridnumCols
- the number of columns in the gridname
- 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 limitj
- the upper limit- Returns:
- the random integer
-
getGrid
public final RectangularGridSpatialModel2D getGrid()
- Returns:
- the RectangularGridSpatialModel2D
-
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 xy
- the ULHC ywidth
- the width of the gridheight
- the height of the gridnumRows
- the number of rows in the gridnumCols
- 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 transitioncCell
- the elements current cellpCell
- the elements previous cell
-
positionUpdate
protected void positionUpdate(SpatialElementIfc element)
Sub-classes can use this when an element moves its position- Parameters:
element
-
-
-