Class ControlledVariable

java.lang.Object
neqsim.process.mpc.MPCVariable
neqsim.process.mpc.ControlledVariable
All Implemented Interfaces:
Serializable

public class ControlledVariable extends MPCVariable
Represents a controlled variable (CV) in an MPC formulation.

A controlled variable is a process output that the MPC aims to keep at a setpoint or within specified constraints. Common examples include pressures, temperatures, compositions, and quality specifications.

Features:

  • Setpoint tracking with configurable weight
  • Soft constraints (penalized violations)
  • Hard constraints (never violated)
  • Zone control (keep within range rather than at setpoint)
  • Priority weighting for multi-CV optimization

Example usage:


// Pressure CV with setpoint control
ControlledVariable pressureCV =
    new ControlledVariable("Pressure", separator, "pressure", "bara").setSetpoint(50.0) // Target
                                                                                        // pressure
        .setWeight(1.0) // High priority
        .setSoftConstraints(45.0, 55.0) // Comfortable range
        .setHardConstraints(35.0, 65.0); // Absolute limits

// Temperature CV with zone control
ControlledVariable tempCV =
    new ControlledVariable("Temperature", outlet, "temperature", "C").setZone(20.0, 30.0) // Keep
                                                                                          // in
                                                                                          // this
                                                                                          // zone
        .setWeight(0.5); // Lower priority

