Package jsl.modeling.elements.entity
Class EntityGenerator
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.EventGenerator
-
- jsl.modeling.elements.entity.EntityGenerator
-
- All Implemented Interfaces:
GetEntityReceiverIfc
,EventGeneratorIfc
,ObservableIfc
,GetNameIfc
,IdentityIfc
- Direct Known Subclasses:
EntityProcessGenerator
public class EntityGenerator extends EventGenerator implements GetEntityReceiverIfc
An EntityGenerator creates entities according to a entity type and sends them to a receiver according to the specified sending option. A general pattern of creation can be specified, see EventGenerator 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 The default sending option is DIRECT. If the user does not supply a receiver via setDirectEntityReceiver() then an error will occur. If the SEQ option is used, the user is responsible for providing a sequence for the EntityType generated. If BY_TYPE then the user is responsible for overriding the getNextReceiver() method for the EntityType. To specify the type of entity generated, there are four options 1) override the getEntityType() method to determine the type 2) supply an object that implements GetEntityTypeIfc 3) supply an EntityType via setEntityType() 4) indicate that the generator should use the default entity type via useDefaultEntityType() option If one of these options is not used, then an error will occur
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.modeling.elements.EventGenerator
EventGenerator.ActionStepIfc, EventGenerator.BuildStepIfc, EventGenerator.EventGeneratorBuilder, EventGenerator.TimeBetweenEventsStepIfc
-
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 EntityReceiverAbstract
myDirectEntityReceiver
protected EntityType
myEntityType
protected GetEntityTypeIfc
myEntityTypeGetter
protected jsl.modeling.elements.entity.EntityGenerator.Receiver
myFakeReceiver
protected EntityType.SendOption
mySendOption
-
Fields inherited from class jsl.modeling.elements.EventGenerator
EVENT_PRIORITY
-
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 EntityGenerator(ModelElement parent)
Creates an EntityGeneratorEntityGenerator(ModelElement parent, java.lang.String name)
Creates an EntityGeneratorEntityGenerator(ModelElement parent, RandomIfc timeUntilFirst)
Creates an EntityGeneratorEntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, java.lang.String name)
Creates an EntityGeneratorEntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext)
Creates an EntityGenerator.EntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum, double timeUntilLast, java.lang.String name)
Creates an EntityGenerator that generates entitiesEntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum, java.lang.String name)
Creates an EntityGeneratorEntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, java.lang.String name)
Creates an EntityGenerator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
generate(JSLEvent event)
This method should be overridden by sub-classes that do not supply an EventGeneratorActionIfc to model the action that occur when the event happens.EntityReceiverAbstract
getDirectEntityReceiver()
An object that will directly receive the entityEntityReceiverAbstract
getEntityReceiver()
Allows the EntityGenerator to act like a location that can receive entities.protected EntityType
getEntityType()
Subclasses should override this to specify the type of entity that will be generated.GetEntityTypeIfc
getEntityTypeGetter()
The object that determines the type of the entity generatedvoid
setDirectEntityReceiver(EntityReceiverAbstract receiver)
Can be used to supply a direct receiver.void
setDirectEntityReceiver(GetEntityReceiverIfc g)
See setDirectEntityReceiver()void
setEntityType(EntityType entityType)
Can be used to supply a pre-determined type to generate Can be null, if so, getEntityType() can be overridden or a EntityTypeGetter suppliedvoid
setEntityTypeGetter(GetEntityTypeIfc typeGetter)
Can supply an object that will be used to determine the type of the entity that is generated.void
setSendingOption(EntityType.SendOption option)
Sets the sending option SendOption {DIRECT, SEQ, BY_TYPE} DIRECT, client must use setDirectEntityReceiver() to set receiver SEQ, entity uses predefined sequence in its EntityType BY_TYPE, entity uses its EntityType to determine next receivervoid
useDefaultEntityType()
Indicates that the generator should use the default entity type-
Methods inherited from class jsl.modeling.elements.EventGenerator
builder, getEndingTime, getEventGeneratorListener, getEventPriority, getInitialEndingTime, getInitialMaximumNumberOfEvents, getInitialTimeBetweenEvents, getInitialTimeUntilFirstEvent, getMaximumNumberOfEvents, getNumberOfEventsGenerated, getStartOnInitializeFlag, getTimeBetweenEvents, incrementNumberOfEvents, initialize, isEventPending, isGeneratorDone, isGeneratorStarted, isSuspended, removedFromModel, resume, scheduleFirstEvent, scheduleFirstEvent, setEndingTime, setEventGeneratorListener, setEventPriority, setInitialEndingTime, setInitialMaximumNumberOfEvents, setInitialTimeBetweenEvents, setInitialTimeBetweenEventsAndMaxNumEvents, setInitialTimeUntilFirstEvent, setMaximumNumberOfEvents, setStartOnInitializeFlag, setTimeBetweenEvents, setTimeBetweenEvents, suspend, turnOffGenerator, turnOnGenerator, turnOnGenerator, turnOnGenerator
-
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_, isTimedUpdateEventScheduled, isWarmedUp, isWarmUpEventScheduled, isWarmUpScheduled, millisecond, minute, montecarlo, montecarlo_, notifyAfterExperimentObservers, notifyAfterReplicationObservers, notifyBeforeExperimentObservers, notifyBeforeReplicationObservers, notifyConditionalActionRegistrationObservers, notifyInitializationObservers, notifyMonteCarloObservers, notifyObservers, notifyObservers, notifyRemovingFromModelObservers, notifyReplicationEndedObservers, notifyTimedUpdateObservers, notifyUpdateObservers, notifyWarmUpObservers, registerConditionalActions, registerConditionalActions_, 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
-
myEntityTypeGetter
protected GetEntityTypeIfc myEntityTypeGetter
-
myDirectEntityReceiver
protected EntityReceiverAbstract myDirectEntityReceiver
-
mySendOption
protected EntityType.SendOption mySendOption
-
myEntityType
protected EntityType myEntityType
-
myFakeReceiver
protected jsl.modeling.elements.entity.EntityGenerator.Receiver myFakeReceiver
-
-
Constructor Detail
-
EntityGenerator
public EntityGenerator(ModelElement parent)
Creates an EntityGenerator- Parameters:
parent
-
-
EntityGenerator
public EntityGenerator(ModelElement parent, java.lang.String name)
Creates an EntityGenerator- Parameters:
parent
-name
-
-
EntityGenerator
public EntityGenerator(ModelElement parent, RandomIfc timeUntilFirst)
Creates an EntityGenerator- Parameters:
parent
-timeUntilFirst
- A RandomIfc object that supplies the time until the first event
-
EntityGenerator
public EntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, java.lang.String name)
Creates an EntityGenerator- Parameters:
parent
-timeUntilFirst
- A RandomIfc object that supplies the time until the first eventname
-
-
EntityGenerator
public EntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext)
Creates an EntityGenerator.- Parameters:
parent
-timeUntilFirst
- A RandomIfc object that supplies the time until the first eventtimeUntilNext
- A RandomIfc object that supplies the time between events
-
EntityGenerator
public EntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, java.lang.String name)
Creates an EntityGenerator.- Parameters:
parent
-timeUntilFirst
- A RandomIfc object that supplies the time until the first eventtimeUntilNext
- A RandomIfc object that supplies the time between eventsname
-
-
EntityGenerator
public EntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum, java.lang.String name)
Creates an EntityGenerator- Parameters:
parent
-timeUntilFirst
- A RandomIfc object that supplies the time until the first event.timeUntilNext
- A RandomIfc object that supplies the time between events.maxNum
- A RandomIfc object that supplies the maximum number of events to generate. This is typically a constant. When the generator is created, this variable is used to set the number of events to generate. The number is rounded to the closest long. Each time an event is to be scheduled the maximum number of events is checked. If the maximum has been reached, then the generator is turned off. If this variable is random, then it is only used once to set the number of events for the generator.name
-
-
EntityGenerator
public EntityGenerator(ModelElement parent, RandomIfc timeUntilFirst, RandomIfc timeUntilNext, long maxNum, double timeUntilLast, java.lang.String name)
Creates an EntityGenerator that generates entities- Parameters:
parent
-timeUntilFirst
- A RandomIfc object that supplies the time until the first event.timeUntilNext
- A RandomIfc object that supplies the time between events.maxNum
- A RandomIfc object that supplies the maximum number of events to generate. This is typically a constant. When the generator is created, this variable is used to set the number of events to generate. The number is rounded to the closest long. Each time an event is to be scheduled the maximum number of events is checked. If the maximum has been reached, then the generator is turned off. If this variable is random, then it is only used once to set the number of events for the generator.timeUntilLast
- A RandomIfc object that supplies a time to stop generating events. This is typically a constant. When the generator is created, this variable is used to set the ending time of the generator. Each time an event is to be scheduled the ending time is checked. If the time of the next event is past this time, then the generator is turned off and the event won't be scheduled. If this variable is random, then it is only used once to set the ending time of the generator.name
- The name of the generator.
-
-
Method Detail
-
getEntityType
protected EntityType getEntityType()
Subclasses should override this to specify the type of entity that will be generated. By default, the default entity type is returned.- Returns:
- Returns the type.
-
generate
protected void generate(JSLEvent event)
Description copied from class:EventGenerator
This method should be overridden by sub-classes that do not supply an EventGeneratorActionIfc to model the action that occur when the event happens.- Overrides:
generate
in classEventGenerator
- Parameters:
event
- the event associated with the generations
-
setSendingOption
public final void setSendingOption(EntityType.SendOption option)
Sets the sending option SendOption {DIRECT, SEQ, BY_TYPE} DIRECT, client must use setDirectEntityReceiver() to set receiver SEQ, entity uses predefined sequence in its EntityType BY_TYPE, entity uses its EntityType to determine next receiver- Parameters:
option
- the sending option
-
getEntityTypeGetter
public final GetEntityTypeIfc getEntityTypeGetter()
The object that determines the type of the entity generated- Returns:
- The object that determines the type
-
setEntityTypeGetter
public final void setEntityTypeGetter(GetEntityTypeIfc typeGetter)
Can supply an object that will be used to determine the type of the entity that is generated. If no type is supplied getDefaultEntityType() is used- Parameters:
typeGetter
- The object that determines the type
-
getDirectEntityReceiver
public final EntityReceiverAbstract getDirectEntityReceiver()
An object that will directly receive the entity- Returns:
- the receiver
-
setDirectEntityReceiver
public final void setDirectEntityReceiver(EntityReceiverAbstract receiver)
Can be used to supply a direct receiver. If used the sending option is automatically changed to direct- Parameters:
receiver
- the receiver
-
setDirectEntityReceiver
public final void setDirectEntityReceiver(GetEntityReceiverIfc g)
See setDirectEntityReceiver()- Parameters:
g
- the thing that determines the receiver
-
setEntityType
public void setEntityType(EntityType entityType)
Can be used to supply a pre-determined type to generate Can be null, if so, getEntityType() can be overridden or a EntityTypeGetter supplied- Parameters:
entityType
- the type of the entity
-
useDefaultEntityType
public void useDefaultEntityType()
Indicates that the generator should use the default entity type
-
getEntityReceiver
public final EntityReceiverAbstract getEntityReceiver()
Allows the EntityGenerator to act like a location that can receive entities. It does not actually receive entities, but this method can be used to return a receiver so that the generator can be an origin point- Specified by:
getEntityReceiver
in interfaceGetEntityReceiverIfc
- Returns:
- the receiver
-
-