Class StateVariable
java.lang.Object
neqsim.process.mpc.MPCVariable
neqsim.process.mpc.StateVariable
- All Implemented Interfaces:
Serializable
Represents a state variable (SVR) in a nonlinear MPC system.
State variables are internal model states that evolve according to dynamic equations. Unlike CVs (controlled variables), SVRs are not directly controlled but are essential for model accuracy. Examples include:
- Flow rates (qin, qout)
- Internal pressures
- Valve coefficients (cv)
- Calculated gains
In nonlinear MPC, state variables track the difference between model predictions and measurements, enabling bias correction and model updates.
Key attributes:
- ModelValue: Current value from model simulation
- MeasValue: Measured value (if available)
- Bias: Difference between measurement and model
- Since:
- 3.0
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class MPCVariable
MPCVariable.MPCVariableType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleBias (measurement - model).private doubleBias filter time constant (seconds).private doubleBias prediction time constant (seconds).private StringData index for C++ code linking.private booleanWhether measurement is available.private doubleMeasured value (if available).private doubleModel-predicted value.private static final longprivate booleanWhether to update from measurement.Fields inherited from class MPCVariable
currentValue, description, equipment, maxValue, minValue, name, propertyName, unit -
Constructor Summary
ConstructorsConstructorDescriptionStateVariable(String name, ProcessEquipmentInterface equipment, String propertyName) Construct a state variable linked to process equipment. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the measurement.doublegetBias()Get the bias (measurement - model).doubleGet the bias filter time constant.doubleGet the bias prediction time constant.doubleGet the corrected value (model + bias).doubleGet the current value of this variable.getDtaIx()Get the data index for C++ code linking.doubleGet the measured value.doubleGet the model-predicted value.getType()Get the type of this MPC variable.booleanCheck if measurement is available.booleanCheck if update from measurement is enabled.doublepredictBias(double predictionTime, double previousBias, double sampleTime) Predict bias at a future time.doubleRead the current value from the process.doubleRead the current value from the bound equipment.voidsetBiasTfilt(double biasTfilt) Set the bias filter time constant.voidsetBiasTpred(double biasTpred) Set the bias prediction time constant.voidSet the data index for C++ code linking.voidsetMeasuredValue(double measuredValue) Set the measured value.voidsetModelValue(double modelValue) Set the model-predicted value.voidsetUpdateFromMeasurement(boolean updateFromMeasurement) Set whether to update from measurement.toString()voidupdate(double measurement) Update state from measurement.private voidUpdate the bias based on current model and measured values.Methods inherited from class MPCVariable
getDescription, getEquipment, getMaxValue, getMinValue, getName, getPropertyName, getUnit, setBounds, setCurrentValue, setDescription, setEquipment, setPropertyName, setUnit
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
modelValue
private double modelValueModel-predicted value. -
measuredValue
private double measuredValueMeasured value (if available). -
hasMeasurement
private boolean hasMeasurementWhether measurement is available. -
bias
private double biasBias (measurement - model). -
biasTfilt
private double biasTfiltBias filter time constant (seconds). -
biasTpred
private double biasTpredBias prediction time constant (seconds). -
dtaIx
Data index for C++ code linking. -
updateFromMeasurement
private boolean updateFromMeasurementWhether to update from measurement.
-
-
Constructor Details
-
StateVariable
Construct a state variable linked to process equipment.- Parameters:
name- variable nameequipment- linked process equipmentpropertyName- property to read from equipment
-
-
Method Details
-
getModelValue
public double getModelValue()Get the model-predicted value.- Returns:
- model value
-
setModelValue
public void setModelValue(double modelValue) Set the model-predicted value.- Parameters:
modelValue- model value
-
getMeasuredValue
public double getMeasuredValue()Get the measured value.- Returns:
- measured value, or model value if no measurement
-
setMeasuredValue
public void setMeasuredValue(double measuredValue) Set the measured value.- Parameters:
measuredValue- measured value
-
hasMeasurement
public boolean hasMeasurement()Check if measurement is available.- Returns:
- true if measured
-
clearMeasurement
public void clearMeasurement()Clear the measurement. -
getBias
public double getBias()Get the bias (measurement - model).- Returns:
- bias value
-
updateBias
private void updateBias()Update the bias based on current model and measured values. -
getBiasTfilt
public double getBiasTfilt()Get the bias filter time constant.- Returns:
- filter time constant (seconds)
-
setBiasTfilt
public void setBiasTfilt(double biasTfilt) Set the bias filter time constant.- Parameters:
biasTfilt- filter time constant (seconds)
-
getBiasTpred
public double getBiasTpred()Get the bias prediction time constant.- Returns:
- prediction time constant (seconds)
-
setBiasTpred
public void setBiasTpred(double biasTpred) Set the bias prediction time constant.- Parameters:
biasTpred- prediction time constant (seconds)
-
getDtaIx
-
setDtaIx
Set the data index for C++ code linking.- Parameters:
dtaIx- data index
-
isUpdateFromMeasurement
public boolean isUpdateFromMeasurement()Check if update from measurement is enabled.- Returns:
- true if updates from measurement
-
setUpdateFromMeasurement
public void setUpdateFromMeasurement(boolean updateFromMeasurement) Set whether to update from measurement.- Parameters:
updateFromMeasurement- true to enable updates
-
getCorrectedValue
public double getCorrectedValue()Get the corrected value (model + bias).- Returns:
- corrected value
-
predictBias
public double predictBias(double predictionTime, double previousBias, double sampleTime) Predict bias at a future time.- Parameters:
predictionTime- time into the future (seconds)previousBias- bias at previous time stepsampleTime- sample time (seconds)- Returns:
- predicted bias
-
getCurrentValue
public double getCurrentValue()Description copied from class:MPCVariableGet the current value of this variable.- Overrides:
getCurrentValuein classMPCVariable- Returns:
- the current value
-
readValue
public double readValue()Description copied from class:MPCVariableRead the current value from the bound equipment.This method uses reflection or equipment-specific accessors to read the property value. The implementation varies by variable type and property.
- Specified by:
readValuein classMPCVariable- Returns:
- the current value read from equipment
-
getType
Description copied from class:MPCVariableGet the type of this MPC variable.- Specified by:
getTypein classMPCVariable- Returns:
- the variable type (MV, CV, or DV)
-
readFromProcess
public double readFromProcess()Read the current value from the process.- Returns:
- current value from equipment
-
update
public void update(double measurement) Update state from measurement.- Parameters:
measurement- measured value
-
toString
- Overrides:
toStringin classMPCVariable
-