Since:
3.0
Version:
1.0
Author:
Even Solbraa
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • setpoint

      private double setpoint
      Target setpoint for this CV.
    • weight

      private double weight
      Weight on setpoint tracking error in objective function.
    • softMin

      private double softMin
      Lower soft constraint (penalized if violated).
    • softMax

      private double softMax
      Upper soft constraint (penalized if violated).
    • hardMin

      private double hardMin
      Lower hard constraint (never violated).
    • hardMax

      private double hardMax
      Upper hard constraint (never violated).
    • softConstraintPenalty

      private double softConstraintPenalty
      Penalty weight for soft constraint violations.
    • zoneControl

      private boolean zoneControl
      Whether to use zone control instead of setpoint tracking.
    • zoneLower

      private double zoneLower
      Lower bound of zone for zone control mode.
    • zoneUpper

      private double zoneUpper
      Upper bound of zone for zone control mode.
    • predictedValue

      private double predictedValue
      Predicted value from MPC calculation.
  • Constructor Details

    • ControlledVariable

      public ControlledVariable(String name)
      Construct a controlled variable with a name.
      Parameters:
      name - unique identifier for this CV
    • ControlledVariable

      public ControlledVariable(String name, ProcessEquipmentInterface equipment, String propertyName)
      Construct a controlled variable bound to equipment.
      Parameters:
      name - unique identifier for this CV
      equipment - the process equipment to monitor
      propertyName - the property to control
    • ControlledVariable

      public ControlledVariable(String name, ProcessEquipmentInterface equipment, String propertyName, String unit)
      Construct a controlled variable bound to equipment with unit.
      Parameters:
      name - unique identifier for this CV
      equipment - the process equipment to monitor
      propertyName - the property to control
      unit - the unit for the property value
  • Method Details

    • getType

      public MPCVariable.MPCVariableType getType()
      Description copied from class: MPCVariable
      Get the type of this MPC variable.
      Specified by:
      getType in class MPCVariable
      Returns:
      the variable type (MV, CV, or DV)
    • getSetpoint

      public double getSetpoint()
      Get the setpoint for this CV.
      Returns:
      the target setpoint
    • setSetpoint

      public ControlledVariable setSetpoint(double setpoint)
      Set the setpoint for this CV.
      Parameters:
      setpoint - the target value
      Returns:
      this variable for method chaining
    • getWeight

      public double getWeight()
      Get the tracking weight.
      Returns:
      the weight on setpoint error
    • setWeight

      public ControlledVariable setWeight(double weight)
      Set the tracking weight for this CV.

      Higher weight means this CV is prioritized over others when the controller must make trade-offs.

      Parameters:
      weight - the weight (non-negative)
      Returns:
      this variable for method chaining
    • getSoftMin

      public double getSoftMin()
      Get the lower soft constraint.
      Returns:
      the lower soft limit
    • getSoftMax

      public double getSoftMax()
      Get the upper soft constraint.
      Returns:
      the upper soft limit
    • setSoftConstraints

      public ControlledVariable setSoftConstraints(double min, double max)
      Set soft constraints for this CV.

      Soft constraints define the preferred operating range. The controller penalizes violations but may exceed these limits if necessary to satisfy higher-priority objectives.

      Parameters:
      min - lower soft limit
      max - upper soft limit
      Returns:
      this variable for method chaining
    • getHardMin

      public double getHardMin()
      Get the lower hard constraint.
      Returns:
      the lower hard limit
    • getHardMax

      public double getHardMax()
      Get the upper hard constraint.
      Returns:
      the upper hard limit
    • setHardConstraints

      public ControlledVariable setHardConstraints(double min, double max)
      Set hard constraints for this CV.

      Hard constraints are never violated. They represent physical or safety limits that the controller must respect.

      Parameters:
      min - lower hard limit
      max - upper hard limit
      Returns:
      this variable for method chaining
    • getSoftConstraintPenalty

      public double getSoftConstraintPenalty()
      Get the soft constraint penalty.
      Returns:
      the penalty weight for soft violations
    • setSoftConstraintPenalty

      public ControlledVariable setSoftConstraintPenalty(double penalty)
      Set the penalty for soft constraint violations.
      Parameters:
      penalty - the penalty weight (positive)
      Returns:
      this variable for method chaining
    • isZoneControl

      public boolean isZoneControl()
      Check if this CV uses zone control.
      Returns:
      true if zone control is enabled
    • getZoneLower

      public double getZoneLower()
      Get the lower zone bound.
      Returns:
      the lower zone limit
    • getZoneUpper

      public double getZoneUpper()
      Get the upper zone bound.
      Returns:
      the upper zone limit
    • setZone

      public ControlledVariable setZone(double lower, double upper)
      Set zone control for this CV.

      In zone control mode, the controller only acts when the CV leaves the specified zone. No control action is taken as long as the CV remains within the zone. This reduces control effort and wear on equipment.

      Parameters:
      lower - lower zone bound
      upper - upper zone bound
      Returns:
      this variable for method chaining
    • getPredictedValue

      public double getPredictedValue()
      Get the predicted value from MPC calculation.
      Returns:
      the predicted CV value
    • setPredictedValue

      public void setPredictedValue(double value)
      Set the predicted value (used by MPC internals).
      Parameters:
      value - the predicted value
    • setBounds

      public ControlledVariable setBounds(double min, double max)
      Description copied from class: MPCVariable
      Set bounds for this variable.
      Overrides:
      setBounds in class MPCVariable
      Parameters:
      min - minimum allowed value
      max - maximum allowed value
      Returns:
      this variable for method chaining
    • setEquipment

      public ControlledVariable setEquipment(ProcessEquipmentInterface equipment)
      Description copied from class: MPCVariable
      Set the bound equipment.
      Overrides:
      setEquipment in class MPCVariable
      Parameters:
      equipment - the process equipment to bind to
      Returns:
      this variable for method chaining
    • setPropertyName

      public ControlledVariable setPropertyName(String propertyName)
      Description copied from class: MPCVariable
      Set the property name to read/write.
      Overrides:
      setPropertyName in class MPCVariable
      Parameters:
      propertyName - the property name
      Returns:
      this variable for method chaining
    • setUnit

      public ControlledVariable setUnit(String unit)
      Description copied from class: MPCVariable
      Set the unit for this variable.
      Overrides:
      setUnit in class MPCVariable
      Parameters:
      unit - the unit string
      Returns:
      this variable for method chaining
    • readValue

      public double readValue()
      Description copied from class: MPCVariable
      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.

      Specified by:
      readValue in class MPCVariable
      Returns:
      the current value read from equipment
    • getTrackingError

      public double getTrackingError()
      Calculate the tracking error for this CV.
      Returns:
      the error (positive if above setpoint, negative if below)
    • getSoftViolation

      public double getSoftViolation()
      Calculate the soft constraint violation.
      Returns:
      the violation amount (0 if within soft limits)
    • isWithinZone

      public boolean isWithinZone()
      Check if the current value is within zone.
      Returns:
      true if CV is within the control zone
    • getEffectiveSetpoint

      public double getEffectiveSetpoint()
      Calculate the effective setpoint considering zone control.

      In zone control mode, returns the current value if within zone (no action needed), or the nearest zone boundary if outside.

      Returns:
      the effective setpoint for control