Package jsl.modeling.elements.entity
Class EntityType
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.entity.EntityType
-
- All Implemented Interfaces:
ObservableIfc
,GetNameIfc
,IdentityIfc
public class EntityType extends SchedulingElement
EntityType represents a generic classification of entities. Every entity must have an entity type. The entity type holds information that is "global" to all entities of the type. To create entities, the client must use an instance of EntityType
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
EntityType.CDestination
protected class
EntityType.Destination
static class
EntityType.SendOption
SendOption {DIRECT, SEQ, BY_TYPE} DIRECT, client must use setDirectEntityReceiver() to set the receiver SEQ, entity uses predefined sequence in its EntityType BY_TYPE, entity uses its EntityType to determine next receiver NONE, there is no option specified, will cause exception when sending entities unless behavior is overridden-
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 java.util.Map<Delay,RandomVariable>
myActivityTimes
Holds the time it takes for each activity experienced by the entityprotected java.util.List<EntityReceivedListener>
myEntityReceivedListeners
Used to hold listeners called prior to an entity being receivedprotected java.util.List<EntitySentListener>
myEntitySentListeners
Used to hold listeners called after an entity is sentprotected TimeWeighted
myNumInSystem
For tracking number of entities by EntityTypeprotected java.util.Map<EntityReceiverAbstract,DestinationIfc>
myODNetwork
Holds the origin and destination pair for to send entity from origin to destinationprotected java.util.List<EntityReceiverAbstract>
myReceiverSequence
Holds the entity's list of receivers to visitprotected ResponseVariable
myTimeInSystem
For tracking system time for entities by EntityType-
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 EntityType(ModelElement parent)
Creates an EntityType with a default nameEntityType(ModelElement parent, java.lang.String name)
Creates an EntityType with the given name
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActivityTime(Delay a, double time)
Associates a time with an Activity for the EntityTypevoid
addActivityTime(Delay a, RVariableIfc r)
Associates a activity (Activity) with the supplied random timevoid
addDestination(EntityReceiverAbstract origin, DestinationIfc d)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract)void
addDestination(EntityReceiverAbstract origin, EntityReceiverAbstract destination)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract).void
addDestination(EntityReceiverAbstract origin, EntityReceiverAbstract destination, double time)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract).void
addDestination(EntityReceiverAbstract origin, EntityReceiverAbstract destination, GetValueIfc value)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract).void
addDestination(EntityReceiverAbstract origin, EntityReceiverAbstract destination, RVariableIfc random)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract).void
addDestination(GetEntityReceiverIfc origin, EntityReceiverAbstract destination)
Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc).void
addDestination(GetEntityReceiverIfc origin, EntityReceiverAbstract destination, double time)
Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc).void
addDestination(GetEntityReceiverIfc origin, GetEntityReceiverIfc destination)
Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc).void
addDestination(GetEntityReceiverIfc origin, GetEntityReceiverIfc destination, double time)
Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc).void
addToSequence(EntityReceiverAbstract receiver)
Adds a receiver to the receiver sequencevoid
addToSequence(GetEntityReceiverIfc g)
Convenience method See addEntityReceiver(EntityReceiverAbstract receiver)void
attachEntityReceivedListener(EntityReceivedListener listener)
Attaches a listener that will be called immediately before the entity is received, i.e.void
attachEntitySentListener(EntitySentListener listener)
Attaches a listener that will be called immediately before the entity is sent, i.e.boolean
containsActivity(Delay a)
True if the Activity has already been addedboolean
containsOrigin(EntityReceiverAbstract origin)
True if the origin has already been added to the O/D mappingEntity
createEntity()
Creates an entityEntity
createEntity(java.lang.String name)
Creates an entity with the given nameAttributeType
defineAttributeType(java.lang.String name)
Defines an attribute type with the given name and adds it to the available types for this entity typevoid
detachEntityReceivedListener(EntityReceivedListener listener)
Detaches a previously attached listenervoid
detachEntitySentListener(EntitySentListener listener)
Detaches a listenerprotected void
dispose(Entity e)
Disposes of the entity, collects statistics if turned onprotected double
getActivityTime(Delay a)
java.util.List<AttributeType>
getAttributeTypes()
Returns an unmodifiable list of the attribute typesprotected DestinationIfc
getDestination(Entity e)
By default the origin/destination mapping (if defined) is used to determine the next receiver; however, this method can be overridden in sub-classes to provide a general method of determining the destinationEntityReceiverAbstract
getEntityReceiver(int index)
Returns the EntityReceiver at the supplied index If a sequence of receivers is not defined or the supplied index is out of bounds then null is returned.protected java.util.List<SeizeRequirement>
getSeizeRequirements(SeizeResources aThis)
EntityReceiverIteratorIfc
getSequenceIterator()
Gets an EntityReceiverIteratorIfc to the sequence of receivers positioned at the beginning of the sequenceint
getSequenceSize()
Returns the size of the Entity's receiver sequence zero if no sequence or if emptyboolean
isOriginDestinationNetworkEmpty()
Whether or not the origin/destination mapping is emptyboolean
isSequenceEmpty()
Returns whether or not the entity receiver sequence is emptyprotected void
notifyEntityReceivedListeners(Entity entity)
protected void
notifyEntitySentListeners(Entity entity)
int
numberOfOrigins()
Number of origins in the origin/destination mappingprotected void
sendToDestination(Entity e)
Uses the DestinationIfc returned by getDestination(Entity e) to send the entity to its destination (receiver)protected void
sendToReceiver(Entity e, EntityReceiverAbstract receiver)
Causes the entity to be received by the receiver, with no time delayprotected void
sendToReceiver(Entity e, EntityReceiverAbstract receiver, double time)
Causes the entity to be received by the receiver, perhaps after the designated time delay.protected void
setSequence(java.util.List<EntityReceiverAbstract> receiverSequence)
void
turnOnNumberInSystemCollection()
Causes number in system statistics to be collected for the EntityTypevoid
turnOnTimeInSystemCollection()
Causes time in system statistics to be collected for the EntityType-
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, 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
-
myTimeInSystem
protected ResponseVariable myTimeInSystem
For tracking system time for entities by EntityType
-
myNumInSystem
protected TimeWeighted myNumInSystem
For tracking number of entities by EntityType
-
myReceiverSequence
protected java.util.List<EntityReceiverAbstract> myReceiverSequence
Holds the entity's list of receivers to visit
-
myODNetwork
protected java.util.Map<EntityReceiverAbstract,DestinationIfc> myODNetwork
Holds the origin and destination pair for to send entity from origin to destination
-
myEntityReceivedListeners
protected java.util.List<EntityReceivedListener> myEntityReceivedListeners
Used to hold listeners called prior to an entity being received
-
myEntitySentListeners
protected java.util.List<EntitySentListener> myEntitySentListeners
Used to hold listeners called after an entity is sent
-
myActivityTimes
protected java.util.Map<Delay,RandomVariable> myActivityTimes
Holds the time it takes for each activity experienced by the entity
-
-
Constructor Detail
-
EntityType
public EntityType(ModelElement parent)
Creates an EntityType with a default name- Parameters:
parent
-
-
EntityType
public EntityType(ModelElement parent, java.lang.String name)
Creates an EntityType with the given name- Parameters:
parent
-name
-
-
-
Method Detail
-
createEntity
public final Entity createEntity()
Creates an entity- Overrides:
createEntity
in classModelElement
- Returns:
-
createEntity
public Entity createEntity(java.lang.String name)
Creates an entity with the given name- Overrides:
createEntity
in classModelElement
- Parameters:
name
-- Returns:
-
turnOnTimeInSystemCollection
public void turnOnTimeInSystemCollection()
Causes time in system statistics to be collected for the EntityType
-
turnOnNumberInSystemCollection
public void turnOnNumberInSystemCollection()
Causes number in system statistics to be collected for the EntityType
-
defineAttributeType
public final AttributeType defineAttributeType(java.lang.String name)
Defines an attribute type with the given name and adds it to the available types for this entity type- Parameters:
name
- the name of the attribute type, must be non-null and unique to this entity type- Returns:
-
getAttributeTypes
public final java.util.List<AttributeType> getAttributeTypes()
Returns an unmodifiable list of the attribute types- Returns:
-
addToSequence
public final void addToSequence(GetEntityReceiverIfc g)
Convenience method See addEntityReceiver(EntityReceiverAbstract receiver)- Parameters:
g
-
-
addToSequence
public final void addToSequence(EntityReceiverAbstract receiver)
Adds a receiver to the receiver sequence- Parameters:
receiver
-
-
getSequenceIterator
public final EntityReceiverIteratorIfc getSequenceIterator()
Gets an EntityReceiverIteratorIfc to the sequence of receivers positioned at the beginning of the sequence- Returns:
- the iterator or null if no receiver list
-
isSequenceEmpty
public final boolean isSequenceEmpty()
Returns whether or not the entity receiver sequence is empty- Returns:
-
getSequenceSize
public final int getSequenceSize()
Returns the size of the Entity's receiver sequence zero if no sequence or if empty- Returns:
-
getEntityReceiver
public final EntityReceiverAbstract getEntityReceiver(int index)
Returns the EntityReceiver at the supplied index If a sequence of receivers is not defined or the supplied index is out of bounds then null is returned. Indexing is 0 based- Parameters:
index
-- Returns:
-
setSequence
protected final void setSequence(java.util.List<EntityReceiverAbstract> receiverSequence)
-
getDestination
protected DestinationIfc getDestination(Entity e)
By default the origin/destination mapping (if defined) is used to determine the next receiver; however, this method can be overridden in sub-classes to provide a general method of determining the destination- Parameters:
e
-- Returns:
-
sendToDestination
protected final void sendToDestination(Entity e)
Uses the DestinationIfc returned by getDestination(Entity e) to send the entity to its destination (receiver)- Parameters:
e
-
-
sendToReceiver
protected void sendToReceiver(Entity e, EntityReceiverAbstract receiver)
Causes the entity to be received by the receiver, with no time delay- Parameters:
e
-receiver
-
-
sendToReceiver
protected void sendToReceiver(Entity e, EntityReceiverAbstract receiver, double time)
Causes the entity to be received by the receiver, perhaps after the designated time delay.- Parameters:
e
-receiver
-time
-
-
dispose
protected void dispose(Entity e)
Disposes of the entity, collects statistics if turned on- Parameters:
e
-
-
attachEntityReceivedListener
public void attachEntityReceivedListener(EntityReceivedListener listener)
Attaches a listener that will be called immediately before the entity is received, i.e. prior to receive(Entity entity) being called- Parameters:
listener
-
-
detachEntityReceivedListener
public void detachEntityReceivedListener(EntityReceivedListener listener)
Detaches a previously attached listener- Parameters:
listener
-
-
notifyEntityReceivedListeners
protected void notifyEntityReceivedListeners(Entity entity)
-
notifyEntitySentListeners
protected void notifyEntitySentListeners(Entity entity)
-
attachEntitySentListener
public void attachEntitySentListener(EntitySentListener listener)
Attaches a listener that will be called immediately before the entity is sent, i.e. prior to sendEntity(Entity e) being called- Parameters:
listener
-
-
detachEntitySentListener
public void detachEntitySentListener(EntitySentListener listener)
Detaches a listener- Parameters:
listener
-
-
addDestination
public void addDestination(EntityReceiverAbstract origin, EntityReceiverAbstract destination, RVariableIfc random)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract). The supplied RandomIfc indicates the delay to arrive at the destination- Parameters:
origin
-destination
-random
-
-
addDestination
public void addDestination(EntityReceiverAbstract origin, EntityReceiverAbstract destination, GetValueIfc value)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract). The supplied GetValueIfc indicates the delay to arrive at the destination- Parameters:
origin
-destination
-value
-
-
addDestination
public void addDestination(EntityReceiverAbstract origin, EntityReceiverAbstract destination, double time)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract). The supplied time indicates the delay to arrive at the destination- Parameters:
origin
-destination
-time
-
-
addDestination
public void addDestination(EntityReceiverAbstract origin, EntityReceiverAbstract destination)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract). The supplied time indicates the delay to arrive at the destination- Parameters:
origin
-destination
-
-
addDestination
public void addDestination(GetEntityReceiverIfc origin, GetEntityReceiverIfc destination, double time)
Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc). The supplied time indicates the delay to arrive at the destination (GetEntityReceiverIfc)- Parameters:
origin
-destination
-time
-
-
addDestination
public void addDestination(GetEntityReceiverIfc origin, GetEntityReceiverIfc destination)
Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc). The supplied time indicates the delay to arrive at the destination (GetEntityReceiverIfc)- Parameters:
origin
-destination
-
-
addDestination
public void addDestination(GetEntityReceiverIfc origin, EntityReceiverAbstract destination, double time)
Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc). The supplied time indicates the delay to arrive at the destination- Parameters:
origin
-destination
-time
-
-
addDestination
public void addDestination(GetEntityReceiverIfc origin, EntityReceiverAbstract destination)
Associates a destination (DestinationIfc) with the supplied origin (GetEntityReceiverIfc). The supplied time indicates the delay to arrive at the destination- Parameters:
origin
-destination
-
-
addDestination
public final void addDestination(EntityReceiverAbstract origin, DestinationIfc d)
Associates a destination (DestinationIfc) with the supplied origin (EntityReceiverAbstract)- Parameters:
origin
-d
-
-
numberOfOrigins
public final int numberOfOrigins()
Number of origins in the origin/destination mapping- Returns:
-
isOriginDestinationNetworkEmpty
public final boolean isOriginDestinationNetworkEmpty()
Whether or not the origin/destination mapping is empty- Returns:
-
containsOrigin
public final boolean containsOrigin(EntityReceiverAbstract origin)
True if the origin has already been added to the O/D mapping- Parameters:
origin
-- Returns:
-
getActivityTime
protected double getActivityTime(Delay a)
-
containsActivity
public final boolean containsActivity(Delay a)
True if the Activity has already been added- Parameters:
a
-- Returns:
-
addActivityTime
public final void addActivityTime(Delay a, double time)
Associates a time with an Activity for the EntityType- Parameters:
a
-time
-
-
addActivityTime
public final void addActivityTime(Delay a, RVariableIfc r)
Associates a activity (Activity) with the supplied random time- Parameters:
a
- The activityr
- The time
-
getSeizeRequirements
protected java.util.List<SeizeRequirement> getSeizeRequirements(SeizeResources aThis)
- Parameters:
aThis
-- Returns:
-
-