Class MPCVariable
java.lang.Object
neqsim.process.mpc.MPCVariable
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ControlledVariable, DisturbanceVariable, ManipulatedVariable, StateVariable
Base class for MPC variables (manipulated, controlled, or disturbance).
An MPCVariable binds a process equipment property to the MPC formulation. It defines how to read the current value from the equipment and, for manipulated variables, how to write new setpoints. This abstraction allows the MPC to work with any NeqSim process equipment without hard-coding specific property accessors.
Example usage:
// Create a manipulated variable for valve opening
ManipulatedVariable mv = new ManipulatedVariable("ValveOpening", valve, "opening")
.setBounds(0.0, 1.0).setRateLimit(-0.1, 0.1);
// Create a controlled variable for separator pressure
ControlledVariable cv = new ControlledVariable("Pressure", separator, "pressure", "bara")
.setSetpoint(50.0).setSoftConstraints(45.0, 55.0);
- Since:
- 3.0
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of MPC variable types. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleCurrent value of the variable.protected StringHuman-readable description of this variable.protected ProcessEquipmentInterfaceThe process equipment this variable is bound to.protected doubleMaximum allowed value for this variable.protected doubleMinimum allowed value for this variable.protected final StringUnique identifier for this variable.protected StringThe property name to read/write on the equipment.private static final longprotected StringThe unit for the property value. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMPCVariable(String name) Construct an MPC variable with a name.protectedMPCVariable(String name, ProcessEquipmentInterface equipment, String propertyName) Construct an MPC variable bound to equipment.protectedMPCVariable(String name, ProcessEquipmentInterface equipment, String propertyName, String unit) Construct an MPC variable bound to equipment with unit specification. -
Method Summary
Modifier and TypeMethodDescriptiondoubleGet the current value of this variable.Get the description for this variable.Get the bound equipment.doubleGet the maximum allowed value.doubleGet the minimum allowed value.getName()Get the variable name.Get the property name.abstract MPCVariable.MPCVariableTypegetType()Get the type of this MPC variable.getUnit()Get the unit for this variable.abstract doubleRead the current value from the bound equipment.setBounds(double min, double max) Set bounds for this variable.voidsetCurrentValue(double value) Set the current value (used for caching/tracking).setDescription(String description) Set the description for this variable.setEquipment(ProcessEquipmentInterface equipment) Set the bound equipment.setPropertyName(String propertyName) Set the property name to read/write.Set the unit for this variable.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
name
Unique identifier for this variable. -
description
Human-readable description of this variable. -
equipment
The process equipment this variable is bound to. -
propertyName
The property name to read/write on the equipment. -
unit
The unit for the property value. -
currentValue
protected double currentValueCurrent value of the variable. -
minValue
protected double minValueMinimum allowed value for this variable. -
maxValue
protected double maxValueMaximum allowed value for this variable.
-
-
Constructor Details
-
MPCVariable
Construct an MPC variable with a name.- Parameters:
name- unique identifier for this variable
-
MPCVariable
Construct an MPC variable bound to equipment.- Parameters:
name- unique identifier for this variableequipment- the process equipment to bind topropertyName- the property to read/write
-
MPCVariable
protected MPCVariable(String name, ProcessEquipmentInterface equipment, String propertyName, String unit) Construct an MPC variable bound to equipment with unit specification.- Parameters:
name- unique identifier for this variableequipment- the process equipment to bind topropertyName- the property to read/writeunit- the unit for the property value
-
-
Method Details
-
getName
-
getEquipment
Get the bound equipment.- Returns:
- the process equipment, or null if not bound
-
setEquipment
Set the bound equipment.- Parameters:
equipment- the process equipment to bind to- Returns:
- this variable for method chaining
-
getPropertyName
Get the property name.- Returns:
- the property name being read/written
-
setPropertyName
Set the property name to read/write.- Parameters:
propertyName- the property name- Returns:
- this variable for method chaining
-
getUnit
Get the unit for this variable.- Returns:
- the unit string, or null if not specified
-
setUnit
Set the unit for this variable.- Parameters:
unit- the unit string- Returns:
- this variable for method chaining
-
getDescription
Get the description for this variable.- Returns:
- the description, or null if not set
-
setDescription
Set the description for this variable.- Parameters:
description- the human-readable description- Returns:
- this variable for method chaining
-
getMinValue
public double getMinValue()Get the minimum allowed value.- Returns:
- the minimum bound
-
getMaxValue
public double getMaxValue()Get the maximum allowed value.- Returns:
- the maximum bound
-
setBounds
Set bounds for this variable.- Parameters:
min- minimum allowed valuemax- maximum allowed value- Returns:
- this variable for method chaining
-
getCurrentValue
public double getCurrentValue()Get the current value of this variable.- Returns:
- the current value
-
setCurrentValue
public void setCurrentValue(double value) Set the current value (used for caching/tracking).- Parameters:
value- the current value
-
readValue
public abstract double readValue()Read 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.
- Returns:
- the current value read from equipment
-
getType
Get the type of this MPC variable.- Returns:
- the variable type (MV, CV, or DV)
-
toString
-