Class ModelElement
- java.lang.Object
-
- jsl.simulation.ModelElement
-
- All Implemented Interfaces:
ObservableIfc
,GetNameIfc
,IdentityIfc
- Direct Known Subclasses:
Aggregatable
,ExampleModelElement
,GGCQueuingStation
,GGCQueuingStationWithCustST
,HospitalWard
,JobShop
,JobType
,LOTR
,Model
,ModelElementState
,NHPPEventGenerator
,ProcessDescription
,Queue
,RandomElement
,RandomList
,RandomVariable
,ResourcePool
,ResourceSet
,ResponseVariableBatchingElement
,SchedulingElement
,Sequence
,StatisticalBatchingElement
,TestLevelResponse
,TestNHPP
,TestNHPPPWConstant
,TestNHPPPWConstantNonRepeat
,TestNHPPPWConstantRepeat
,TestNHPPPWLinear
,TestNHPPPWLinearNonRepeat
,TestNHPPPWLinearRepeat
,TestResponseVariable
,TieDyeTShirts
,TieDyeTShirtsSR
,TransporterSet
,TwoWayByChanceQObjectSender
,UniformCellSelector
public abstract class ModelElement extends java.lang.Object implements IdentityIfc, ObservableIfc
The ModelElement represents elements within the simulation model that can schedule and react to simulation events and default simulation actions (e.g. setup, begin replication, warm up, after replication, end simulation, etc.) The ModelElement is a component in the composite pattern
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ModelElement.EventBuilderIfc<T>
protected class
ModelElement.EventScheduler<T>
Uses the builder pattern to create and schedule the event and the action associated carrying the eventstatic class
ModelElement.ModelElementComparator
A Comparator for comparing model elements based on getId()class
ModelElement.RequestBuilder
static interface
ModelElement.RequestDurationIfc
static interface
ModelElement.RequestTimeIfc
static interface
ModelElement.RequestUsingIfc
protected class
ModelElement.TimedUpdateEventAction
static interface
ModelElement.TimeUnitIfc<T>
A Tagging interface to force builder to specify time timeUnits after calling the in() method.protected class
ModelElement.WarmUpEventAction
-
Field Summary
Fields Modifier and Type Field Description static int
AFTER_EXPERIMENT
An "enum" for the end of simulation state.static int
AFTER_REPLICATION
An "enum" for the after replication state.static int
BEFORE_EXPERIMENT
An "enum" for the setup state.static int
BEFORE_REPLICATION
An "enum" for the before replication state.static int
CONDITIONAL_ACTION_REGISTRATION
An "enum" to indicate that the model element performed its registerConditionalActions() methodstatic int
DEFAULT_TIMED_EVENT_PRIORITY
A constant for the default batch havingPrioritystatic int
INITIALIZED
An "enum" for the initialization state.static int
MONTE_CARLO
An "enum" for the monte carlo state.protected boolean
myAfterExperimentOption
A flag to control whether or not the model element reacts to after experiment actions.protected boolean
myAfterReplicationOption
A flag to control whether or not the model element reacts to after replication actions.protected boolean
myBeforeExperimentOption
A flag to control whether or not the model element reacts to before experiment actions.protected boolean
myBeforeReplicationOption
A flag to control whether or not the model element reacts to before replication actions.protected boolean
myInitializationOption
A flag to control whether or not the model element reacts to initialization actionsprotected double
myLengthOfWarmUp
The length of time from the start of the simulation to the warm up event.protected java.util.List<ModelElement>
myModelElements
A collection containing the first level children of this model elementprotected boolean
myMonteCarloOption
A flag to control whether or not the model element participates in monte carlo actions.protected ObservableComponent
myObservableComponent
Used to allow observersprotected boolean
myReplicationEndedOption
A flag to control whether or not the model element reacts to end replication actions.protected ModelElement.TimedUpdateEventAction
myTimedUpdateActionListener
The action listener that reacts to the timed update event.protected JSLEvent
myTimedUpdateEvent
A reference to the TimedUpdate event.protected double
myTimedUpdateInterval
The time interval between TimedUpdate events.protected boolean
myTimedUpdateOption
Specifies whether or not this model element participates in time update event specified by its parentprotected int
myTimedUpdatePriority
Specifies the havingPriority of this model element's timed update event.protected ModelElement.WarmUpEventAction
myWarmUpActionListener
The action listener that reacts to the warm up event.protected JSLEvent
myWarmUpEvent
A reference to the warm up eventprotected boolean
myWarmUpIndicator
Indicates whether or not the warm up action occurred sometime during the simulation.protected boolean
myWarmUpOption
Specifies if this model element will be warmed up when the warmup action occurs for its parent.protected int
myWarmUpPriority
Specifies the havingPriority of this model element's warm up event.static int
NONE
A mnemonic for zerostatic int
REMOVED_FROM_MODEL
An "enum" to indicate that the model element was removed from the model element hierarchystatic int
REPLICATION_ENDED
An "enum" for when the replication endsstatic double
TIME_UNIT_DAY
An "enum" to represent time unit conversion.static double
TIME_UNIT_HOUR
An "enum" to represent time unit conversion.static double
TIME_UNIT_MILLISECOND
An "enum" to represent time unit conversion.static double
TIME_UNIT_MINUTE
An "enum" to represent time unit conversion.static double
TIME_UNIT_SECOND
An "enum" to represent time unit conversion.static double
TIME_UNIT_WEEK
An "enum" to represent time unit conversion.static int
TIMED_UPDATE
An "enum" for the timed update state.static int
UPDATE
An "enum" for the update state.static int
WARMUP
An "enum" for the warmup state.
-
Constructor Summary
Constructors Constructor Description ModelElement(ModelElement parent)
Creates a model element carrying name "null" as a child element of the supplied parentModelElement(ModelElement parent, java.lang.String name)
Creates a model element carrying the given name as a child element of the supplied parent.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObserver(ObserverIfc observer)
Allows the adding (attaching) of an observer to the observablevoid
addObserverToModelElements(ObserverIfc o)
Adds an observer to this model element.protected void
afterExperiment()
This method should be overridden by subclasses that need actions performed after an experiment has been completed It is called after all replications are done and can be used to collect data from the the model element, etc.protected void
afterExperiment_()
The afterExperiment_ method is called after all replications are completed for an experiment.protected void
afterReplication()
This method should be overridden by subclasses that need actions performed after each replication.protected void
afterReplication_()
The afterReplication_ method is called at the end of 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
beforeExperiment_()
The beforeExperiment_ method allows model elements to be setup prior to the first replication within an experiment.protected void
beforeReplication()
This method should be overridden by subclasses that need actions performed prior to each replication.protected void
beforeReplication_()
The beforeReplication_ method is called before each replication.protected EventGenerator.ActionStepIfc
buildEventGenerator()
Allows easy building of an EventGeneratorvoid
cancelTimedUpdateEvent()
Cancels the timed update event for this model element.void
cancelWarmUpEvent()
Cancels the warm up event for this model element.ModelElement
changeParentModelElement(ModelElement newParent)
Changes the parent model element for this model element to the supplied value.boolean
checkForAfterExperiment()
Checks to see if the model element is in the end simulation state.boolean
checkForAfterReplication()
Checks to see if the model element is in the after replication state.boolean
checkForBeforeExperiment()
Checks to see if the model element is in the setup state.boolean
checkForBeforeReplication()
Checks to see if the model element is in the before replication state.boolean
checkForConditionalActionRegistration()
Checks to see if the model element has just called, registerConditionalActions()boolean
checkForInitialize()
Checks to see if the model element is in the initialize state.boolean
checkForMonteCarlo()
Checks to see if the model element is in the monte carlo state.boolean
checkForRemoveFromModel()
Checks to see if the model element just been removed from the model This method can be used by observers that are interested in reacting to when a model element is removed from a modelboolean
checkForReplicationEnded()
Checks to see if the model element is in the replication ended state.boolean
checkForTimedUpdate()
Checks to see if the model element is in the timed update state.boolean
checkForUpdate()
Checks to see if the model element is in the update state.boolean
checkForWarmUp()
Checks to see if the model element is in the warm up state.boolean
checkObserverState(int observerState)
Checks to see if the model element is in the given observer state.boolean
checkWarmUpOption()
Checks if this model element or any model element directly above this model element in the hierarchy of model elements all the way until the top Model participates in the warm up action.protected void
clearModelElementObservers()
Causes the model element to delete any observers that had been addedboolean
contains(ObserverIfc observer)
Returns true if the observer is already attachedint
countObservers()
Returns how many observers are currently observing the observableprotected Entity
createEntity()
Creates an instance of the DefaultEntityTypeprotected Entity
createEntity(java.lang.String name)
Creates an instance of the DefaultEntityType reactingWith the supplied nameprotected QObject
createQObject()
A convenience method for creating QObjectsdouble
day()
Returns the value of a 1 day time interval in terms of the base time unitvoid
deleteObserver(ObserverIfc observer)
Allows the deletion (removing) of an observer from the observablevoid
deleteObserverFromModelElements(ObserverIfc o)
Removes the observer from this model element.void
deleteObservers()
Deletes all the observers from the observableModelElement
findModelElementWithWarmUpEvent()
Find the first parent that has its own warm up event this guarantees that all elements below the found model element do not have their own warm up event.boolean
getAfterExperimentOption()
Gets the after experiment flag that indicates whether or not this model element will participate in the default after experiment action controlled by its parent model element.boolean
getAfterReplicationOption()
Gets the after replication flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.protected void
getAllCounters(java.util.Collection<Counter> c)
Fills up the provided collection carrying all of the Counters that are contained by any model elements within this model element.protected void
getAllModelElements(java.util.List<ModelElement> list)
Gets all model elements that are contained within this model element in parent-child order within the hierarchyprotected void
getAllRandomElements(java.util.Collection<RandomElementIfc> c)
Fills up the provided collection carrying all of the RandomElementIfc and subclasses of RandomElementIfc that are contained by any model elements within this model element.protected void
getAllResponseVariables(java.util.Collection<ResponseVariable> c)
Fills up the provided collection carrying all of the response variables that are contained by any model elements within this model element.protected void
getAllVariables(java.util.Collection<Variable> c)
Fills up the provided collection carrying all of the variables that are contained by any model elements within this model element.boolean
getBeforeExperimentOption()
Gets the before experiment flag that indicates whether or not this model element will participate in the default before experiment action controlled by its parent model element.boolean
getBeforeReplicationOption()
Gets the before replication flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.java.util.Iterator<ModelElement>
getChildModelElementIterator()
Gets an iterator to the contained model elements.int
getCurrentReplicationNumber()
Returns the current replication number.protected EntityType
getDefaultEntityType()
Returns a reference to the default entity typeExecutive
getExecutive()
Returns a reference to the Executive or null.ExperimentGetIfc
getExperiment()
Returns a reference to the Experiment or null.int
getId()
Gets a uniquely assigned integer identifier for this model element.boolean
getInitializationOption()
Gets the initialization flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.void
getInitializationOrderAsString(java.lang.StringBuilder sb)
Fills a StringBuilder carrying the model element names in the order that they will be initializedint
getLeftPreOrderTraversalCount()
double
getLengthOfWarmUp()
Gets the length of the warm up for this model element.Model
getModel()
Gets the main model.static java.util.Comparator<ModelElement>
getModelElementCompartor()
java.lang.String
getModelElementsAsString()
Returns a string representation of the model element and its child model elements.void
getModelElementsAsString(java.lang.StringBuilder sb)
Fills up the supplied StringBuilder carrying a string representation of the model element and its child model elements Useful for realizing the model element hierarchy.void
getModelElementsAsString(java.lang.StringBuilder sb, int n)
Fills up the supplied StringBuilder carrying a string representation of the model element and its child model elements Useful for realizing the model element hierarchy.boolean
getMonteCarloOption()
Gets the monte carlo option flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.java.lang.String
getName()
Gets this model element's name.int
getNumberOfModelElements()
Gets the number of model elements contained by this model elements.int
getObserverState()
Returns an integer representing the state of the model element This can be used by Observers to find out which action occurred for the model elementModelElement
getParentModelElement()
Gets this model elements parent in the composite pattern, i.e.int
getPreviousObserverState()
Returns an integer representing the previous state of the model element This can be used by Observers to find out which action occurred prior to the current state change for the model elementboolean
getReplicationEndedOption()
Gets the end replication flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.int
getRightPreOrderTraversalCount()
Simulation
getSimulation()
Returns a reference to the Simulation that contains the model that contains this ModelElementSpatialModel
getSpatialModel()
Gets the spatial model that this ModelElement is currently reactingWith if it existsjava.lang.String
getStringLabel()
Gets the a string that can be used to label the model element By default it is the same as getName(), but can be changed via setStringLabel()protected void
getThisElementsCounters(java.util.Collection<Counter> c)
Fills up the provided collection carrying the Counters that are contained only by this model elementprotected void
getThisElementsModelElements(java.util.List<ModelElement> list)
A list containing the (child) model elements of only this model elementprotected void
getThisElementsRandomVariables(java.util.Collection<RandomVariable> c)
Fills up the provided collection carrying only the random variables associated carrying this elementprotected void
getThisElementsResponseVariables(java.util.Collection<ResponseVariable> c)
Fills up the provided collection carrying the response variables that are contained only by this model elementprotected void
getThisElementsVariables(java.util.Collection<Variable> c)
Fills up the provided collection carrying only the variables associated carrying this elementdouble
getTime()
Gets the current simulated time relative to the starting time of the run.double
getTimedUpdateInterval()
Gets the time between timed update events for this model element.boolean
getTimedUpdateOption()
Gets the timed update flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.boolean
getUpdateNotificationFlag()
This flag indicates whether or not the notification of update observers will occur for this model element.Variable
getVariable(java.lang.String variableKey)
Gets the variable carrying the name given by the string provideddouble
getWarmUpEventTime()
This method returns the planned time for the warm up for this model elementboolean
getWarmUpOption()
Gets the warm up flag that indicates whether or not this model element will be warmed up when its parent warm up event/action occurs.double
hour()
Returns the value of a 1 hour time interval in terms of the base time unitprotected void
indent(java.lang.StringBuilder sb, int n)
Add spaces representing the level of indentionprotected void
initialize()
This method should be overridden by subclasses that need actions performed to initialize prior to a replication.protected void
initialize_()
The initialize_ method allows model elements to be initialized to a standard reactor defined state.boolean
isTimedUpdateEventScheduled()
Checks if a timed update event has been scheduled for this model elementboolean
isWarmedUp()
Returns true if the warm up has occurred, false otherwiseboolean
isWarmUpEventScheduled()
Checks if a warm up event has been scheduled for this model elementboolean
isWarmUpScheduled()
Checks if a warm up event is scheduled for any model element directly above this model element in the hierarchy of model elements all the way until the top Model.double
millisecond()
Returns the value of a 1 millisecond time interval in terms of the base time unitdouble
minute()
Returns the value of a 1 minute time interval in terms of the base time unit.protected void
montecarlo()
This method should be overridden by subclasses that need actions performed after before replication.protected void
montecarlo_()
The monte carlo_ method facilitates model elements to perform a monte carlo simulation carrying no events being called.protected void
notifyAfterExperimentObservers()
This method is used to notify observers that this model element has entered the end of simulation state.protected void
notifyAfterReplicationObservers()
The method is used to notify observers that this model element has entered the after replication state.protected void
notifyBeforeExperimentObservers()
The method is used to notify observers that this model element has entered the setup state.protected void
notifyBeforeReplicationObservers()
The method is used to notify observers that this model element has entered the before replication state.protected void
notifyConditionalActionRegistrationObservers()
This method is used to notify observers that this model element has called registerConditionalActions()protected void
notifyInitializationObservers()
The method is used to notify observers that this model element has entered the initialized state.protected void
notifyMonteCarloObservers()
The method is used to notify observers that this model element has entered the monte carlo state.protected void
notifyObservers(int observerState)
protected void
notifyObservers(int observerState, java.lang.Object arg)
Used to notify observers that this model element has entered the given state.protected void
notifyRemovingFromModelObservers()
This method is used to notify observers that this model element has been removed from a modelprotected void
notifyReplicationEndedObservers()
The method is used to notify observers that this model element has entered the after replication state.protected void
notifyTimedUpdateObservers()
The method is used to notify observers that this model element has entered the timed update state.protected void
notifyUpdateObservers()
The method is used to notify observers that this model element has been updated.protected void
notifyWarmUpObservers()
The method is used to notify observers that this model element has entered the warmup update state.protected void
registerConditionalActions(Executive e)
This method should be overridden by subclasses that need to register conditional actions prior to a replication.protected void
registerConditionalActions_(Executive e)
The registerConditionalActions_ method allows model elements to be register any conditional actions after initialization.protected void
removedFromModel()
This method should be overridden by subclasses that need actions performed when a model element is removed from a modelvoid
removeFromModel()
Recursively removes this model element and the children of this model element and all their children, etc.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() .protected void
replicationEnded_()
The replicationEnded_ method is called when a replication ends This method ensures that each contained model element that requires a end of replication action will performs its actions.protected <T> ModelElement.EventBuilderIfc<T>
schedule(EventActionIfc<T> action)
Creates an EventScheduler which can be used to create and schedule events on the simulation calendar reactingWith a fluency pattern.double
second()
Returns the value of a 1 second time interval in terms of the base time unitprotected ModelElement.RequestUsingIfc
seize(ResourceUnit resource)
void
setAfterExperimentOption(boolean flag)
Sets the after experiment option for this model element.void
setAfterExperimentOptionForModelElements(boolean option)
Sets the after experiment option of all model elements (children) contained by this model element.void
setAfterReplicationOption(boolean flag)
Sets the after replication flag for this model element.void
setAfterReplicationOptionForModelElements(boolean flag)
Sets the after replication flag of all model elements (children) contained by this model element.void
setBeforeExperimentOption(boolean flag)
Sets the before experiment option for this model element.void
setBeforeExperimentOptionForModelElements(boolean flag)
Sets the before experiment option of all model elements (children) contained by this model element.void
setBeforeReplicationOption(boolean flag)
Sets the before replication flag for this model element.void
setBeforeReplicationOptionForModelElements(boolean flag)
Sets the before replication flag of all model elements (children) contained by this model element.void
setInitializationOption(boolean flag)
Sets the initialization flag for this model element.void
setInitializationOptionForModelElements(boolean flag)
Sets the initialization option of all model elements (children) contained by this model element.void
setLengthOfWarmUp(double lengthOfWarmUp)
Sets the length of the warm up for this model element.protected void
setModel(Model model)
Sets the model attribute for this elementvoid
setMonteCarloOption(boolean flag)
Sets the monte carlo option flag for this model element.void
setMonteCarloOptionForModelElements(boolean flag)
Sets the monte carlo option flag of all model elements (children) contained by this model element.protected void
setName(java.lang.String str)
Sets the name of this model elementprotected void
setObserverState(int observerState)
protected void
setParentModelElement(ModelElement parent)
Sets the parent element to the supplied valuevoid
setReplicationEndedOption(boolean flag)
Sets the end replication option flag for this model element.void
setReplicationEndedOptionForModelElements(boolean flag)
Sets the end replication option flag of all model elements (children) contained by this model element.protected void
setSpatialModel(SpatialModel spatialModel)
Sets the spatial model for this ModelElement Note: Any ModelElements that are children of this ModelElement do not have their SpatialModels changed.void
setStringLabel(java.lang.String label)
Sets a string that can be used to label the model elementvoid
setTimedUpdateInterval(double deltaT)
Used to set the length of the timed update interval.void
setTimedUpdateOption(boolean timedUpdateOption)
Sets the timed update option flag for this model element.void
setTimedUpdateOptionForModelElements(boolean timedUpdateOption)
Sets the timed update option flag of all model elements (children) contained by this model element.void
setUpdateNotificationFlag(boolean flag)
This flag indicates whether or not the notification of update observers will occur for this model element.void
setWarmUpOption(boolean warmUpFlag)
Sets the warm up option flag for this model element.void
setWarmUpOptionForModelElements(boolean warmUpFlag)
Sets the warm up option flag of all model elements (children) contained by this model element.void
stopExecutive()
Tells the Executive to stop executing eventsvoid
stopExecutive(java.lang.String msg)
Tells the Executive to stop executing eventsprotected void
timedUpdate()
This method should be overridden by subclasses that need actions performed at each timed update event during each replication.protected void
timedUpdate_()
The timedUpdate_ method is called multiple times during each replication.java.lang.String
toString()
Includes the model name, the id, the model element name, the parent name, and parent idprotected void
update()
The update method can be called at reactor defined points to indicate that the model element has been changed in some fashion that the update observers need notification.protected void
useControls()
This method should be implemented by subclasses that need to use Controls prior to an experiment being run.protected void
warmUp()
This method should be overridden by subclasses that need actions performed at the warm up event during each replication.protected void
warmUp_()
The warmUp_ method is called once during each replication.double
week()
Returns the value of a 1 week time interval in terms of the base time unit
-
-
-
Field Detail
-
DEFAULT_TIMED_EVENT_PRIORITY
public static final int DEFAULT_TIMED_EVENT_PRIORITY
A constant for the default batch havingPriority- See Also:
- Constant Field Values
-
NONE
public static final int NONE
A mnemonic for zero- See Also:
- Constant Field Values
-
BEFORE_EXPERIMENT
public static final int BEFORE_EXPERIMENT
An "enum" for the setup state.
-
BEFORE_REPLICATION
public static final int BEFORE_REPLICATION
An "enum" for the before replication state.
-
INITIALIZED
public static final int INITIALIZED
An "enum" for the initialization state.
-
MONTE_CARLO
public static final int MONTE_CARLO
An "enum" for the monte carlo state.
-
UPDATE
public static final int UPDATE
An "enum" for the update state.
-
WARMUP
public static final int WARMUP
An "enum" for the warmup state.
-
TIMED_UPDATE
public static final int TIMED_UPDATE
An "enum" for the timed update state.
-
REPLICATION_ENDED
public static final int REPLICATION_ENDED
An "enum" for when the replication ends
-
AFTER_REPLICATION
public static final int AFTER_REPLICATION
An "enum" for the after replication state.
-
AFTER_EXPERIMENT
public static final int AFTER_EXPERIMENT
An "enum" for the end of simulation state.
-
REMOVED_FROM_MODEL
public static final int REMOVED_FROM_MODEL
An "enum" to indicate that the model element was removed from the model element hierarchy
-
CONDITIONAL_ACTION_REGISTRATION
public static final int CONDITIONAL_ACTION_REGISTRATION
An "enum" to indicate that the model element performed its registerConditionalActions() method
-
TIME_UNIT_MILLISECOND
public static final double TIME_UNIT_MILLISECOND
An "enum" to represent time unit conversion.- See Also:
- Constant Field Values
-
TIME_UNIT_SECOND
public static final double TIME_UNIT_SECOND
An "enum" to represent time unit conversion.- See Also:
- Constant Field Values
-
TIME_UNIT_MINUTE
public static final double TIME_UNIT_MINUTE
An "enum" to represent time unit conversion.- See Also:
- Constant Field Values
-
TIME_UNIT_HOUR
public static final double TIME_UNIT_HOUR
An "enum" to represent time unit conversion.- See Also:
- Constant Field Values
-
TIME_UNIT_DAY
public static final double TIME_UNIT_DAY
An "enum" to represent time unit conversion.- See Also:
- Constant Field Values
-
TIME_UNIT_WEEK
public static final double TIME_UNIT_WEEK
An "enum" to represent time unit conversion.- See Also:
- Constant Field Values
-
myBeforeExperimentOption
protected boolean myBeforeExperimentOption
A flag to control whether or not the model element reacts to before experiment actions.
-
myInitializationOption
protected boolean myInitializationOption
A flag to control whether or not the model element reacts to initialization actions
-
myBeforeReplicationOption
protected boolean myBeforeReplicationOption
A flag to control whether or not the model element reacts to before replication actions.
-
myMonteCarloOption
protected boolean myMonteCarloOption
A flag to control whether or not the model element participates in monte carlo actions.
-
myReplicationEndedOption
protected boolean myReplicationEndedOption
A flag to control whether or not the model element reacts to end replication actions.
-
myAfterReplicationOption
protected boolean myAfterReplicationOption
A flag to control whether or not the model element reacts to after replication actions.
-
myWarmUpOption
protected boolean myWarmUpOption
Specifies if this model element will be warmed up when the warmup action occurs for its parent.
-
myTimedUpdateOption
protected boolean myTimedUpdateOption
Specifies whether or not this model element participates in time update event specified by its parent
-
myAfterExperimentOption
protected boolean myAfterExperimentOption
A flag to control whether or not the model element reacts to after experiment actions.
-
myModelElements
protected java.util.List<ModelElement> myModelElements
A collection containing the first level children of this model element
-
myWarmUpActionListener
protected ModelElement.WarmUpEventAction myWarmUpActionListener
The action listener that reacts to the warm up event.
-
myWarmUpEvent
protected JSLEvent myWarmUpEvent
A reference to the warm up event
-
myWarmUpIndicator
protected boolean myWarmUpIndicator
Indicates whether or not the warm up action occurred sometime during the simulation. False indicates that the warm up action has not occurred
-
myWarmUpPriority
protected int myWarmUpPriority
Specifies the havingPriority of this model element's warm up event.
-
myLengthOfWarmUp
protected double myLengthOfWarmUp
The length of time from the start of the simulation to the warm up event.
-
myTimedUpdateActionListener
protected ModelElement.TimedUpdateEventAction myTimedUpdateActionListener
The action listener that reacts to the timed update event.
-
myTimedUpdateEvent
protected JSLEvent myTimedUpdateEvent
A reference to the TimedUpdate event.
-
myTimedUpdatePriority
protected int myTimedUpdatePriority
Specifies the havingPriority of this model element's timed update event.
-
myTimedUpdateInterval
protected double myTimedUpdateInterval
The time interval between TimedUpdate events. The default is zero, indicating no timed update
-
myObservableComponent
protected ObservableComponent myObservableComponent
Used to allow observers
-
-
Constructor Detail
-
ModelElement
public ModelElement(ModelElement parent)
Creates a model element carrying name "null" as a child element of the supplied parent- Parameters:
parent
- the parent
-
ModelElement
public ModelElement(ModelElement parent, java.lang.String name)
Creates a model element carrying the given name as a child element of the supplied parent. The defaults for a general model element are:before experiment option: true before replication option: true initialization option: true after replication option: true after experiment option: true timed update option: true batching option: true length of warm up = 0.0 // no warm up length of batch interval = 0.0 // no batch interval
- Parameters:
parent
- the parentname
- The name of the model element
-
-
Method Detail
-
setName
protected final void setName(java.lang.String str)
Sets the name of this model element- Parameters:
str
- The name as a string.
-
getModelElementsAsString
public final java.lang.String getModelElementsAsString()
Returns a string representation of the model element and its child model elements. Useful for realizing the model element hierarchy. <type> getClass().getSimpleName() <\type> <name> getName() <\name> child elements here, etc. </modelelement>- Returns:
- the model element as a string
-
getModelElementsAsString
public final void getModelElementsAsString(java.lang.StringBuilder sb)
Fills up the supplied StringBuilder carrying a string representation of the model element and its child model elements Useful for realizing the model element hierarchy. <modelelement> <type> getClass().getSimpleName() <\type> <name> getName() <\name> child elements here, etc. </modelelement>- Parameters:
sb
- will hold the model element as a StringBuilder
-
getModelElementsAsString
public final void getModelElementsAsString(java.lang.StringBuilder sb, int n)
Fills up the supplied StringBuilder carrying a string representation of the model element and its child model elements Useful for realizing the model element hierarchy. <modelelement> <type> getClass().getSimpleName() <\type> <name> getName() <\name> child elements here, etc. </modelelement>- Parameters:
sb
- to hold the model element as a stringn
- The starting level of indentation for the model elements
-
indent
protected final void indent(java.lang.StringBuilder sb, int n)
Add spaces representing the level of indention- Parameters:
sb
- holds the stuff to be indentedn
- level of indentation
-
getName
public final java.lang.String getName()
Gets this model element's name.- Specified by:
getName
in interfaceGetNameIfc
- Returns:
- The name of the model element.
-
getStringLabel
public final java.lang.String getStringLabel()
Gets the a string that can be used to label the model element By default it is the same as getName(), but can be changed via setStringLabel()- Returns:
- the label
-
setStringLabel
public final void setStringLabel(java.lang.String label)
Sets a string that can be used to label the model element- Parameters:
label
- the myLabel to set
-
getId
public final int getId()
Gets a uniquely assigned integer identifier for this model element. This identifier is assigned when the model element is created. It may vary if the order of creation changes.- Specified by:
getId
in interfaceIdentityIfc
- Returns:
- The identifier for the model element.
-
getTime
public final double getTime()
Gets the current simulated time relative to the starting time of the run.- Returns:
- The simulation time as a double
-
millisecond
public final double millisecond()
Returns the value of a 1 millisecond time interval in terms of the base time unit- Returns:
- the value of a 1 millisecond time interval in terms of the base time unit
-
second
public final double second()
Returns the value of a 1 second time interval in terms of the base time unit- Returns:
- Returns the value of a 1 second time interval in terms of the base time unit
-
minute
public final double minute()
Returns the value of a 1 minute time interval in terms of the base time unit. For example, if the time unit is set to hours, then minute() should return 0.0166 (TIME_UNIT_MINUTE/TIME_UNIT_HOUR)Thus, if base time unit is set to hours, then 5*minute() represents 5 minutes (5.0/60) and 2*day() represents 2 days. Use these methods to convert timeUnits to the base time unit when scheduling events or defining time parameters.
- Returns:
- Returns the value of a 1 minute time interval in terms of the base time unit.
-
hour
public final double hour()
Returns the value of a 1 hour time interval in terms of the base time unit- Returns:
- Returns the value of a 1 hour time interval in terms of the base time unit
-
day
public final double day()
Returns the value of a 1 day time interval in terms of the base time unit- Returns:
- Returns the value of a 1 day time interval in terms of the base time unit
-
week
public final double week()
Returns the value of a 1 week time interval in terms of the base time unit- Returns:
- Returns the value of a 1 week time interval in terms of the base time unit
-
getDefaultEntityType
protected EntityType getDefaultEntityType()
Returns a reference to the default entity type- Returns:
- Returns a reference to the default entity type
-
createQObject
protected final QObject createQObject()
A convenience method for creating QObjects- Returns:
- the created QObject carrying time properly set
-
createEntity
protected Entity createEntity()
Creates an instance of the DefaultEntityType- Returns:
- an entity of the default type
-
createEntity
protected Entity createEntity(java.lang.String name)
Creates an instance of the DefaultEntityType reactingWith the supplied name- Parameters:
name
- the name for the entity- Returns:
- the default entity type carrying the supplied name
-
getParentModelElement
public final ModelElement getParentModelElement()
Gets this model elements parent in the composite pattern, i.e. returns the model element that contains this model element.- Returns:
- The containing model element
-
getBeforeExperimentOption
public final boolean getBeforeExperimentOption()
Gets the before experiment flag that indicates whether or not this model element will participate in the default before experiment action controlled by its parent model element.- Returns:
- True means it participates, false means it that it does not.
-
setBeforeExperimentOption
public final void setBeforeExperimentOption(boolean flag)
Sets the before experiment option for this model element.- Parameters:
flag
- True means it participates.
-
setBeforeExperimentOptionForModelElements
public final void setBeforeExperimentOptionForModelElements(boolean flag)
Sets the before experiment option of all model elements (children) contained by this model element.- Parameters:
flag
- True means that they participate in setup.
-
getAfterExperimentOption
public final boolean getAfterExperimentOption()
Gets the after experiment flag that indicates whether or not this model element will participate in the default after experiment action controlled by its parent model element.- Returns:
- True means it participates, false means it that it does not.
-
setAfterExperimentOption
public final void setAfterExperimentOption(boolean flag)
Sets the after experiment option for this model element.- Parameters:
flag
- True means it participates.
-
setAfterExperimentOptionForModelElements
public final void setAfterExperimentOptionForModelElements(boolean option)
Sets the after experiment option of all model elements (children) contained by this model element.- Parameters:
option
- True means that they participate.
-
getBeforeReplicationOption
public final boolean getBeforeReplicationOption()
Gets the before replication flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.- Returns:
- True means it participates, false means it that it does not.
-
setBeforeReplicationOption
public final void setBeforeReplicationOption(boolean flag)
Sets the before replication flag for this model element.- Parameters:
flag
- True means it participates in the default action
-
setBeforeReplicationOptionForModelElements
public final void setBeforeReplicationOptionForModelElements(boolean flag)
Sets the before replication flag of all model elements (children) contained by this model element.- Parameters:
flag
- True means that they participate in the default action
-
getMonteCarloOption
public final boolean getMonteCarloOption()
Gets the monte carlo option flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.- Returns:
- True means it participates, false means it that it does not.
-
setMonteCarloOption
public final void setMonteCarloOption(boolean flag)
Sets the monte carlo option flag for this model element.- Parameters:
flag
- True means it participates in the default action
-
getUpdateNotificationFlag
public final boolean getUpdateNotificationFlag()
This flag indicates whether or not the notification of update observers will occur for this model element. Update notifications can be computationally intensive. By setting this flag to false, no update observers will be called.- Returns:
- Returns the updateNotificationFlag.
-
setUpdateNotificationFlag
public final void setUpdateNotificationFlag(boolean flag)
This flag indicates whether or not the notification of update observers will occur for this model element. Update notifications can be computationally intensive. By setting this flag to false, no update observers will be called.WARNING: Setting this flag to true on ResponseVariables and subclasses will essentially turn off statistical collection since statistical collection is done through update observers
- Parameters:
flag
- The updateNotificationFlag to set.
-
setMonteCarloOptionForModelElements
public final void setMonteCarloOptionForModelElements(boolean flag)
Sets the monte carlo option flag of all model elements (children) contained by this model element.- Parameters:
flag
- True means that they participate in the default action
-
getInitializationOption
public final boolean getInitializationOption()
Gets the initialization flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.- Returns:
- True means it participates, false means it that it does not.
-
setInitializationOption
public final void setInitializationOption(boolean flag)
Sets the initialization flag for this model element.- Parameters:
flag
- True means it participates in the default action
-
setInitializationOptionForModelElements
public final void setInitializationOptionForModelElements(boolean flag)
Sets the initialization option of all model elements (children) contained by this model element.- Parameters:
flag
- True means that they participate in the default action
-
getWarmUpOption
public final boolean getWarmUpOption()
Gets the warm up flag that indicates whether or not this model element will be warmed up when its parent warm up event/action occurs. The default value for all model elements is true. A value of true implies that the model element allows its parent's warm up event to call its warm up action. A value of false implies that the model element does not allow its parent's warm up event to call its warm up action. False does not necessarily mean that the model element will not be warmed up. It may, through the use of the setLengthOfWarmUp() method, have its own warm up event and action.- Returns:
- True means it will be warmed up by its parent model element, false means it that it will not be warmed up by its parent.
-
setWarmUpOption
public final void setWarmUpOption(boolean warmUpFlag)
Sets the warm up option flag for this model element. The warm up option flag indicates whether or not the model element will allow its parent model element to control its warm up event. That is, if the warm up option flag is true, the model element does not have its own warm up event and will be warmed up when its parent model element is warmed up. If the warm up option flag is false, the model element will either not participate at all in warm up events or will have its own warm up event defined through the use of the method setLengthOfWarmUp(). Setting the warm up option flag to false, without setting a warm up length for the model element, implies that the model element will not react to any warm up actions.- Parameters:
warmUpFlag
- True represents that the model element participates.
-
setWarmUpOptionForModelElements
public final void setWarmUpOptionForModelElements(boolean warmUpFlag)
Sets the warm up option flag of all model elements (children) contained by this model element.- Parameters:
warmUpFlag
- True means that they participate in the default action
-
isWarmedUp
public final boolean isWarmedUp()
Returns true if the warm up has occurred, false otherwise- Returns:
- true if the warm up has occurred, false otherwise
-
getTimedUpdateOption
public final boolean getTimedUpdateOption()
Gets the timed update flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.- Returns:
- True means it participates, false means it that it does not.
-
setTimedUpdateOption
public final void setTimedUpdateOption(boolean timedUpdateOption)
Sets the timed update option flag for this model element.- Parameters:
timedUpdateOption
- True means it participates in the default action
-
setTimedUpdateOptionForModelElements
public final void setTimedUpdateOptionForModelElements(boolean timedUpdateOption)
Sets the timed update option flag of all model elements (children) contained by this model element.- Parameters:
timedUpdateOption
- True means that they participate in the default action
-
getLengthOfWarmUp
public final double getLengthOfWarmUp()
Gets the length of the warm up for this model element. Each model element can have its own warm up length.- Returns:
- the the length of the warm up
-
setLengthOfWarmUp
public final void setLengthOfWarmUp(double lengthOfWarmUp)
Sets the length of the warm up for this model element.Setting the length of the warm up to 0.0 will set the warm up option flag to true.
This is based on the assumption that a zero length warm up implies that the model element's parent warm up event will take care of the warm up action. If this is not the case, then calling setWarmUpFlag(false) after setting the length of the warm up to 0.0, will cause the model element to not have a warmup.
In general, there is not a need to set the length of the warm up to zero unless the reactor is resetting the value after explicitly specifying it for a replication. The default value of the warm up length is zero. A zero length warm up will not cause a separate event to be scheduled. The default warm up flag option starts as true, which implies that the model element lets its parent's warm up event take care of its warm up action.
Setting the length of the warm up > 0.0, will set the warm up option flag to false.
Prior to each replication the specified warm up length will be checked to see if it is greater than zero. if the length of the warm up is greater than zero, it is checked to see if it is less than the simulation run length. If so, it is assumed that the model element wants its own warm up event scheduled. It is also assumed that the model element does not depend on its parent for a warm up action. The warm up option flag will be set to false and a separate warm up event will be scheduled for the model element.
- Parameters:
lengthOfWarmUp
- length of the warm up, must be >= 0.0
-
getWarmUpEventTime
public final double getWarmUpEventTime()
This method returns the planned time for the warm up for this model element- Returns:
- the planned time
-
isWarmUpEventScheduled
public final boolean isWarmUpEventScheduled()
Checks if a warm up event has been scheduled for this model element- Returns:
- True means that it has been scheduled.
-
isWarmUpScheduled
public final boolean isWarmUpScheduled()
Checks if a warm up event is scheduled for any model element directly above this model element in the hierarchy of model elements all the way until the top Model.True means that some warm up event is scheduled in the upward chain. False means that no warm up event is scheduled in the upward chain.
- Returns:
- true if any warm up event is scheduled in the upward chain
-
findModelElementWithWarmUpEvent
public final ModelElement findModelElementWithWarmUpEvent()
Find the first parent that has its own warm up event this guarantees that all elements below the found model element do not have their own warm up event. A model element that has its own warm up event also opts out of the warm up action. If the returned parent is the Model, then all are controlled by the model (unless they opt out). Elements can opt out and not have their own warm up event. Thus, they have no warm up at all.Null indicates that no model element in the parent chain has a warm up event.
- Returns:
- the element or null
-
checkWarmUpOption
public final boolean checkWarmUpOption()
Checks if this model element or any model element directly above this model element in the hierarchy of model elements all the way until the top Model participates in the warm up action.True means that this and every parent in the chain participates in the warm up action. False means this element or some parent does not participate in the warm up action
- Returns:
- true if this and every parent participates in the warm up action
-
cancelWarmUpEvent
public final void cancelWarmUpEvent()
Cancels the warm up event for this model element.
-
getTimedUpdateInterval
public final double getTimedUpdateInterval()
Gets the time between timed update events for this model element. If T is the length of the run, and n is the number of timed updates, then the timed update interval is T/n- Returns:
- The time between timed update events.
-
setTimedUpdateInterval
public final void setTimedUpdateInterval(double deltaT)
Used to set the length of the timed update interval.- Parameters:
deltaT
- timed update interval, must be >= 0.0
-
isTimedUpdateEventScheduled
public final boolean isTimedUpdateEventScheduled()
Checks if a timed update event has been scheduled for this model element- Returns:
- True means that it has been scheduled.
-
cancelTimedUpdateEvent
public final void cancelTimedUpdateEvent()
Cancels the timed update event for this model element.
-
getAfterReplicationOption
public final boolean getAfterReplicationOption()
Gets the after replication flag that indicates whether or not this model element will participate in the default action controlled by its parent model element.- Returns:
- True means it participates, false means it that it does not.
-
setAfterReplicationOption
public final void setAfterReplicationOption(boolean flag)
Sets the after replication flag for this model element.- Parameters:
flag
- True means it participates in the default action
-
setAfterReplicationOptionForModelElements
public final void setAfterReplicationOptionForModelElements(boolean flag)
Sets the after replication flag of all model elements (children) contained by this model element.- Parameters:
flag
- True means that they participate in the default action
-
getReplicationEndedOption
public final boolean getReplicationEndedOption()
Gets the end replication flag that indicates whether or not this model element will participate in the default action controlled by its parent model element. Determines whether or not the replicationEnded() method will be called- Returns:
- True means it participates, false means it that it does not.
-
setReplicationEndedOption
public final void setReplicationEndedOption(boolean flag)
Sets the end replication option flag for this model element. Determines whether or not the replicationEnded() method will be called- Parameters:
flag
- True means it participates in the default action
-
setReplicationEndedOptionForModelElements
public final void setReplicationEndedOptionForModelElements(boolean flag)
Sets the end replication option flag of all model elements (children) contained by this model element. Determines whether or not the replicationEnded() method will be called- Parameters:
flag
- True means that they participate in the default action
-
getNumberOfModelElements
public final int getNumberOfModelElements()
Gets the number of model elements contained by this model elements.- Returns:
- a count of the number of child elements.
-
getChildModelElementIterator
public final java.util.Iterator<ModelElement> getChildModelElementIterator()
Gets an iterator to the contained model elements.- Returns:
- an iterator over the child elements.
-
deleteObservers
public void deleteObservers()
Description copied from interface:ObservableIfc
Deletes all the observers from the observable- Specified by:
deleteObservers
in interfaceObservableIfc
-
deleteObserver
public void deleteObserver(ObserverIfc observer)
Description copied from interface:ObservableIfc
Allows the deletion (removing) of an observer from the observable- Specified by:
deleteObserver
in interfaceObservableIfc
- Parameters:
observer
- the observer to delete
-
contains
public boolean contains(ObserverIfc observer)
Description copied from interface:ObservableIfc
Returns true if the observer is already attached- Specified by:
contains
in interfaceObservableIfc
- Parameters:
observer
- the observer to check- Returns:
- true if attached
-
countObservers
public int countObservers()
Description copied from interface:ObservableIfc
Returns how many observers are currently observing the observable- Specified by:
countObservers
in interfaceObservableIfc
- Returns:
- number of observers
-
addObserver
public void addObserver(ObserverIfc observer)
Description copied from interface:ObservableIfc
Allows the adding (attaching) of an observer to the observable- Specified by:
addObserver
in interfaceObservableIfc
- Parameters:
observer
- the observer to attach
-
addObserverToModelElements
public final void addObserverToModelElements(ObserverIfc o)
Adds an observer to this model element. Every model element implements the Observer interface and thus can be observed at particular state actions.- Parameters:
o
- observer to be added.
-
deleteObserverFromModelElements
public final void deleteObserverFromModelElements(ObserverIfc o)
Removes the observer from this model element.- Parameters:
o
- The observer to be removed.
-
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 classjava.lang.Object
- Returns:
- a string representing the model element
-
asString
public java.lang.String asString()
Allows sub-classes to provide more detail than toString() to represent the ModelElement as a String- Returns:
- a detailed String representation
-
getObserverState
public final int getObserverState()
Returns an integer representing the state of the model element This can be used by Observers to find out which action occurred for the model element- Returns:
- The state of the model element
-
getPreviousObserverState
public final int getPreviousObserverState()
Returns an integer representing the previous state of the model element This can be used by Observers to find out which action occurred prior to the current state change for the model element- Returns:
- The state of the model element
-
checkObserverState
public final boolean checkObserverState(int observerState)
Checks to see if the model element is in the given observer state. This method can be used by observers that are interested in reacting to the action associated carrying this state for the model element.BEFORE_EXPERIMENT beforeExperiment() INITIALIZED initialize() BEFORE_REPLICATION beforeReplication() MONTE_CARLO monte carlo() REPLICATION_ENDED replicationEnded() AFTER_REPLICATION afterReplication() UPDATE update() WARMUP warmUp() TIMED_UPDATE timedUpdate() AFTER_EXPERIMENT afterExperiment() BATCH batch() CONDITIONAL_ACTION_REGISTRATION registerConditionalActions()
- Parameters:
observerState
- The state to check- Returns:
- True means that this model element's corresponding action method has been invoked and that it is in the given state.
-
checkForBeforeExperiment
public final boolean checkForBeforeExperiment()
Checks to see if the model element is in the setup state. That is, has the setup action been invoked. This method can be used by observers that are interested in reacting to the setup action for the model element.- Returns:
- True means that this model element's setup method has been invoked and that it is in the setup state.
-
checkForInitialize
public final boolean checkForInitialize()
Checks to see if the model element is in the initialize state. That is, has the initialize action been invoked. This method can be used by observers that are interested in reacting to the initialize action for the model element.- Returns:
- True means that this model element's initialize method has been invoked and that it is in the initialized state.
-
checkForMonteCarlo
public final boolean checkForMonteCarlo()
Checks to see if the model element is in the monte carlo state. That is, has the monte carlo action been invoked. This method can be used by observers that are interested in reacting to the monte carlo action for the model element.- Returns:
- True means that this model element's monte carlo method has been invoked and that it is in the monte carlo state.
-
checkForBeforeReplication
public final boolean checkForBeforeReplication()
Checks to see if the model element is in the before replication state. That is, has the before replication action been invoked. This method can be used by observers that are interested in reacting to the before replication action for the model element.- Returns:
- True means that this model element's before replication method has been invoked and that it is in the before replication state.
-
checkForAfterReplication
public final boolean checkForAfterReplication()
Checks to see if the model element is in the after replication state. That is, has the after replication action been invoked. This method can be used by observers that are interested in reacting to the after replication action for the model element.- Returns:
- True means that this model element's after replication method has been invoked and that it is in the after replication state.
-
checkForReplicationEnded
public final boolean checkForReplicationEnded()
Checks to see if the model element is in the replication ended state. That is, has the replication ended action been invoked. This method can be used by observers that are interested in reacting to the replication ended action for the model element.- Returns:
- True means that this model element's replicationEnded() method has been invoked and that it is in the replication ended state.
-
checkForUpdate
public final boolean checkForUpdate()
Checks to see if the model element is in the update state. That is, has the notifyUpdateObservers been invoked. This method can be used by observers that are interested in reacting to the update action for the model element.- Returns:
- True means that this model element is in the update state.
-
checkForWarmUp
public final boolean checkForWarmUp()
Checks to see if the model element is in the warm up state. That is, has the warm up action been invoked. This method can be used by observers that are interested in reacting to the warm up action for the model element.- Returns:
- True means that this model element has experienced a warm up action
-
checkForTimedUpdate
public final boolean checkForTimedUpdate()
Checks to see if the model element is in the timed update state. That is, has the timed update action been invoked. This method can be used by observers that are interested in reacting to the timed update action for the model element.- Returns:
- True means that this model element has experienced a timed update action
-
checkForAfterExperiment
public final boolean checkForAfterExperiment()
Checks to see if the model element is in the end simulation state. That is, has the end simulation action been invoked. This method can be used by observers that are interested in reacting to the end simulation action for the model element.- Returns:
- True means that this model element has experienced an end of simulation action
-
checkForRemoveFromModel
public final boolean checkForRemoveFromModel()
Checks to see if the model element just been removed from the model This method can be used by observers that are interested in reacting to when a model element is removed from a model- Returns:
- True means that this model element has just been removed from a model
-
checkForConditionalActionRegistration
public final boolean checkForConditionalActionRegistration()
Checks to see if the model element has just called, registerConditionalActions()- Returns:
- True means that this model element has just called registerConditionalActions()
-
getVariable
public Variable getVariable(java.lang.String variableKey)
Gets the variable carrying the name given by the string provided- Parameters:
variableKey
- the name of the variable- Returns:
- The Variable carrying the given name
-
setObserverState
protected final void setObserverState(int observerState)
- Parameters:
observerState
- The myObserverState to set.
-
getInitializationOrderAsString
public final void getInitializationOrderAsString(java.lang.StringBuilder sb)
Fills a StringBuilder carrying the model element names in the order that they will be initialized- Parameters:
sb
- the StringBuilder to fill
-
getAllResponseVariables
protected final void getAllResponseVariables(java.util.Collection<ResponseVariable> c)
Fills up the provided collection carrying all of the response variables that are contained by any model elements within this model element. In other words, any response variables that are in the model element hierarchy below this model element.- Parameters:
c
- The collection to be filled.
-
getThisElementsResponseVariables
protected final void getThisElementsResponseVariables(java.util.Collection<ResponseVariable> c)
Fills up the provided collection carrying the response variables that are contained only by this model element- Parameters:
c
- The collection to be filled.
-
getAllCounters
protected final void getAllCounters(java.util.Collection<Counter> c)
Fills up the provided collection carrying all of the Counters that are contained by any model elements within this model element. In other words, any Counters that are in the model element hierarchy below this model element.- Parameters:
c
- The collection to be filled.
-
getThisElementsCounters
protected final void getThisElementsCounters(java.util.Collection<Counter> c)
Fills up the provided collection carrying the Counters that are contained only by this model element- Parameters:
c
- The collection to be filled.
-
getAllRandomElements
protected final void getAllRandomElements(java.util.Collection<RandomElementIfc> c)
Fills up the provided collection carrying all of the RandomElementIfc and subclasses of RandomElementIfc that are contained by any model elements within this model element. In other words, any RandomElementIfc that are in the model element hierarchy below this model element.- Parameters:
c
- The collection to be filled.
-
getThisElementsRandomVariables
protected final void getThisElementsRandomVariables(java.util.Collection<RandomVariable> c)
Fills up the provided collection carrying only the random variables associated carrying this element- Parameters:
c
- The collection to be filled.
-
getThisElementsVariables
protected final void getThisElementsVariables(java.util.Collection<Variable> c)
Fills up the provided collection carrying only the variables associated carrying this element- Parameters:
c
- The collection to be filled.
-
getAllVariables
protected final void getAllVariables(java.util.Collection<Variable> c)
Fills up the provided collection carrying all of the variables that are contained by any model elements within this model element. In other words, any variables that are in the model element hierarchy below this model element.- Parameters:
c
- The collection to be filled.
-
getAllModelElements
protected final void getAllModelElements(java.util.List<ModelElement> list)
Gets all model elements that are contained within this model element in parent-child order within the hierarchy- Parameters:
list
- the list to fill
-
getThisElementsModelElements
protected final void getThisElementsModelElements(java.util.List<ModelElement> list)
A list containing the (child) model elements of only this model element- Parameters:
list
- the list of model elements
-
useControls
protected void useControls()
This method should be implemented by subclasses that need to use Controls prior to an experiment being run. The instance variable myControls should be set by a client and then can be used in this method to properly assign the values from the controls to the inner state of the model element
-
beforeExperiment
protected void beforeExperiment()
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.
-
initialize
protected void initialize()
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
-
registerConditionalActions
protected void registerConditionalActions(Executive e)
This method should be overridden by subclasses that need to register conditional actions prior to a replication. It is called once before each replication, right after the initialize() method is called.- Parameters:
e
- provides access to the executive
-
beforeReplication
protected void beforeReplication()
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.
-
montecarlo
protected void montecarlo()
This method should be overridden by subclasses that need actions performed after before replication. It is called after beforeReplication but prior to afterReplication() and can be used to perform pure monte-carlo (non event type) simulations carrying the model element
-
warmUp
protected void warmUp()
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.
-
timedUpdate
protected void timedUpdate()
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.
-
replicationEnded
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() . It is called when each replication ends and can be used to collect data from the the model element, etc.
-
afterReplication
protected void afterReplication()
This method should be overridden by subclasses that need actions performed after each replication. It is called after replicationEnded() has been called.
-
afterExperiment
protected void afterExperiment()
This method should be overridden by subclasses that need actions performed after an experiment has been completed It is called after all replications are done and can be used to collect data from the the model element, etc.
-
removedFromModel
protected void removedFromModel()
This method should be overridden by subclasses that need actions performed when a model element is removed from a model
-
notifyObservers
protected final void notifyObservers(int observerState, java.lang.Object arg)
Used to notify observers that this model element has entered the given state. Valid values for observerState include:BEFORE_EXPERIMENT INITIALIZED BEFORE_REPLICATION MONTE_CARLO REPLICATION_ENDED AFTER_REPLICATION UPDATE WARMUP TIMED_UPDATE AFTER_EXPERIMENT CONDITIONAL_ACTION_REGISTRATION
- Parameters:
observerState
- the state as an integerarg
- an object for notification
-
notifyObservers
protected final void notifyObservers(int observerState)
-
notifyBeforeExperimentObservers
protected final void notifyBeforeExperimentObservers()
The method is used to notify observers that this model element has entered the setup state.
-
notifyBeforeReplicationObservers
protected final void notifyBeforeReplicationObservers()
The method is used to notify observers that this model element has entered the before replication state.
-
notifyInitializationObservers
protected final void notifyInitializationObservers()
The method is used to notify observers that this model element has entered the initialized state.
-
notifyMonteCarloObservers
protected final void notifyMonteCarloObservers()
The method is used to notify observers that this model element has entered the monte carlo state.
-
notifyReplicationEndedObservers
protected final void notifyReplicationEndedObservers()
The method is used to notify observers that this model element has entered the after replication state.
-
notifyAfterReplicationObservers
protected final void notifyAfterReplicationObservers()
The method is used to notify observers that this model element has entered the after replication state.
-
notifyWarmUpObservers
protected final void notifyWarmUpObservers()
The method is used to notify observers that this model element has entered the warmup update state.
-
notifyTimedUpdateObservers
protected final void notifyTimedUpdateObservers()
The method is used to notify observers that this model element has entered the timed update state.
-
notifyUpdateObservers
protected void notifyUpdateObservers()
The method is used to notify observers that this model element has been updated.
-
notifyAfterExperimentObservers
protected final void notifyAfterExperimentObservers()
This method is used to notify observers that this model element has entered the end of simulation state.
-
notifyRemovingFromModelObservers
protected final void notifyRemovingFromModelObservers()
This method is used to notify observers that this model element has been removed from a model
-
notifyConditionalActionRegistrationObservers
protected final void notifyConditionalActionRegistrationObservers()
This method is used to notify observers that this model element has called registerConditionalActions()
-
clearModelElementObservers
protected final void clearModelElementObservers()
Causes the model element to delete any observers that had been added
-
beforeExperiment_
protected final void beforeExperiment_()
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 within the experiment. This method ensures that each contained model element has its beforeExperiment method called and that any observers will be notified of this action
-
beforeReplication_
protected final void beforeReplication_()
The beforeReplication_ method is called before each replication. This method ensures that each contained model element is initialized and performs default actions for all model elements.
-
initialize_
protected void initialize_()
The initialize_ method allows model elements to be initialized to a standard reactor defined state. It is called by default before each replicationThis method ensures that each contained model element has its initialize method called and that any observers will be notified of this action
-
registerConditionalActions_
protected final void registerConditionalActions_(Executive e)
The registerConditionalActions_ method allows model elements to be register any conditional actions after initialization.It is called by default before each replication, right after the initialize() method is invoked
This method ensures that each contained model element has its registerConditionalActions() method called and that any observers will be notified of this action
- Parameters:
e
- provides access to the Executive
-
montecarlo_
protected final void montecarlo_()
The monte carlo_ method facilitates model elements to perform a monte carlo simulation carrying no events being called. It is called by default after beginReplication_() and initialize_().This method ensures that each contained model element has its monte carlo method called and that any observers will be notified of this action
-
warmUp_
protected void warmUp_()
The warmUp_ method is called once during each replication. This method ensures that each contained model element that requires a warm up action will performs its actions.
-
timedUpdate_
protected final void timedUpdate_()
The timedUpdate_ method is called multiple times during each replication. This method ensures that each contained model element that requires a timed update action will performs its actions.
-
replicationEnded_
protected final void replicationEnded_()
The replicationEnded_ method is called when a replication ends This method ensures that each contained model element that requires a end of replication action will performs its actions.
-
afterReplication_
protected final void afterReplication_()
The afterReplication_ method is called at the end of each replication. This method ensures that each contained model element that requires a end of replication action will performs its actions.
-
afterExperiment_
protected final void afterExperiment_()
The afterExperiment_ method is called after all replications are completed for an experiment. This method ensures that each contained model element that requires an action at the end of an experiment will perform its actions.
-
update
protected final void update()
The update method can be called at reactor defined points to indicate that the model element has been changed in some fashion that the update observers need notification. This method ensures that each contained model element that requires an update action will performs its actions.
-
getModel
public final Model getModel()
Gets the main model. The container of all model elements.- Returns:
- The main model.
-
getCurrentReplicationNumber
public final int getCurrentReplicationNumber()
Returns the current replication number.- Returns:
- the current replication number.
-
getSpatialModel
public final SpatialModel getSpatialModel()
Gets the spatial model that this ModelElement is currently reactingWith if it exists- Returns:
- the spatial model that this ModelElement is currently reactingWith if it exists
-
setSpatialModel
protected final void setSpatialModel(SpatialModel spatialModel)
Sets the spatial model for this ModelElement Note: Any ModelElements that are children of this ModelElement do not have their SpatialModels changed.- Parameters:
spatialModel
- the spatial model for this ModelElement
-
getExecutive
public Executive getExecutive()
Returns a reference to the Executive or null. The reference to the Executive will only be available after the Simulation is initialized.- Returns:
- a reference to the Executive or null.
-
stopExecutive
public final void stopExecutive(java.lang.String msg)
Tells the Executive to stop executing events- Parameters:
msg
- a stopping withMessage
-
stopExecutive
public final void stopExecutive()
Tells the Executive to stop executing events
-
getExperiment
public ExperimentGetIfc getExperiment()
Returns a reference to the Experiment or null. The reference to the Experiment will only be available after the Simulation is initialized.- Returns:
- a reference to the Experiment or null.
-
getSimulation
public Simulation getSimulation()
Returns a reference to the Simulation that contains the model that contains this ModelElement- Returns:
- a reference to the Simulation
-
setModel
protected final void setModel(Model model)
Sets the model attribute for this element- Parameters:
model
- The model for this element
-
setParentModelElement
protected final void setParentModelElement(ModelElement parent)
Sets the parent element to the supplied value- Parameters:
parent
- the parent element to the supplied value
-
changeParentModelElement
public final ModelElement changeParentModelElement(ModelElement newParent)
Changes the parent model element for this model element to the supplied value. This will1) remove this element from its parent's list of child model elements 2) add this element to its new parent's list of child model elements 3) ensure that the moved model elements are all in the same model 4) return the model element's old parent
- Parameters:
newParent
- The new parent for this model element- Returns:
- The old (previous) parent for this model element
-
removeFromModel
public final void removeFromModel()
Recursively removes this model element and the children of this model element and all their children, etc. The children will no longer have a parent and will no longer have a model. This can only be done when the simulation that contains the model is not running. This method has very serious side-effects. After invoking this method: 1) All children of this model element will have been removed from the model. 2) This model element will be removed from its parent's model, element list and from the model. The getParentModelElement() method will return null. In other words, this model element will no longer be connected to a parent model element. 3) This model element and all its children will no longer be connected. In other words, there is no longer a parent/child relationship between this model element and its former children. 4) This model element and all of its children will no longer belong to a model. Their getModel() method will return null 5) The removed elements are no longer part of their former model's model element map 6) The name and label are set to null 7) Warm up and timed update listeners are set to null 9) Any reference to a spatial model is set to null 10) All observers of this model element are detached 11) All child model elements are removed. It will no longer have any children. Since it has been removed from the model, it and its children will no longer participate in any of the standard model element actions, e.g. initialize(), afterReplication(), etc.Notes: 1) This method removes from the list of model elements. Thus, if a client attempts to use this method, via code that is iterating the list a concurrent modification exception will occur. 2) The user is responsible for ensuring that other references to this model element are correctly handled. If references to this model element exist within other data structures/collections then the user is responsible for appropriately addressing those references. This is especially important for any observers of the removed model element. The observers will be notified that the model element is being removed. It is up to the observer to correctly react to the removal. If the observer is a sub-class of ModelElementObserver then implementing the removedFromModel() method can be used. If the observer is a general Observer, then use REMOVED_FROM_MODEL to check if the element is being removed.
-
schedule
protected final <T> ModelElement.EventBuilderIfc<T> schedule(EventActionIfc<T> action)
Creates an EventScheduler which can be used to create and schedule events on the simulation calendar reactingWith a fluency pattern.- Type Parameters:
T
- if the event has a message, this is the type- Parameters:
action
- the action to be invoked at the event time- Returns:
- the builder of the event
-
buildEventGenerator
protected final EventGenerator.ActionStepIfc buildEventGenerator()
Allows easy building of an EventGenerator- Returns:
- the building step
-
seize
protected final ModelElement.RequestUsingIfc seize(ResourceUnit resource)
-
getModelElementCompartor
public static final java.util.Comparator<ModelElement> getModelElementCompartor()
- Returns:
- a comparator that compares based on getId()
-
getLeftPreOrderTraversalCount
public final int getLeftPreOrderTraversalCount()
- Returns:
- the left traversal count label in a pre-order traversal of the model element hierarchy for this model element based on the Model as the root node (label = 1)
-
getRightPreOrderTraversalCount
public final int getRightPreOrderTraversalCount()
- Returns:
- the right traversal count label in a pre-order traversal of the model element hierarchy for this model element based on the Model as the root node (label = 1)
-
-