Class SteadyStateVariable
- All Implemented Interfaces:
Serializable
Maintains a sliding window of recent measurements and computes statistics used by
SteadyStateDetector to determine whether the variable is at steady state. The key
statistics are:
- Mean and standard deviation of the window
- R-statistic: ratio of filtered variance to unfiltered variance
- Slope from linear regression over the window
- Whether the variable is at steady state according to configurable thresholds
Values are added one at a time via addValue(double). The window size and all thresholds
are set on the parent SteadyStateDetector.
- Version:
- 1.0
- Author:
- Process Optimization Team
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether this variable is currently at steady state.private doubleCurrent mean of the window.private final StringVariable name (tag identifier).private doubleR-statistic: ratio of filtered variance to unfiltered variance.private static final longprivate doubleSlope of linear regression through the window values.private doubleCurrent standard deviation of the window.private doubleOptional measurement uncertainty (sigma) for linking to reconciliation.private StringEngineering unit string (e.g., "kg/hr", "bara", "C").Sliding window of recent values.private intMaximum window size. -
Constructor Summary
ConstructorsConstructorDescriptionSteadyStateVariable(String name, int windowSize) Creates a steady-state monitoring variable. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddValue(double value) Adds a new measurement value to the sliding window.voidclear()Clears all values from the window and resets statistics.private voidComputes all statistics from the current window contents.intgetCount()Returns the current number of values in the window.doubleReturns the most recent value in the window.doublegetMean()Returns the mean of the current window.getName()Returns the variable name.doubleReturns the R-statistic (filtered/unfiltered variance ratio).doublegetSlope()Returns the slope from linear regression through the window.doubleReturns the standard deviation of the current window.doubleReturns the measurement uncertainty (sigma) for reconciliation.getUnit()Returns the engineering unit string.intReturns the maximum window size.Returns the values in the current window.booleanReturns whether this variable is currently at steady state.booleanReturns whether the window is full.(package private) voidsetAtSteadyState(boolean atSteadyState) Sets the steady-state flag.setUncertainty(double uncertainty) Sets the measurement uncertainty for linking to the reconciliation engine.Sets the engineering unit string.voidsetWindowSize(int windowSize) Sets the maximum window size.toString()Returns a summary string.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
name
Variable name (tag identifier). -
unit
Engineering unit string (e.g., "kg/hr", "bara", "C"). -
window
-
windowSize
private int windowSizeMaximum window size. -
mean
private double meanCurrent mean of the window. -
standardDeviation
private double standardDeviationCurrent standard deviation of the window. -
rStatistic
private double rStatisticR-statistic: ratio of filtered variance to unfiltered variance. A value near 1.0 indicates steady state; lower values indicate transient behaviour. -
slope
private double slopeSlope of linear regression through the window values. Near zero indicates steady state; positive or negative values indicate a trend. -
atSteadyState
private boolean atSteadyStateWhether this variable is currently at steady state. -
uncertainty
private double uncertaintyOptional measurement uncertainty (sigma) for linking to reconciliation.
-
-
Constructor Details
-
SteadyStateVariable
Creates a steady-state monitoring variable.- Parameters:
name- variable identifier (e.g., DCS tag name)windowSize- maximum number of recent values to retain
-
-
Method Details
-
addValue
public void addValue(double value) Adds a new measurement value to the sliding window.If the window exceeds its maximum size, the oldest value is removed. After adding, the mean, standard deviation, R-statistic, and slope are recalculated.
- Parameters:
value- the new measurement reading
-
computeStatistics
private void computeStatistics()Computes all statistics from the current window contents.Calculates: mean, standard deviation, R-statistic (filtered/unfiltered variance ratio), and slope from linear regression.
-
getName
-
getUnit
-
setUnit
Sets the engineering unit string.- Parameters:
unit- the unit (e.g., "kg/hr")- Returns:
- this variable for chaining
-
getCount
public int getCount()Returns the current number of values in the window.- Returns:
- count of values in the sliding window
-
getWindowSize
public int getWindowSize()Returns the maximum window size.- Returns:
- the configured window size
-
setWindowSize
public void setWindowSize(int windowSize) Sets the maximum window size.- Parameters:
windowSize- new window size (must be at least 3)- Throws:
IllegalArgumentException- if windowSize is less than 3
-
isWindowFull
public boolean isWindowFull()Returns whether the window is full.- Returns:
- true if the number of values equals the window size
-
getMean
public double getMean()Returns the mean of the current window.- Returns:
- arithmetic mean
-
getStandardDeviation
public double getStandardDeviation()Returns the standard deviation of the current window.- Returns:
- sample standard deviation
-
getRStatistic
public double getRStatistic()Returns the R-statistic (filtered/unfiltered variance ratio).The R-statistic compares the variance of successive differences (filtered variance) to the overall sample variance (unfiltered variance). At steady state, both variances are similar and R approaches 1.0. During ramps or trends, the unfiltered variance is much larger, so R drops well below 1.0.
- Returns:
- R-statistic in the range [0, 1+] where ~1 = steady state
-
getSlope
public double getSlope()Returns the slope from linear regression through the window.Expressed in engineering-units per sample. Divide by the sampling interval to get units per second, per minute, etc.
- Returns:
- regression slope (units per sample)
-
getLatestValue
public double getLatestValue()Returns the most recent value in the window.- Returns:
- the last added value, or NaN if empty
-
getWindowValues
-
isAtSteadyState
public boolean isAtSteadyState()Returns whether this variable is currently at steady state.- Returns:
- true if at steady state
-
setAtSteadyState
void setAtSteadyState(boolean atSteadyState) Sets the steady-state flag. Called bySteadyStateDetector.- Parameters:
atSteadyState- true if at steady state
-
getUncertainty
public double getUncertainty()Returns the measurement uncertainty (sigma) for reconciliation.- Returns:
- uncertainty, or NaN if not set
-
setUncertainty
Sets the measurement uncertainty for linking to the reconciliation engine.- Parameters:
uncertainty- standard deviation (sigma), must be positive- Returns:
- this variable for chaining
- Throws:
IllegalArgumentException- if uncertainty is not positive
-
clear
public void clear()Clears all values from the window and resets statistics. -
toString
-