Class Model

    • Field Detail

      • MODEL_ELEMENT_ADDED

        public static final int MODEL_ELEMENT_ADDED
        An "enum" to indicate that the model element was added to the model element hierarchy
      • MODEL_ELEMENT_REMOVED

        public static final int MODEL_ELEMENT_REMOVED
        An "enum" to indicate that the model element was removed from the model element hierarchy
      • myResponseVariables

        protected java.util.List<ResponseVariable> myResponseVariables
        A list of all the response variables (including TimeWeighted) within the model
      • myCounters

        protected java.util.List<Counter> myCounters
        A list of all the Counters within the model
      • myVariables

        protected java.util.List<Variable> myVariables
        A list of all the Variables within the model
      • myRandomElements

        protected java.util.List<RandomElementIfc> myRandomElements
        A list of all random elements within the model
    • Constructor Detail

      • Model

        protected Model​(java.lang.String name)
        Constructs a model called "name"
        Parameters:
        name - The name of the model
    • Method Detail

      • getNextEnumConstant

        public static int getNextEnumConstant()
        Should be used by subclasses to get the next constant so that unique constants can be used
        Returns:
        the constant
      • getTimeUnit

        public final double getTimeUnit()
        Returns the current time unit. The default is the number of milliseconds in one time unit. So, if you do not use setTimeUnit(), then this method will return 1.0.
        Returns:
        the time unit addFactor
      • setTimeUnit

        public final void setTimeUnit​(double timeUnit)
        sets the time unit to a given number of milliseconds (tu). If you are setting a standard time unit, you can use a time constant from ModelElement.
        Parameters:
        timeUnit - the time unit addFactor
      • getVariable

        public final Variable getVariable​(java.lang.String name)
        Returns the variable associated with the name or null if named element is not in the model. Note that this will also return ANY instances of subclasses of Variable
        Overrides:
        getVariable in class ModelElement
        Parameters:
        name - The name of the Variable model element
        Returns:
        the associated variable, may be null if provided name does not exist in the model
      • getRandomVariable

        public final RandomVariable getRandomVariable​(java.lang.String name)
        Returns the random variable associated with the name or null if named element is not in the model. Note that this will also return ANY instances of subclasses of RandomVariable
        Parameters:
        name - The name of the RandomVariable model element
        Returns:
        the associated random variable, may be null if provided name does not exist in the model
      • getRandomVariables

        public final java.util.List<RandomVariable> getRandomVariables()
        Returns:
        a list containing all RandomVariables within the model
      • turnOnRandomVariableResponseCapture

        public final void turnOnRandomVariableResponseCapture()
        Turns on RandomVariable response capture for all RandomVariables in the model
      • getResponseVariable

        public final ResponseVariable getResponseVariable​(java.lang.String name)
        Returns the response variable associated with the name or null if named element is not in the model. Note that this will also return ANY instances of subclasses of ResponseVariable (i.e. including TimeWeighted)
        Parameters:
        name - The name of the ResponseVariable model element
        Returns:
        the associated ResponseVariable, may be null if provided name does not exist in the model
      • getTimeWeighted

        public final TimeWeighted getTimeWeighted​(java.lang.String name)
        Returns the time weighted variable associated with the name or null if named element is not in the model. Note that this will also return ANY instances of subclasses of TimeWeighted
        Parameters:
        name - The name of the TimeWeighted model element
        Returns:
        the associated TimeWeighted, may be null if provided name does not exist in the model
      • getAcrossReplicationResponseVariable

        public final AcrossReplicationStatisticIfc getAcrossReplicationResponseVariable​(java.lang.String name)
        Gets the AcrossReplicationStatisticIfc for the provided name. If there is no response variable with the provided name then null is returned.
        Parameters:
        name - name of response variable in the model, must not be null
        Returns:
        the associated across replication statistic information, may be null if provided name does not exist in the model
      • getCounter

        public final Counter getCounter​(java.lang.String name)
        Returns the Counter associated with the name or null if named element is not in the model.
        Parameters:
        name - The name of the Counter model element
        Returns:
        the associated counter, may be null if provided name does not exist in the model
      • getListOfAcrossReplicationStatistics

        public final java.util.List<StatisticAccessorIfc> getListOfAcrossReplicationStatistics()
        The responses as a list of StatisticAccessorIfc
        Returns:
        a list of response variables and counters
      • turnOnTimeIntervalCollection

        public final void turnOnTimeIntervalCollection​(double interval)
        Turns on the collection of statistics across intervals of time, defined by the interval length for all response variables (including TimeWeighted) and counters
        Parameters:
        interval - the interval
      • containsModelElement

        public final boolean containsModelElement​(java.lang.String modelElementName)
        Checks to see if the model element has been registered with the Model using it's uniquely assigned name.
        Parameters:
        modelElementName - the name of the model element to check
        Returns:
        true if contained
      • getModelElement

        public final ModelElement getModelElement​(java.lang.String name)
        Returns the model element associated with the name. In some sense, this model violates encapsulation for ModelElements, but since the client knows the unique name of the ModelElement, we assume that the client knows what he/she is doing.
        Parameters:
        name - The name of the model element, the name must not be null
        Returns:
        The named ModelElement if it exists in the model by the supplied name, null otherwise
      • getModelElement

        public final ModelElement getModelElement​(int id)
        Returns the model element that has the provided unique id or null if not found
        Parameters:
        id - the identifier getId() of the desired ModelElement
        Returns:
        the ModelElement
      • getVariables

        public final void getVariables​(java.util.Collection<Variable> c)
        Gets all instances of the Variable class within the model hierarchy. Only Variable objects (not its subclasses)
        Parameters:
        c - a Collection to hold the instances of Variable found
      • getVariables

        public final java.util.List<Variable> getVariables()
        Returns an unmodifiable collection holding all the Variables within the Model. The list is unchangeable, but the elements in the list can be still be accessed and changed as necessary
        Returns:
        An unmodifiable List of the variables
      • getRandomElements

        public final void getRandomElements​(java.util.Collection<RandomElementIfc> c)
        Gets all instances of the RandomElementIfc interface within the model hierarchy. All instances of RandomElementIfc will be returned including any instances of subclasses of RandomElementIfc
        Parameters:
        c - a Collection to hold the instances of RandomElementIfc found
      • getRandomElements

        public final java.util.List<RandomElementIfc> getRandomElements()
        Returns an unmodifiable collection holding all the RandomElementIfc within the Model. The list is unchangeable, but the elements in the list can be still be accessed and changed as necessary
        Returns:
        An unmodifiable List of the RandomElementIfc
      • turnOnAntithetic

        public final void turnOnAntithetic()
        Causes RandomElementIfc that have been added to the model to immediately turn on their antithetic generating streams.
      • turnOffAntithetic

        public final void turnOffAntithetic()
        Causes RandomElementIfc that have been added to the model to immediately turn off their antithetic generating streams.
      • advanceSubstreams

        public final void advanceSubstreams​(int n)
        Advances the streams of all RandomElementIfc n times. If n <= 0, no advancing occurs
        Parameters:
        n - the number of times to advance
      • advanceToNextSubstream

        public final void advanceToNextSubstream()
        Causes RandomElementIfc that have been added to the model to immediately advance their random number streams to the next substream in their stream.
      • resetStartStream

        public final void resetStartStream()
        Causes RandomElementIfc that have been added to the model to immediately reset their random number streams to the beginning of their starting stream.
      • resetStartSubStream

        public final void resetStartSubStream()
        Causes RandomElementIfc that have been added to the model to immediately reset their random number streams to the beginning of their current sub stream.
      • getResponseVariables

        public final void getResponseVariables​(java.util.Collection<ResponseVariable> c)
        Fills up the provided collection with all of the response variables that are contained by any model elements within the model. In other words, any response variables (and subclasses, e.g. TimeWeighted that are in the model element hierarchy below the model.
        Parameters:
        c - The collection to be filled.
      • getResponseVariables

        public final java.util.List<ResponseVariable> getResponseVariables()
        Returns an unmodifiable collection holding all the ResponseVariables within the Model. The list is unchangeable, but the elements in the list can still be accessed and changed as necessary
        Returns:
        An unmodifiable List of the variables
      • getResponseVariableNames

        public final java.util.List<java.lang.String> getResponseVariableNames()
        Returns a list of strings with each element being the unique model element name for the ResponseVariables within the model
        Returns:
        the list of response variable names
      • getCounters

        public final void getCounters​(java.util.Collection<Counter> c)
        Fills up the provided collection with all of the Counters that are contained by any model elements within the model. In other words, any Counters that are in the model element hierarchy below the model.
        Parameters:
        c - The collection to be filled.
      • getCounters

        public final java.util.List<Counter> getCounters()
        Returns an unmodifiable collection holding all the Counters within the Model. The list is unchangeable, but the elements in the list can be still be accessed and changed as necessary
        Returns:
        An unmodifiable List of the Counters
      • getCounterNames

        public final java.util.List<java.lang.String> getCounterNames()
        Returns a list of strings with each element being the unique model element name for the Counters within the model
        Returns:
        list of strings
      • addModelElementObserver

        public final boolean addModelElementObserver​(java.lang.String name,
                                                     ObserverIfc observer)
        Adds the supplied observer to the ModelElement with the given name. While any model element can be observed the client needs a reference to tell the model element to add an observer. This method provides way to add observers to any ModelElement regardless of where it is in the model hierarchy, provided the client knows the unique name of the ModelElement.
        Parameters:
        name - The name of the model element
        observer - The observer of the named model element
        Returns:
        If this method returns false, then no such named model element exists in the Model
      • deleteModelElementObserver

        public final boolean deleteModelElementObserver​(java.lang.String name,
                                                        ObserverIfc observer)
        Removes the supplied observer from the ModelElement with the given name. While any model element can be observed the client needs a reference to tell the model element to remove an observer. This method provides way to remove observers from any ModelElement regardless of where it is in the model hierarchy, provided the client knows the unique name of the ModelElement.
        Parameters:
        name - The name of the model element
        observer - The observer of the named model element
        Returns:
        If this method returns false, then no such named model element exists in the Model
      • getModelElementIterator

        public final java.util.Iterator<ModelElement> getModelElementIterator()
        Returns an Iterator to all the ModelElements registered inside this model
        Returns:
        a model element iterator
      • getModelElements

        public final java.util.List<ModelElement> getModelElements()
        The list is ordered parent-child, in the order of the model element hierarchy
        Returns:
        all of the model elements in the model as a List
      • setSpatialModelForAllElements

        public final void setSpatialModelForAllElements​(SpatialModel model)
        This method can be used to ensure that all model elements within the model use the same spatial model
        Parameters:
        model - the spatial model
      • getAutoRemoveMarkedElementsOption

        public final boolean getAutoRemoveMarkedElementsOption()
        Indicates whether or not the model will automatically remove elements that are marked for removal prior to each replication. The default is false.
        Returns:
        the option true if auto remove option is on
      • setAutoRemoveMarkedElementsOption

        public final void setAutoRemoveMarkedElementsOption​(boolean flag)
        Sets the option for the model to automatically remove elements that are marked for removal prior to each replication. False means elements will not be automatically removed. True means that they will automatically be removed.
        Parameters:
        flag - the flag to indicate the option
      • getElementAddedAfterReplicationStartedWarningOption

        public final boolean getElementAddedAfterReplicationStartedWarningOption()
        If a model element is added to the model after a replication has started this is likely to be a conceptual error. A warning message will be printed to the console in this case. The user can turn off this warning message by setting this flag to false. The default is true.
        Returns:
        the option true means option is on
      • setElementAddedAfterReplicationStartedWarningOption

        public final void setElementAddedAfterReplicationStartedWarningOption​(boolean flag)
        If a model element is added to the model after a replication has started this is likely to be a conceptual error. A warning message will be printed to the console in this case. The user can turn off this warning message by setting this flag to false. The default is true.
        Parameters:
        flag - true turns off this potential warning
      • setAllRVResetStartStreamOptions

        protected final void setAllRVResetStartStreamOptions​(boolean option)
        Sets the reset start stream option for all RandomElementIfc in the model to the supplied value, true is the default behavior. This method is used by an experiment prior to beforeExperiment_() being called Thus, any RandomElementIfc must already have been created and attached to the model elements
        Parameters:
        option - The option, true means to reset prior to each experiment
      • setAllRVResetNextSubStreamOptions

        protected final void setAllRVResetNextSubStreamOptions​(boolean option)
        Sets the reset next sub stream option for all RandomElementIfc in the model to the supplied value, true is the default behavior. True implies that the substreams will be advanced at the end of the replication. This method is used by an experiment prior to beforeExperiment_() being called Thus, any RandomElementIfc must already have been created and attached to the model elements
        Parameters:
        option - The option, true means to reset prior to each replication
      • addModelElementAndChildrenToModelElementMap

        protected final void addModelElementAndChildrenToModelElementMap​(ModelElement element)
        Used by ModelElement to assist with changing the model element's parent. This method ensures that the model has model element and its children registered in its map after the change.
        Parameters:
        element - the element to add
      • getDefaultEntityType

        protected final EntityType getDefaultEntityType()
        Returns a reference to the default entity type
        Overrides:
        getDefaultEntityType in class ModelElement
        Returns:
        the default entity type
      • getSimulation

        public final Simulation getSimulation()
        Returns a reference to the Simulation that contains this Model
        Overrides:
        getSimulation in class ModelElement
        Returns:
        the Simulation
      • isRunning

        public final boolean isRunning()
        Returns true if the executive is running, false if it is not running or if the model is not yet part of a simulation.
        Returns:
        true means running
      • getExperiment

        public final ExperimentGetIfc getExperiment()
        Returns a reference to the Experiment or null. The reference to the Experiment will only be available after the Simulation is initialized.
        Overrides:
        getExperiment in class ModelElement
        Returns:
        the experiment handle
      • setUpExperiment

        protected void setUpExperiment()
        Called from Simulation.ReplicationExecutionProcess.initializeIterations() Represents what to do to set up an experiment
      • setUpReplication

        protected void setUpReplication()
      • afterReplication

        protected void afterReplication​(Experiment e)
      • afterExperiment

        protected void afterExperiment​(Experiment e)