Class MPCVariable

java.lang.Object
neqsim.process.mpc.MPCVariable
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ControlledVariable, DisturbanceVariable, ManipulatedVariable, StateVariable

public abstract class MPCVariable extends Object implements Serializable
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:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • name

      protected final String name
      Unique identifier for this variable.
    • description

      protected String description
      Human-readable description of this variable.
    • equipment

      protected ProcessEquipmentInterface equipment
      The process equipment this variable is bound to.
    • propertyName

      protected String propertyName
      The property name to read/write on the equipment.
    • unit

      protected String unit
      The unit for the property value.
    • currentValue

      protected double currentValue
      Current value of the variable.
    • minValue

      protected double minValue
      Minimum allowed value for this variable.
    • maxValue

      protected double maxValue
      Maximum allowed value for this variable.
  • Constructor Details

    • MPCVariable

      protected MPCVariable(String name)
      Construct an MPC variable with a name.
      Parameters:
      name - unique identifier for this variable
    • MPCVariable

      protected MPCVariable(String name, ProcessEquipmentInterface equipment, String propertyName)
      Construct an MPC variable bound to equipment.
      Parameters:
      name - unique identifier for this variable
      equipment - the process equipment to bind to
      propertyName - 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 variable
      equipment - the process equipment to bind to
      propertyName - the property to read/write
      unit - the unit for the property value
  • Method Details

    • getName

      public String getName()
      Get the variable name.
      Returns:
      the unique identifier
    • getEquipment

      public ProcessEquipmentInterface getEquipment()
      Get the bound equipment.
      Returns:
      the process equipment, or null if not bound
    • setEquipment

      public MPCVariable setEquipment(ProcessEquipmentInterface equipment)
      Set the bound equipment.
      Parameters:
      equipment - the process equipment to bind to
      Returns:
      this variable for method chaining
    • getPropertyName

      public String getPropertyName()
      Get the property name.
      Returns:
      the property name being read/written
    • setPropertyName

      public MPCVariable setPropertyName(String propertyName)
      Set the property name to read/write.
      Parameters:
      propertyName - the property name
      Returns:
      this variable for method chaining
    • getUnit

      public String getUnit()
      Get the unit for this variable.
      Returns:
      the unit string, or null if not specified
    • setUnit

      public MPCVariable setUnit(String unit)
      Set the unit for this variable.
      Parameters:
      unit - the unit string
      Returns:
      this variable for method chaining
    • getDescription

      public String getDescription()
      Get the description for this variable.
      Returns:
      the description, or null if not set
    • setDescription

      public MPCVariable setDescription(String description)
      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

      public MPCVariable setBounds(double min, double max)
      Set bounds for this variable.
      Parameters:
      min - minimum allowed value
      max - 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

      public abstract MPCVariable.MPCVariableType getType()
      Get the type of this MPC variable.
      Returns:
      the variable type (MV, CV, or DV)
    • toString

      public String toString()
      Overrides:
      toString in class Object