Package jsl.modeling.elements.variable
Class ResponseInterval
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.simulation.SchedulingElement
-
- jsl.modeling.elements.variable.ResponseInterval
-
- All Implemented Interfaces:
ObservableIfc
,GetNameIfc
,IdentityIfc
public class ResponseInterval extends SchedulingElement
This class represents an interval of time over which statistical collection should be performed. An interval is specified by providing an interval start time and a duration. The duration must be finite and greater than zero. Simulation responses in the form of instances of ResponseVariable, TimeWeighted, and Counter can be added to the interval for observation. New responses are created and associated with each of the supplied responses. The new responses collect observations associated with the supplied responses only during the specified interval. In the case of response variables or time weighted variables, the average response during the interval is observed. In the case of counters, the total count during the interval is observed. If the interval is not associated with a ResponseSchedule, the interval may be repeated. In which case, the statistics are collected across the intervals. A repeated interval starts immediately after the previous duration. Note that for ResponseVariables that are observed, if there are no observations during the interval then the average response during the interval is undefined (and thus not observed). Therefore interval statistics for ResponseVariables are conditional on the occurrence of at least one observation. This is most relevant when the interval is repeated because intervals with no observations are not tabulated.
-
-
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 int
END_EVENT_PRIORITY
Need to ensure that end event happens before schedule endprotected boolean
myRepeatFlag
The repeat flag controls whether or not the interval will repeat after its duration has elapsed.protected ResponseSchedule
myResponseSchedule
protected double
myStartTime
The time that the interval should startint
START_EVENT_PRIORITY
Need to ensure that start event happens after schedule start and after warm up event-
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 ResponseInterval(ModelElement parent, double duration, java.lang.String label)
Creates an interval response
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponseVariable
addCounterToInterval(Counter theCounter)
Adds a Counter to the interval for data collection over the intervalResponseVariable
addResponseToInterval(ResponseVariable theResponse)
Adds a ResponseVariable to the interval for data collection over the interval.ResponseVariable
addResponseToInterval(ResponseVariable theResponse, boolean intervalEmptyStatOption)
Adds a ResponseVariable to the interval for data collection over the intervalprotected void
afterReplication()
This method should be overridden by subclasses that need actions performed after each replication.java.lang.String
asString()
Allows sub-classes to provide more detail than toString() to represent the ModelElement as a Stringvoid
cancelInterval()
Cancels the scheduling of the interval.double
getDuration()
The duration (length) of the intervalboolean
getRepeatFlag()
Returns whether or not the interval will repeat after it completes its durationdouble
getStartTime()
double
getTimeLastEnded()
When the interval was last endeddouble
getTimeLastStarted()
When the interval was last startedprotected void
initialize()
This method should be overridden by subclasses that need actions performed to initialize prior to a replication.boolean
isScheduled()
protected void
scheduleInterval(double startTime)
Schedules the interval to occur at current time + start timeprotected void
setDuration(double duration)
void
setRepeatFlag(boolean flag)
Sets whether or not the interval will repeat after it reaches it lengthprotected void
setResponseSchedule(ResponseSchedule schedule)
void
setStartTime(double startTime)
Specifies when the interval is to start.java.lang.String
toString()
Includes the model name, the id, the model element name, the parent name, and parent id-
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_, 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_, update, useControls, warmUp, warmUp_, week
-
-
-
-
Field Detail
-
START_EVENT_PRIORITY
public final int START_EVENT_PRIORITY
Need to ensure that start event happens after schedule start and after warm up event- See Also:
- Constant Field Values
-
END_EVENT_PRIORITY
public final int END_EVENT_PRIORITY
Need to ensure that end event happens before schedule end- See Also:
- Constant Field Values
-
myStartTime
protected double myStartTime
The time that the interval should start
-
myRepeatFlag
protected boolean myRepeatFlag
The repeat flag controls whether or not the interval will repeat after its duration has elapsed. The default is false.
-
myResponseSchedule
protected ResponseSchedule myResponseSchedule
-
-
Constructor Detail
-
ResponseInterval
public ResponseInterval(ModelElement parent, double duration, java.lang.String label)
Creates an interval response- Parameters:
parent
- the parent model elementduration
- must be finite and strictly positivelabel
- the label used to denote the interval, must not be null
-
-
Method Detail
-
setRepeatFlag
public final void setRepeatFlag(boolean flag)
Sets whether or not the interval will repeat after it reaches it length- Parameters:
flag
- true means repeats
-
getRepeatFlag
public final boolean getRepeatFlag()
Returns whether or not the interval will repeat after it completes its duration- Returns:
- true means it repeats
-
setStartTime
public final void setStartTime(double startTime)
Specifies when the interval is to start. If negative, then the interval will not be started- Parameters:
startTime
- must not be infinite
-
getStartTime
public final double getStartTime()
- Returns:
- the time to start the interval
-
setResponseSchedule
protected final void setResponseSchedule(ResponseSchedule schedule)
- Parameters:
schedule
- the response schedule that the interval is on
-
setDuration
protected final void setDuration(double duration)
- Parameters:
duration
- must be finite and positive
-
addResponseToInterval
public ResponseVariable addResponseToInterval(ResponseVariable theResponse)
Adds a ResponseVariable to the interval for data collection over the interval. By default, interval empty statistics are not collected.- Parameters:
theResponse
- the response to collect interval statistics on- Returns:
- a ResponseVariable for the interval
-
addResponseToInterval
public ResponseVariable addResponseToInterval(ResponseVariable theResponse, boolean intervalEmptyStatOption)
Adds a ResponseVariable to the interval for data collection over the interval- Parameters:
theResponse
- the response to collect interval statistics onintervalEmptyStatOption
- true means include statistics on whether the interval is empty when observed- Returns:
- a ResponseVariable for the interval
-
addCounterToInterval
public ResponseVariable addCounterToInterval(Counter theCounter)
Adds a Counter to the interval for data collection over the interval- Parameters:
theCounter
- the counter to collect interval statistics on- Returns:
- a ResponseVariable for the interval
-
isScheduled
public final boolean isScheduled()
- Returns:
- true if the interval has been scheduled
-
getTimeLastStarted
public final double getTimeLastStarted()
When the interval was last started- Returns:
- When the interval was last started
-
getTimeLastEnded
public final double getTimeLastEnded()
When the interval was last ended- Returns:
- When the interval was last ended
-
getDuration
public final double getDuration()
The duration (length) of the interval- Returns:
- The duration (length) of the interval
-
initialize
protected void initialize()
Description copied from class:ModelElement
This 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:
initialize
in classModelElement
-
afterReplication
protected void afterReplication()
Description copied from class:ModelElement
This method should be overridden by subclasses that need actions performed after each replication. It is called after replicationEnded() has been called.- Overrides:
afterReplication
in classModelElement
-
scheduleInterval
protected final void scheduleInterval(double startTime)
Schedules the interval to occur at current time + start time- Parameters:
startTime
- the time to start the interval
-
cancelInterval
public void cancelInterval()
Cancels the scheduling of the interval. Any statistical collection will not occur.
-
toString
public java.lang.String toString()
Includes the model name, the id, the model element name, the parent name, and parent id- Overrides:
toString
in classModelElement
- Returns:
- a string representing the model element
-
asString
public java.lang.String asString()
Description copied from class:ModelElement
Allows sub-classes to provide more detail than toString() to represent the ModelElement as a String- Overrides:
asString
in classModelElement
- Returns:
- a detailed String representation
-
-