Package jsl.modeling.elements.station
Class SingleQueueStation
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.station.Station
-
- jsl.modeling.elements.station.SingleQueueStation
-
- All Implemented Interfaces:
ReceiveQObjectIfc,ObservableIfc,GetNameIfc,IdentityIfc
public class SingleQueueStation extends Station
Models a service station with a resource that has a single queue to hold waiting customers. Customers can only use 1 unit of the resource while in service.
-
-
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 TimeWeightedmyNSprotected SResourcemyResourceprotected Queue<QObject>myWaitingQ-
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 SingleQueueStation(ModelElement parent)Uses a resource with capacity 1 and service time Constant.ZEROSingleQueueStation(ModelElement parent, java.lang.String name)Uses a resource with capacity 1 and service time Constant.ZEROSingleQueueStation(ModelElement parent, SResource resource)No sender is provided.SingleQueueStation(ModelElement parent, SResource resource, GetValueIfc sd)No sender is provided.SingleQueueStation(ModelElement parent, SResource resource, GetValueIfc sd, java.lang.String name)No sender is provided.SingleQueueStation(ModelElement parent, SResource resource, GetValueIfc sd, SendQObjectIfc sender, java.lang.String name)SingleQueueStation(ModelElement parent, GetValueIfc sd)Uses a resource with capacity 1SingleQueueStation(ModelElement parent, GetValueIfc sd, java.lang.String name)Uses a resource with capacity 1SingleQueueStation(ModelElement parent, GetValueIfc sd, SendQObjectIfc sender, java.lang.String name)Default resource of capacity 1 is used
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddQueueListener(QueueListenerIfc<QObject> listener)Adds a QueueListenerIfc to the underlying queuevoidchangeDiscipline(Queue.Discipline discipline)intgetCapacity()The capacity of the resource.doublegetFractionBusy()Fraction of the capacity that is busy.Queue.DisciplinegetInitialDiscipline()intgetInitialResourceCapacity()The initial capacity of the resource at the stationStatisticAccessorIfcgetNBAcrossReplicationStatistic()Across replication statistics on the number busy serversStatisticAccessorIfcgetNSAcrossReplicationStatistic()Across replication statistics on the number in systemWeightedStatisticIfcgetNSWithinReplicationStatistic()Within replication statistics on the number in systemintgetNumberInQueue()The current number in the queueintgetNumberInStation()The current number in the station (in queue + in service)intgetNumBusyServers()Current number of busy serversjava.util.Optional<QueueResponse<QObject>>getQueueResponses()GetValueIfcgetServiceTime()The object used to determine the service time when not using the QObject optionprotected doublegetServiceTime(QObject customer)booleangetUseQObjectServiceTimeOption()Whether or not the station uses the QObject to determine the service timeprotected voidinitialize()This method should be overridden by subclasses that need actions performed to initialize prior to a replication.booleanisQueueEmpty()Whether the queue is emptybooleanisQueueNotEmpty()Whether the queue is not emptybooleanisResourceAvailable()voidreceive(QObject customer)booleanremoveQueueListener(QueueListenerIfc<QObject> listener)Removes a QueueListenerIfc from the underlying queueprotected voidserveNext()Called to determine which waiting QObject will be served next Determines the next customer, seizes the resource, and schedules the end of the service.voidsetInitialCapacity(int capacity)Sets the initial capacity of the station's resourcevoidsetInitialDiscipline(Queue.Discipline discipline)voidsetServiceTime(GetValueIfc st)If the service time is null, it is assumed to be zerovoidsetUseQObjectServiceTimeOption(boolean option)Tells the station to use the QObject to determine the service time-
Methods inherited from class jsl.modeling.elements.station.Station
getNextReceiver, getSender, send, setNextReceiver, setSender
-
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_, 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
-
myNS
protected final TimeWeighted myNS
-
myResource
protected final SResource myResource
-
-
Constructor Detail
-
SingleQueueStation
public SingleQueueStation(ModelElement parent)
Uses a resource with capacity 1 and service time Constant.ZERO- Parameters:
parent-
-
SingleQueueStation
public SingleQueueStation(ModelElement parent, GetValueIfc sd)
Uses a resource with capacity 1- Parameters:
parent-sd-
-
SingleQueueStation
public SingleQueueStation(ModelElement parent, java.lang.String name)
Uses a resource with capacity 1 and service time Constant.ZERO- Parameters:
parent-name-
-
SingleQueueStation
public SingleQueueStation(ModelElement parent, GetValueIfc sd, java.lang.String name)
Uses a resource with capacity 1- Parameters:
parent-sd-name-
-
SingleQueueStation
public SingleQueueStation(ModelElement parent, SResource resource)
No sender is provided.- Parameters:
parent-resource-
-
SingleQueueStation
public SingleQueueStation(ModelElement parent, SResource resource, GetValueIfc sd)
No sender is provided.- Parameters:
parent-resource-sd-
-
SingleQueueStation
public SingleQueueStation(ModelElement parent, SResource resource, GetValueIfc sd, java.lang.String name)
No sender is provided.- Parameters:
parent-resource-sd-name-
-
SingleQueueStation
public SingleQueueStation(ModelElement parent, GetValueIfc sd, SendQObjectIfc sender, java.lang.String name)
Default resource of capacity 1 is used- Parameters:
parent-sd-sender-name-
-
SingleQueueStation
public SingleQueueStation(ModelElement parent, SResource resource, GetValueIfc sd, SendQObjectIfc sender, java.lang.String name)
- Parameters:
parent-resource-sd- Represents the time using the resourcesender- handles sending to nextname-
-
-
Method Detail
-
initialize
protected void initialize()
Description copied from class:ModelElementThis method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called- Overrides:
initializein classModelElement
-
getServiceTime
protected double getServiceTime(QObject customer)
-
serveNext
protected void serveNext()
Called to determine which waiting QObject will be served next Determines the next customer, seizes the resource, and schedules the end of the service.
-
receive
public void receive(QObject customer)
-
getQueueResponses
public java.util.Optional<QueueResponse<QObject>> getQueueResponses()
-
setUseQObjectServiceTimeOption
public final void setUseQObjectServiceTimeOption(boolean option)
Tells the station to use the QObject to determine the service time- Parameters:
option- true means the station uses the QObject's getValueObject() to determine the service time
-
getUseQObjectServiceTimeOption
public final boolean getUseQObjectServiceTimeOption()
Whether or not the station uses the QObject to determine the service time- Returns:
- true means the station uses the QObject's getValueObject() to determine the service time
-
getNumberInQueue
public final int getNumberInQueue()
The current number in the queue- Returns:
- The current number in the queue
-
getNumberInStation
public final int getNumberInStation()
The current number in the station (in queue + in service)- Returns:
- current number in the station (in queue + in service)
-
getInitialResourceCapacity
public final int getInitialResourceCapacity()
The initial capacity of the resource at the station- Returns:
- initial capacity of the resource at the station
-
setInitialCapacity
public final void setInitialCapacity(int capacity)
Sets the initial capacity of the station's resource- Parameters:
capacity- the initial capacity of the station's resource
-
setServiceTime
public final void setServiceTime(GetValueIfc st)
If the service time is null, it is assumed to be zero- Parameters:
st- the GetValueIfc implementor that provides the service time
-
getServiceTime
public final GetValueIfc getServiceTime()
The object used to determine the service time when not using the QObject option- Returns:
- the object used to determine the service time when not using the QObject
-
getNBAcrossReplicationStatistic
public final StatisticAccessorIfc getNBAcrossReplicationStatistic()
Across replication statistics on the number busy servers- Returns:
- Across replication statistics on the number busy servers
-
getNSAcrossReplicationStatistic
public final StatisticAccessorIfc getNSAcrossReplicationStatistic()
Across replication statistics on the number in system- Returns:
- Across replication statistics on the number in system
-
getNSWithinReplicationStatistic
public final WeightedStatisticIfc getNSWithinReplicationStatistic()
Within replication statistics on the number in system- Returns:
- Within replication statistics on the number in system
-
isResourceAvailable
public final boolean isResourceAvailable()
- Returns:
- true if a resource has available units
-
getCapacity
public final int getCapacity()
The capacity of the resource. Maximum number of units that can be busy.- Returns:
- The capacity of the resource. Maximum number of units that can be busy.
-
getNumBusyServers
public final int getNumBusyServers()
Current number of busy servers- Returns:
- Current number of busy servers
-
getFractionBusy
public final double getFractionBusy()
Fraction of the capacity that is busy.- Returns:
- Fraction of the capacity that is busy.
-
isQueueEmpty
public final boolean isQueueEmpty()
Whether the queue is empty- Returns:
- Whether the queue is empty
-
isQueueNotEmpty
public final boolean isQueueNotEmpty()
Whether the queue is not empty- Returns:
- Whether the queue is not empty
-
addQueueListener
public final boolean addQueueListener(QueueListenerIfc<QObject> listener)
Adds a QueueListenerIfc to the underlying queue- Parameters:
listener- the listener to queue state changes- Returns:
- true if added
-
removeQueueListener
public boolean removeQueueListener(QueueListenerIfc<QObject> listener)
Removes a QueueListenerIfc from the underlying queue- Parameters:
listener- the listener to queue state changes- Returns:
- true if removed
-
changeDiscipline
public final void changeDiscipline(Queue.Discipline discipline)
- Parameters:
discipline- the new discipline
-
getInitialDiscipline
public final Queue.Discipline getInitialDiscipline()
- Returns:
- the initial queue discipline
-
setInitialDiscipline
public final void setInitialDiscipline(Queue.Discipline discipline)
- Parameters:
discipline- the initial queue discipline
-
-