Package jsl.modeling.elements.variable
Class ResponseVariable
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.modeling.elements.variable.Aggregatable
-
- jsl.modeling.elements.variable.Variable
-
- jsl.modeling.elements.variable.ResponseVariable
-
- All Implemented Interfaces:
AcrossReplicationStatisticIfc
,DefaultReportingOptionIfc
,GetInitialValueIfc
,GetPreviousTimeOfChangeIfc
,GetTimeOfChangeIfc
,GetWeightIfc
,InitialValueIfc
,ResponseStatisticsIfc
,SetInitialValueIfc
,SetValueIfc
,TimeWeightedIfc
,VariableIfc
,WithinReplicationStatisticIfc
,ObservableIfc
,GetNameIfc
,GetValueIfc
,IdentityIfc
,PreviousValueIfc
- Direct Known Subclasses:
TimeWeighted
public class ResponseVariable extends Variable implements DefaultReportingOptionIfc, ResponseStatisticsIfc
-
-
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 ResponseVariable
myAcrossIntervalResponse
For collecting across interval statisticsprotected Statistic
myAcrossRepStats
The across replication statistics for the response variableprotected long
myCountStopLimit
indicates the count when the simulation should stop *protected boolean
myDefaultReportingOption
Can be used by the reports to indicate whether or not the response should appear The default is trueprotected double
myLastUpdateTime
Time of last update intervalprotected ResponseVariable
myMaxResponse
Used to collect across replication averages over the maximum of the response variableprotected double
myTimeOfWarmUp
The time of the warm up if it occurs, 0.0 otherwiseprotected WeightedStatistic
myWithinIntervalStats
The within interval statistics for the response variableprotected WeightedStatistic
myWithinRepStats
The within replication statistics for the response variable-
Fields inherited from class jsl.modeling.elements.variable.Variable
myInitialValue, myLowerLimit, myNextValue, myPrevTimeOfChange, myPrevValue, myTimeOfChange, myUpperLimit, myValue, myVariableTraceTextReport, myWeight
-
Fields inherited from class jsl.modeling.elements.variable.Aggregatable
myAggregates
-
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 ResponseVariable(ModelElement parent)
Creates a ResponseVariable with the given parent with initial value 0.0 over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]ResponseVariable(ModelElement parent, double initialValue)
Creates a ResponseVariable with the given name and initial value over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]ResponseVariable(ModelElement parent, double initialValue, double lowerLimit)
Creates a ResponseVariable with the initial value over the supplied range [lowerLimit, Double.POSITIVE_INFINITY]ResponseVariable(ModelElement parent, double initialValue, double lowerLimit, double upperLimit)
Creates a ResponseVariable with the initial value over the supplied range [lowerLimit, upperLimit]ResponseVariable(ModelElement parent, double initialValue, double lowerLimit, double upperLimit, java.lang.String name)
Creates a ResponseVariable with the given name and initial value over the supplied range [lowerLimit, upperLimit]ResponseVariable(ModelElement parent, double initialValue, double lowerLimit, java.lang.String name)
Creates a ResponseVariable with the given name and initial value over the supplied range [lowerLimit, Double.POSITIVE_INFINITY]ResponseVariable(ModelElement parent, double initialValue, java.lang.String name)
Creates a ResponseVariable with the given name and initial value over the supplied range The default range is [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]ResponseVariable(ModelElement parent, java.lang.String name)
Creates a ResponseVariable with the given name and initial value, 0.0, over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 Stringprotected void
beforeExperiment()
This method should be overridden by subclasses that need logic to be performed prior to an experiment.protected void
beforeReplication()
This method should be overridden by subclasses that need actions performed prior to each replication.protected void
collectStatistics()
ResponseVariable
getAcrossIntervalResponse()
If the time interval collection is turned on a ResponseVariable is created for capturing statistics across the intervals.double
getAcrossReplicationAverage()
A convenience method to get the across replication average from the underlying CounterObserver For other statistics use getAcrossReplicationStatistic()StatisticAccessorIfc
getAcrossReplicationStatistic()
Gets a copy of the statistics that have been accumulated across all replications for this variable.long
getCountStopLimit()
Gets the stopping limit based on counts, zero means no limit setboolean
getDefaultReportingOption()
Returns the default reporting option.double
getValue()
Every Variable must implement the getValue method.WeightedStatisticIfc
getWithinReplicationStatistic()
Gets the within replication statisticsprotected void
removedFromModel()
This method should be overridden by subclasses that need actions performed when a model element is removed from a model after the replication has started.protected void
replicationEnded()
This method should be overridden by subclasses that need actions performed when the replication ends and prior to the calling of afterReplication() .void
resetWithinReplicationStatistics()
void
setCountBasedStopLimit(long countLimit)
Sets the count limit for determining when the count based stopping should occur If countLimit is less than or equal to current count when set then the action will occur the next time that the variable changesvoid
setDefaultReportingOption(boolean flag)
Sets the default reporting option.void
setValue(double value)
Sets the value of the variable and notifies any observers of the changeprotected void
timedUpdate()
This method should be overridden by subclasses that need actions performed at each timed update event during each replication.void
turnOnAcrossReplicationMaxCollection()
Allows for the collection of across replication statistics on the average maximum number observedvoid
turnOnTimeIntervalCollection(double interval)
Turns on the collection of statistics across intervals of time, defined by the interval lengthvoid
turnOnTimeIntervalTrace()
Turns on tracing to a file of the time interval response if and only if time interval collection has been turned onvoid
turnOnTimeIntervalTrace(boolean header)
Turns on tracing to a file of the time interval response if and only if time interval collection has been turned onvoid
turnOnTimeIntervalTrace(java.lang.String fileName)
Turns on tracing to a file of the time interval response if and only if time interval collection has been turned onvoid
turnOnTimeIntervalTrace(java.lang.String fileName, boolean header)
Turns on tracing to a file of the time interval response if and only if time interval collection has been turned onprotected void
warmUp()
This method should be overridden by subclasses that need actions performed at the warm up event during each replication.-
Methods inherited from class jsl.modeling.elements.variable.Variable
assignInitialValue, assignValue, getInitialValue, getLowerLimit, getPreviousTimeOfChange, getPreviousValue, getSetValueUpdateNotificationFlag, getTimeOfChange, getUpperLimit, getWeight, initialize, setInitialValue, setTraceObserver, setValue, setValueUpdateNotificationFlag, setWeight, turnOffTrace, turnOnTrace, turnOnTrace, turnOnTrace, turnOnTrace
-
Methods inherited from class jsl.modeling.elements.variable.Aggregatable
attachAggregate, detachAggregate, initialize_, notifyAggregatesOfInitialization, notifyAggregatesOfModelRemoval, notifyAggregatesOfValueChange, notifyAggregatesOfWarmUp, warmUp_
-
Methods inherited from class jsl.simulation.ModelElement
addObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication_, beforeExperiment_, 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, 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_, 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_, toString, update, useControls, week
-
-
-
-
Field Detail
-
myCountStopLimit
protected long myCountStopLimit
indicates the count when the simulation should stop *
-
myDefaultReportingOption
protected boolean myDefaultReportingOption
Can be used by the reports to indicate whether or not the response should appear The default is true
-
myWithinRepStats
protected WeightedStatistic myWithinRepStats
The within replication statistics for the response variable
-
myAcrossRepStats
protected Statistic myAcrossRepStats
The across replication statistics for the response variable
-
myMaxResponse
protected ResponseVariable myMaxResponse
Used to collect across replication averages over the maximum of the response variable
-
myWithinIntervalStats
protected WeightedStatistic myWithinIntervalStats
The within interval statistics for the response variable
-
myAcrossIntervalResponse
protected ResponseVariable myAcrossIntervalResponse
For collecting across interval statistics
-
myLastUpdateTime
protected double myLastUpdateTime
Time of last update interval
-
myTimeOfWarmUp
protected double myTimeOfWarmUp
The time of the warm up if it occurs, 0.0 otherwise
-
-
Constructor Detail
-
ResponseVariable
public ResponseVariable(ModelElement parent)
Creates a ResponseVariable with the given parent with initial value 0.0 over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]- Parameters:
parent
- the variable's parent model element.
-
ResponseVariable
public ResponseVariable(ModelElement parent, double initialValue)
Creates a ResponseVariable with the given name and initial value over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]- Parameters:
parent
- the variable's parent model element.initialValue
- The initial value of the variable.
-
ResponseVariable
public ResponseVariable(ModelElement parent, java.lang.String name)
Creates a ResponseVariable with the given name and initial value, 0.0, over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]- Parameters:
parent
- the variable's parent model element.name
- The name of the variable.
-
ResponseVariable
public ResponseVariable(ModelElement parent, double initialValue, java.lang.String name)
Creates a ResponseVariable with the given name and initial value over the supplied range The default range is [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]- Parameters:
parent
- the variable's parent model elementinitialValue
- The initial value of the variable.name
- The name of the variable.
-
ResponseVariable
public ResponseVariable(ModelElement parent, double initialValue, double lowerLimit, java.lang.String name)
Creates a ResponseVariable with the given name and initial value over the supplied range [lowerLimit, Double.POSITIVE_INFINITY]- Parameters:
parent
- the variable's parent model elementinitialValue
- The initial value of the variable.lowerLimit
- the lower limit on the range for the variable, must be < upperLimitname
- The name of the variable.
-
ResponseVariable
public ResponseVariable(ModelElement parent, double initialValue, double lowerLimit)
Creates a ResponseVariable with the initial value over the supplied range [lowerLimit, Double.POSITIVE_INFINITY]- Parameters:
parent
- the variable's parent model elementinitialValue
- The initial value of the variable.lowerLimit
- the lower limit on the range for the variable, must be < upperLimit
-
ResponseVariable
public ResponseVariable(ModelElement parent, double initialValue, double lowerLimit, double upperLimit)
Creates a ResponseVariable with the initial value over the supplied range [lowerLimit, upperLimit]- Parameters:
parent
- the variable's parent model elementinitialValue
- The initial value of the variable.lowerLimit
- the lower limit on the range for the variable, must be < upperLimitupperLimit
- the upper limit on the range for the variable
-
ResponseVariable
public ResponseVariable(ModelElement parent, double initialValue, double lowerLimit, double upperLimit, java.lang.String name)
Creates a ResponseVariable with the given name and initial value over the supplied range [lowerLimit, upperLimit]- Parameters:
parent
- the variable's parent model elementinitialValue
- The initial value of the variable. Must be within the range.lowerLimit
- the lower limit on the range for the variable, must be < upperLimitupperLimit
- the upper limit on the range for the variablename
- The name of the variable.
-
-
Method Detail
-
turnOnAcrossReplicationMaxCollection
public final void turnOnAcrossReplicationMaxCollection()
Allows for the collection of across replication statistics on the average maximum number observed
-
getAcrossIntervalResponse
public final ResponseVariable getAcrossIntervalResponse()
If the time interval collection is turned on a ResponseVariable is created for capturing statistics across the intervals. This returns this value or null if time interval collection has not been turned on- Returns:
- the response or null
-
turnOnTimeIntervalCollection
public final void turnOnTimeIntervalCollection(double interval)
Turns on the collection of statistics across intervals of time, defined by the interval length- Parameters:
interval
-
-
turnOnTimeIntervalTrace
public final void turnOnTimeIntervalTrace()
Turns on tracing to a file of the time interval response if and only if time interval collection has been turned on
-
turnOnTimeIntervalTrace
public final void turnOnTimeIntervalTrace(boolean header)
Turns on tracing to a file of the time interval response if and only if time interval collection has been turned on- Parameters:
header
- true means include the header
-
turnOnTimeIntervalTrace
public final void turnOnTimeIntervalTrace(java.lang.String fileName)
Turns on tracing to a file of the time interval response if and only if time interval collection has been turned on- Parameters:
fileName
- the name of the file to write the trace
-
turnOnTimeIntervalTrace
public final void turnOnTimeIntervalTrace(java.lang.String fileName, boolean header)
Turns on tracing to a file of the time interval response if and only if time interval collection has been turned on- Parameters:
fileName
- the name of the file to write the traceheader
- true means include the header
-
replicationEnded
protected void replicationEnded()
Description copied from class:ModelElement
This method should be overridden by subclasses that need actions performed when the replication ends and prior to the calling of afterReplication() . It is called when each replication ends and can be used to collect data from the the model element, etc.- Overrides:
replicationEnded
in classModelElement
-
setDefaultReportingOption
public void setDefaultReportingOption(boolean flag)
Sets the default reporting option. True means the response will appear on default reports- Specified by:
setDefaultReportingOption
in interfaceDefaultReportingOptionIfc
- Parameters:
flag
-
-
getDefaultReportingOption
public boolean getDefaultReportingOption()
Returns the default reporting option. True means that the response should appear on the default reports- Specified by:
getDefaultReportingOption
in interfaceDefaultReportingOptionIfc
- Returns:
-
getValue
public double getValue()
Every Variable must implement the getValue method. This method simply returns the value of the variable.- Specified by:
getValue
in interfaceGetValueIfc
- Overrides:
getValue
in classVariable
- Returns:
- The value of the variable.
-
getWithinReplicationStatistic
public final WeightedStatisticIfc getWithinReplicationStatistic()
Gets the within replication statistics- Specified by:
getWithinReplicationStatistic
in interfaceWithinReplicationStatisticIfc
- Returns:
-
resetWithinReplicationStatistics
public void resetWithinReplicationStatistics()
-
removedFromModel
protected void removedFromModel()
Description copied from class:Aggregatable
This method should be overridden by subclasses that need actions performed when a model element is removed from a model after the replication has started.- Overrides:
removedFromModel
in classVariable
-
setValue
public void setValue(double value)
Description copied from class:Variable
Sets the value of the variable and notifies any observers of the change- Specified by:
setValue
in interfaceSetValueIfc
- Overrides:
setValue
in classVariable
- Parameters:
value
- The observation of the variable.
-
collectStatistics
protected void collectStatistics()
-
timedUpdate
protected void timedUpdate()
Description copied from class:ModelElement
This method should be overridden by subclasses that need actions performed at each timed update event during each replication. It is called for each timed update during each replication if the model element reacts to timed update actions.- Overrides:
timedUpdate
in classModelElement
-
setCountBasedStopLimit
public final void setCountBasedStopLimit(long countLimit)
Sets the count limit for determining when the count based stopping should occur If countLimit is less than or equal to current count when set then the action will occur the next time that the variable changes- Parameters:
countLimit
- must be >=0, zero implies no count limit
-
getCountStopLimit
public final long getCountStopLimit()
Gets the stopping limit based on counts, zero means no limit set- Returns:
- the stopping limit for observations
-
beforeExperiment
protected void beforeExperiment()
Description copied from class:ModelElement
This method should be overridden by subclasses that need logic to be performed prior to an experiment. The beforeExperiment method allows model elements to be setup prior to the first replication within an experiment. It is called once before any replications occur.- Overrides:
beforeExperiment
in classVariable
-
beforeReplication
protected void beforeReplication()
Description copied from class:ModelElement
This method should be overridden by subclasses that need actions performed prior to each replication. It is called prior to each replication and can be used to initialize the model element. It is called before initialize() is called.- Overrides:
beforeReplication
in classModelElement
-
warmUp
protected void warmUp()
Description copied from class:ModelElement
This method should be overridden by subclasses that need actions performed at the warm up event during each replication. It is called once during each replication if the model element reacts to warm up actions.
-
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
-
getAcrossReplicationStatistic
public final StatisticAccessorIfc getAcrossReplicationStatistic()
Gets a copy of the statistics that have been accumulated across all replications for this variable.- Specified by:
getAcrossReplicationStatistic
in interfaceAcrossReplicationStatisticIfc
- Returns:
- A StatisticAccessorIfc representing the across replication statistics.
-
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
-
getAcrossReplicationAverage
public double getAcrossReplicationAverage()
Description copied from interface:AcrossReplicationStatisticIfc
A convenience method to get the across replication average from the underlying CounterObserver For other statistics use getAcrossReplicationStatistic()- Specified by:
getAcrossReplicationAverage
in interfaceAcrossReplicationStatisticIfc
- Returns:
- the across replication average
-
-