Class Variable

    • Field Detail

      • myLowerLimit

        protected double myLowerLimit
        Represents the lowest possible value allowed for this variable Attempts to set the value of the variable to < myLowerLimit will throw an exception
      • myUpperLimit

        protected double myUpperLimit
        Represents the lowest possible value allowed for this variable Attempts to set the value of the variable to > myUpperLimit will throw an exception
      • myValue

        protected double myValue
        The value of the variable.
      • myInitialValue

        protected double myInitialValue
        Holds the initial value of the variable.
      • myPrevValue

        protected double myPrevValue
        The previous value of the variable.
      • myNextValue

        protected double myNextValue
        The next value of the variable.
      • myTimeOfChange

        protected double myTimeOfChange
        The time that the variable changed
      • myPrevTimeOfChange

        protected double myPrevTimeOfChange
        The previous time that the variable changed
      • myWeight

        protected double myWeight
        The weight associated with the change
      • myVariableTraceTextReport

        protected VariableTraceTextReport myVariableTraceTextReport
        Holds a reference to an observer that will trace the variable's changes
    • Constructor Detail

      • Variable

        public Variable​(ModelElement parent)
        Creates a Variable with the given parent with initial value 0.0 over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]
        Parameters:
        parent - the variable's parent model element.
      • Variable

        public Variable​(ModelElement parent,
                        double initialValue)
        Creates a Variable with the given name and initial value over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]
        Parameters:
        parent - the variable's parent model element.
        initialValue - The initial value of the variable.
      • Variable

        public Variable​(ModelElement parent,
                        java.lang.String name)
        Creates a Variable with the given name and initial value, 0.0, over the range [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]
        Parameters:
        parent - the variable's parent model element.
        name - The name of the variable.
      • Variable

        public Variable​(ModelElement parent,
                        double initialValue,
                        java.lang.String name)
        Creates a Variable with the given name and initial value over the supplied range The default range is [Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY]
        Parameters:
        parent - the variable's parent model element
        initialValue - The initial value of the variable.
        name - The name of the variable.
      • Variable

        public Variable​(ModelElement parent,
                        double initialValue,
                        double lowerLimit,
                        java.lang.String name)
        Creates a Variable with the given name and initial value over the supplied range [lowerLimit, Double.POSITIVE_INFINITY]
        Parameters:
        parent - the variable's parent model element
        initialValue - The initial value of the variable.
        lowerLimit - the lower limit on the range for the variable, must be < upperLimit
        name - The name of the variable.
      • Variable

        public Variable​(ModelElement parent,
                        double initialValue,
                        double lowerLimit)
        Creates a Variable with the initial value over the supplied range [lowerLimit, Double.POSITIVE_INFINITY]
        Parameters:
        parent - the variable's parent model element
        initialValue - The initial value of the variable.
        lowerLimit - the lower limit on the range for the variable, must be < upperLimit
      • Variable

        public Variable​(ModelElement parent,
                        double initialValue,
                        double lowerLimit,
                        double upperLimit)
        Creates a Variable with the initial value over the supplied range [lowerLimit, upperLimit]
        Parameters:
        parent - the variable's parent model element
        initialValue - The initial value of the variable.
        lowerLimit - the lower limit on the range for the variable, must be < upperLimit
        upperLimit - the upper limit on the range for the variable
      • Variable

        public Variable​(ModelElement parent,
                        double initialValue,
                        double lowerLimit,
                        double upperLimit,
                        java.lang.String name)
        Creates a Variable with the given name and initial value over the supplied range [lowerLimit, upperLimit]
        Parameters:
        parent - the variable's parent model element
        initialValue - The initial value of the variable. Must be within the range.
        lowerLimit - the lower limit on the range for the variable, must be < upperLimit
        upperLimit - the upper limit on the range for the variable
        name - The name of the variable.
    • Method Detail

      • getInitialValue

        public final double getInitialValue()
        Gets the initial value of the variable
        Specified by:
        getInitialValue in interface GetInitialValueIfc
        Returns:
        The initial value.
      • setInitialValue

        public final void setInitialValue​(double value)
        Sets the initial value of the variable. Only relevant prior to each replication. Changing during a replication has no effect until the next replication.
        Specified by:
        setInitialValue in interface SetInitialValueIfc
        Parameters:
        value - The initial value for the variable.
      • getLowerLimit

        public final double getLowerLimit()
        The lower limit for the range of this random variable
        Returns:
        Returns the lowerLimit.
      • getUpperLimit

        public final double getUpperLimit()
        The upper limit for the range of this random variable
        Returns:
        Returns the upperLimit.
      • setValue

        public final void setValue​(boolean value)
        Maps true to 1.0 and false to 0.0
        Parameters:
        value - true to 1.0 and false to 0.0
      • setValue

        public void setValue​(double value)
        Sets the value of the variable and notifies any observers of the change
        Specified by:
        setValue in interface SetValueIfc
        Parameters:
        value - The observation of the variable.
      • getValue

        public double getValue()
        Every Variable must implement the getValue method. By default this method simply returns the value of the variable.
        Specified by:
        getValue in interface GetValueIfc
        Returns:
        The value of the variable.
      • getPreviousValue

        public final double getPreviousValue()
        Gets the previous number value that was assigned before the current value
        Specified by:
        getPreviousValue in interface PreviousValueIfc
        Returns:
        a double representing that was assigned before the current value
      • getWeight

        public final double getWeight()
        Gets the weight associated with the last value observed.
        Specified by:
        getWeight in interface GetWeightIfc
        Returns:
        The weight for the value.
      • setWeight

        protected void setWeight()
        Sets the weight
      • getTimeOfChange

        public final double getTimeOfChange()
        Gets the time associated with the last value observed.
        Specified by:
        getTimeOfChange in interface GetTimeOfChangeIfc
        Returns:
        The time of the last observation
      • getPreviousTimeOfChange

        public final double getPreviousTimeOfChange()
        Gets the time associated with previous variable change.
        Specified by:
        getPreviousTimeOfChange in interface GetPreviousTimeOfChangeIfc
        Returns:
        The time of the previous change.
      • turnOnTrace

        public final void turnOnTrace()
        Turns on the automatic tracing of this variable to a text file with the default name and no header
      • turnOnTrace

        public final void turnOnTrace​(boolean header)
        Turns on the automatic tracing of this variable to a text file
        Parameters:
        header - if true a header will be the first line of the file
      • turnOnTrace

        public final void turnOnTrace​(java.lang.String fileName)
        Turns on the automatic tracing of this variable to a text file
        Parameters:
        fileName - the file name
      • turnOnTrace

        public final void turnOnTrace​(java.lang.String name,
                                      boolean header)
        Turns on the automatic tracing of this variable to a text file
        Parameters:
        name - Used to name the text file
        header - if true a header will be the first line of the file
      • turnOffTrace

        public final void turnOffTrace()
        Turns off the automatic tracing of this variable to a text file.
      • assignInitialValue

        protected void assignInitialValue​(double value)
        Assigns the value of the variable to the supplied value. Ensures that time of change is current time and previous value and previous time of change are the same as the current value and current time without notifying any update observers
        Parameters:
        value - the initial value to assign
      • assignValue

        protected final void assignValue​(double value)
        Properly assigns the value of the variable and remembers previous value without notifying any update observers
        Parameters:
        value - the value to assign
      • setTraceObserver

        protected void setTraceObserver​(java.lang.String name,
                                        boolean header)
        Can be overridden by subclasses to set the protected variable myVariableTraceTextReport for appropriate text tracing
        Parameters:
        name - the file name of the report
        header - the header, true means include the header
      • beforeExperiment

        protected void beforeExperiment()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need logic to be performed prior to an experiment. The beforeExperiment method allows model elements to be setup prior to the first replication within an experiment. It is called once before any replications occur.
        Overrides:
        beforeExperiment in class ModelElement
      • initialize

        protected void initialize()
        Description copied from class: ModelElement
        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
        Overrides:
        initialize in class ModelElement
      • warmUp

        protected void warmUp()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed at the warm up event during each replication. It is called once during each replication if the model element reacts to warm up actions.
        Overrides:
        warmUp in class ModelElement
      • removedFromModel

        protected void removedFromModel()
        Description copied from class: Aggregatable
        This method should be overridden by subclasses that need actions performed when a model element is removed from a model after the replication has started.
        Overrides:
        removedFromModel in class Aggregatable
      • getSetValueUpdateNotificationFlag

        public final boolean getSetValueUpdateNotificationFlag()
        Gets the value of the flag that indicates whether or not observers will be notified when the value changes.
        Returns:
        true means will be notified
      • setValueUpdateNotificationFlag

        public final void setValueUpdateNotificationFlag​(boolean flag)
        Turns off or on the notification of update observers for changes to the value of the variable. For example, this is useful to save the execution time associated with the statistical collection, etc on the variable Once it is off, it remains off until turned on. Thus multiple executions of the same model will remember this setting
        Parameters:
        flag - true means on
      • asString

        public java.lang.String asString()
        Description copied from class: ModelElement
        Allows sub-classes to provide more detail than toString() to represent the ModelElement as a String
        Overrides:
        asString in class ModelElement
        Returns:
        a detailed String representation