Package jsl.modeling.elements.variable
Class Aggregate
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- jsl.modeling.elements.variable.Aggregatable
-
- jsl.modeling.elements.variable.Aggregate
-
- All Implemented Interfaces:
DefaultReportingOptionIfc
,ObservableIfc
,GetNameIfc
,GetValueIfc
,IdentityIfc
,PreviousValueIfc
- Direct Known Subclasses:
AggregateCounter
,AggregateTimeWeightedVariable
,ResponseVariableAverageObserver
public abstract class Aggregate extends Aggregatable implements DefaultReportingOptionIfc
This class serves as a base class for the concept of aggregate variables. That is, something that consists of many variables. It knows about the variables that it aggregates. Any variable can be associated with any number of aggregates and any aggregate can be associated with any number of variables
-
-
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 int
myNumInitialized
counts the number of observed variables that have been initializedprotected int
myNumWarmedUp
counts the number of observed variables that have been warmed upprotected java.util.List<Aggregatable>
myVariables
Holds the variables that this aggregate is observing for the purposes of aggregation-
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 Aggregate(ModelElement parent)
Aggregate(ModelElement parent, java.lang.String name)
-
Method Summary
All Methods Instance Methods Abstract 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.double
avgValues()
Computes and returns the average of the aggregated variablesprotected void
beforeExperiment()
This method should be overridden by subclasses that need logic to be performed prior to an experiment.int
countNumToInitialize()
Counts and returns the number of aggregated variables that have their initialization option onint
countNumToWarmUp()
Counts and returns the number of aggregated variables that have their warm up option onprotected abstract void
initializeAggregate()
Sub-classes must implement this method to properly initialize the aggregate after all its variables have been initializedprotected void
initialized(Aggregatable variable)
Aggregatables to which the Aggregate is subscribed call this method when they are initializedprotected void
removedFromModel(Aggregatable variable)
Sub-classes can implement this method to properly react to the removal from the model of the variable with respect to its form of aggregation.void
subscribeTo(Aggregatable variable)
Tells the Aggregate to observe the provided Variable for the purpose of aggregatingdouble
sumValues()
Computes and returns the sum of the aggregated variablesvoid
unsubscribeFrom(Aggregatable variable)
Tells the aggregate to stop observing the provided Variableprotected abstract void
valueChangedBeforeReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to a change in the variable with respect to its form of aggregationprotected abstract void
valueChangedDuringReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to a change in the variable with respect to its form of aggregationprotected abstract void
variableAddedBeforeReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to the subscription of a new variable to the aggregate.protected abstract void
variableAddedDuringReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to the subscription of a new variable to the aggregate.protected abstract void
variableRemovedBeforeReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to the removal of a variable from the aggregate.protected abstract void
variableRemovedDuringReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to the removal of a variable from the aggregate.protected void
warmedUp(Aggregatable variable)
Aggregatables to which the Aggregate is subscribed call this method when they are warmed upprotected abstract void
warmUpAggregate()
Sub-classes must implement this method to properly warm up the aggregate after all its variables have been warmed up-
Methods inherited from class jsl.modeling.elements.variable.Aggregatable
attachAggregate, detachAggregate, initialize_, notifyAggregatesOfInitialization, notifyAggregatesOfModelRemoval, notifyAggregatesOfValueChange, notifyAggregatesOfWarmUp, removedFromModel, warmUp_
-
Methods inherited from class jsl.simulation.ModelElement
addObserver, addObserverToModelElements, afterExperiment, afterExperiment_, afterReplication_, asString, 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, week
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.modeling.elements.variable.DefaultReportingOptionIfc
getDefaultReportingOption, setDefaultReportingOption
-
Methods inherited from interface jsl.utilities.GetValueIfc
getValue
-
Methods inherited from interface jsl.utilities.PreviousValueIfc
getPreviousValue
-
-
-
-
Field Detail
-
myNumInitialized
protected int myNumInitialized
counts the number of observed variables that have been initialized
-
myNumWarmedUp
protected int myNumWarmedUp
counts the number of observed variables that have been warmed up
-
myVariables
protected java.util.List<Aggregatable> myVariables
Holds the variables that this aggregate is observing for the purposes of aggregation
-
-
Constructor Detail
-
Aggregate
public Aggregate(ModelElement parent)
- Parameters:
parent
-
-
Aggregate
public Aggregate(ModelElement parent, java.lang.String name)
- Parameters:
parent
-name
-
-
-
Method Detail
-
subscribeTo
public final void subscribeTo(Aggregatable variable)
Tells the Aggregate to observe the provided Variable for the purpose of aggregating- Parameters:
variable
-
-
unsubscribeFrom
public final void unsubscribeFrom(Aggregatable variable)
Tells the aggregate to stop observing the provided Variable- Parameters:
variable
-
-
sumValues
public final double sumValues()
Computes and returns the sum of the aggregated variables- Returns:
-
avgValues
public final double avgValues()
Computes and returns the average of the aggregated variables- Returns:
-
countNumToInitialize
public final int countNumToInitialize()
Counts and returns the number of aggregated variables that have their initialization option on- Returns:
-
countNumToWarmUp
public final int countNumToWarmUp()
Counts and returns the number of aggregated variables that have their warm up option on- Returns:
-
variableAddedBeforeReplication
protected abstract void variableAddedBeforeReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to the subscription of a new variable to the aggregate. Note that the variable is already in the aggregate's list of variables when this method is invoked- Parameters:
variable
- The variable that has been added to the aggregate
-
variableAddedDuringReplication
protected abstract void variableAddedDuringReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to the subscription of a new variable to the aggregate. Note that the variable is already in the aggregate's list of variables when this method is invoked- Parameters:
variable
- The variable that has been added to the aggregate
-
variableRemovedBeforeReplication
protected abstract void variableRemovedBeforeReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to the removal of a variable from the aggregate. Note that the variable is no longer in the aggregate's list of variables when this method is invoked- Parameters:
variable
- The variable that has been removed from the aggregate
-
variableRemovedDuringReplication
protected abstract void variableRemovedDuringReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to the removal of a variable from the aggregate. Note that the variable is no longer in the aggregate's list of variables when this method is invoked- Parameters:
variable
- The variable that has been removed from the aggregate
-
valueChangedBeforeReplication
protected abstract void valueChangedBeforeReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to a change in the variable with respect to its form of aggregation- Parameters:
variable
- The variable that has just changed
-
valueChangedDuringReplication
protected abstract void valueChangedDuringReplication(Aggregatable variable)
Sub-classes must implement this method to properly react to a change in the variable with respect to its form of aggregation- Parameters:
variable
- The variable that has just changed
-
initializeAggregate
protected abstract void initializeAggregate()
Sub-classes must implement this method to properly initialize the aggregate after all its variables have been initialized
-
warmUpAggregate
protected abstract void warmUpAggregate()
Sub-classes must implement this method to properly warm up the aggregate after all its variables have been warmed up
-
removedFromModel
protected void removedFromModel(Aggregatable variable)
Sub-classes can implement this method to properly react to the removal from the model of the variable with respect to its form of aggregation.- Parameters:
variable
- The variable that has just been removed from the model
-
initialized
protected void initialized(Aggregatable variable)
Aggregatables to which the Aggregate is subscribed call this method when they are initialized- Parameters:
variable
- The variable that has just been initialized
-
warmedUp
protected void warmedUp(Aggregatable variable)
Aggregatables to which the Aggregate is subscribed call this method when they are warmed up- Parameters:
variable
- The variable that has just been warmed up
-
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 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
-
-