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 ResponseVariablemyAcrossIntervalResponseFor collecting across interval statisticsprotected StatisticmyAcrossRepStatsThe across replication statistics for the response variableprotected longmyCountStopLimitindicates the count when the simulation should stop *protected booleanmyDefaultReportingOptionCan be used by the reports to indicate whether or not the response should appear The default is trueprotected doublemyLastUpdateTimeTime of last update intervalprotected ResponseVariablemyMaxResponseUsed to collect across replication averages over the maximum of the response variableprotected doublemyTimeOfWarmUpThe time of the warm up if it occurs, 0.0 otherwiseprotected WeightedStatisticmyWithinIntervalStatsThe within interval statistics for the response variableprotected WeightedStatisticmyWithinRepStatsThe 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 voidafterReplication()This method should be overridden by subclasses that need actions performed after each replication.java.lang.StringasString()Allows sub-classes to provide more detail than toString() to represent the ModelElement as a Stringprotected voidbeforeExperiment()This method should be overridden by subclasses that need logic to be performed prior to an experiment.protected voidbeforeReplication()This method should be overridden by subclasses that need actions performed prior to each replication.protected voidcollectStatistics()ResponseVariablegetAcrossIntervalResponse()If the time interval collection is turned on a ResponseVariable is created for capturing statistics across the intervals.doublegetAcrossReplicationAverage()A convenience method to get the across replication average from the underlying CounterObserver For other statistics use getAcrossReplicationStatistic()StatisticAccessorIfcgetAcrossReplicationStatistic()Gets a copy of the statistics that have been accumulated across all replications for this variable.longgetCountStopLimit()Gets the stopping limit based on counts, zero means no limit setbooleangetDefaultReportingOption()Returns the default reporting option.doublegetValue()Every Variable must implement the getValue method.WeightedStatisticIfcgetWithinReplicationStatistic()Gets the within replication statisticsprotected voidremovedFromModel()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 voidreplicationEnded()This method should be overridden by subclasses that need actions performed when the replication ends and prior to the calling of afterReplication() .voidresetWithinReplicationStatistics()voidsetCountBasedStopLimit(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 changesvoidsetDefaultReportingOption(boolean flag)Sets the default reporting option.voidsetValue(double value)Sets the value of the variable and notifies any observers of the changeprotected voidtimedUpdate()This method should be overridden by subclasses that need actions performed at each timed update event during each replication.voidturnOnAcrossReplicationMaxCollection()Allows for the collection of across replication statistics on the average maximum number observedvoidturnOnTimeIntervalCollection(double interval)Turns on the collection of statistics across intervals of time, defined by the interval lengthvoidturnOnTimeIntervalTrace()Turns on tracing to a file of the time interval response if and only if time interval collection has been turned onvoidturnOnTimeIntervalTrace(boolean header)Turns on tracing to a file of the time interval response if and only if time interval collection has been turned onvoidturnOnTimeIntervalTrace(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 onvoidturnOnTimeIntervalTrace(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 voidwarmUp()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:ModelElementThis 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:
replicationEndedin classModelElement
-
setDefaultReportingOption
public void setDefaultReportingOption(boolean flag)
Sets the default reporting option. True means the response will appear on default reports- Specified by:
setDefaultReportingOptionin 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:
getDefaultReportingOptionin interfaceDefaultReportingOptionIfc- Returns:
-
getValue
public double getValue()
Every Variable must implement the getValue method. This method simply returns the value of the variable.- Specified by:
getValuein interfaceGetValueIfc- Overrides:
getValuein classVariable- Returns:
- The value of the variable.
-
getWithinReplicationStatistic
public final WeightedStatisticIfc getWithinReplicationStatistic()
Gets the within replication statistics- Specified by:
getWithinReplicationStatisticin interfaceWithinReplicationStatisticIfc- Returns:
-
resetWithinReplicationStatistics
public void resetWithinReplicationStatistics()
-
removedFromModel
protected void removedFromModel()
Description copied from class:AggregatableThis 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:
removedFromModelin classVariable
-
setValue
public void setValue(double value)
Description copied from class:VariableSets the value of the variable and notifies any observers of the change- Specified by:
setValuein interfaceSetValueIfc- Overrides:
setValuein classVariable- Parameters:
value- The observation of the variable.
-
collectStatistics
protected void collectStatistics()
-
timedUpdate
protected void timedUpdate()
Description copied from class:ModelElementThis 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:
timedUpdatein 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:ModelElementThis 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:
beforeExperimentin classVariable
-
beforeReplication
protected void beforeReplication()
Description copied from class:ModelElementThis 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:
beforeReplicationin classModelElement
-
warmUp
protected void warmUp()
Description copied from class:ModelElementThis 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:ModelElementThis method should be overridden by subclasses that need actions performed after each replication. It is called after replicationEnded() has been called.- Overrides:
afterReplicationin classModelElement
-
getAcrossReplicationStatistic
public final StatisticAccessorIfc getAcrossReplicationStatistic()
Gets a copy of the statistics that have been accumulated across all replications for this variable.- Specified by:
getAcrossReplicationStatisticin interfaceAcrossReplicationStatisticIfc- Returns:
- A StatisticAccessorIfc representing the across replication statistics.
-
asString
public java.lang.String asString()
Description copied from class:ModelElementAllows sub-classes to provide more detail than toString() to represent the ModelElement as a String
-
getAcrossReplicationAverage
public double getAcrossReplicationAverage()
Description copied from interface:AcrossReplicationStatisticIfcA convenience method to get the across replication average from the underlying CounterObserver For other statistics use getAcrossReplicationStatistic()- Specified by:
getAcrossReplicationAveragein interfaceAcrossReplicationStatisticIfc- Returns:
- the across replication average
-
-