Class ControlledVariable
- All Implemented Interfaces:
Serializable
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class MPCVariable
MPCVariable.MPCVariableType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate doubleUpper hard constraint (never violated).private doubleLower hard constraint (never violated).private doublePredicted value from MPC calculation.private static final longprivate doubleTarget setpoint for this CV.private doublePenalty weight for soft constraint violations.private doubleUpper soft constraint (penalized if violated).private doubleLower soft constraint (penalized if violated).private doubleWeight on setpoint tracking error in objective function.private booleanWhether to use zone control instead of setpoint tracking.private doubleLower bound of zone for zone control mode.private doubleUpper bound of zone for zone control mode.Fields inherited from class MPCVariable
currentValue, description, equipment, maxValue, minValue, name, propertyName, unit -
Constructor Summary
ConstructorsConstructorDescriptionControlledVariable(String name) Construct a controlled variable with a name.ControlledVariable(String name, ProcessEquipmentInterface equipment, String propertyName) Construct a controlled variable bound to equipment.ControlledVariable(String name, ProcessEquipmentInterface equipment, String propertyName, String unit) Construct a controlled variable bound to equipment with unit. -
Method Summary
Modifier and TypeMethodDescriptiondoubleCalculate the effective setpoint considering zone control.doubleGet the upper hard constraint.doubleGet the lower hard constraint.doubleGet the predicted value from MPC calculation.doubleGet the setpoint for this CV.doubleGet the soft constraint penalty.doubleGet the upper soft constraint.doubleGet the lower soft constraint.doubleCalculate the soft constraint violation.doubleCalculate the tracking error for this CV.getType()Get the type of this MPC variable.doubleGet the tracking weight.doubleGet the lower zone bound.doubleGet the upper zone bound.booleanCheck if the current value is within zone.booleanCheck if this CV uses zone control.doubleRead the current value from the bound equipment.setBounds(double min, double max) Set bounds for this variable.setEquipment(ProcessEquipmentInterface equipment) Set the bound equipment.setHardConstraints(double min, double max) Set hard constraints for this CV.voidsetPredictedValue(double value) Set the predicted value (used by MPC internals).setPropertyName(String propertyName) Set the property name to read/write.setSetpoint(double setpoint) Set the setpoint for this CV.setSoftConstraintPenalty(double penalty) Set the penalty for soft constraint violations.setSoftConstraints(double min, double max) Set soft constraints for this CV.Set the unit for this variable.setWeight(double weight) Set the tracking weight for this CV.setZone(double lower, double upper) Set zone control for this CV.Methods inherited from class MPCVariable
getCurrentValue, getDescription, getEquipment, getMaxValue, getMinValue, getName, getPropertyName, getUnit, setCurrentValue, setDescription, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
setpoint
private double setpointTarget setpoint for this CV. -
weight
private double weightWeight on setpoint tracking error in objective function. -
softMin
private double softMinLower soft constraint (penalized if violated). -
softMax
private double softMaxUpper soft constraint (penalized if violated). -
hardMin
private double hardMinLower hard constraint (never violated). -
hardMax
private double hardMaxUpper hard constraint (never violated). -
softConstraintPenalty
private double softConstraintPenaltyPenalty weight for soft constraint violations. -
zoneControl
private boolean zoneControlWhether to use zone control instead of setpoint tracking. -
zoneLower
private double zoneLowerLower bound of zone for zone control mode. -
zoneUpper
private double zoneUpperUpper bound of zone for zone control mode. -
predictedValue
private double predictedValuePredicted value from MPC calculation.
-
-
Constructor Details
-
ControlledVariable
Construct a controlled variable with a name.- Parameters:
name- unique identifier for this CV
-
ControlledVariable
Construct a controlled variable bound to equipment.- Parameters:
name- unique identifier for this CVequipment- the process equipment to monitorpropertyName- 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 CVequipment- the process equipment to monitorpropertyName- the property to controlunit- the unit for the property value
-
-
Method Details
-
getType
Description copied from class:MPCVariableGet the type of this MPC variable.- Specified by:
getTypein classMPCVariable- Returns:
- the variable type (MV, CV, or DV)
-
getSetpoint
public double getSetpoint()Get the setpoint for this CV.- Returns:
- the target setpoint
-
setSetpoint
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
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
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 limitmax- 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
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 limitmax- 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
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
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 boundupper- 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
Description copied from class:MPCVariableSet bounds for this variable.- Overrides:
setBoundsin classMPCVariable- Parameters:
min- minimum allowed valuemax- maximum allowed value- Returns:
- this variable for method chaining
-
setEquipment
Description copied from class:MPCVariableSet the bound equipment.- Overrides:
setEquipmentin classMPCVariable- Parameters:
equipment- the process equipment to bind to- Returns:
- this variable for method chaining
-
setPropertyName
Description copied from class:MPCVariableSet the property name to read/write.- Overrides:
setPropertyNamein classMPCVariable- Parameters:
propertyName- the property name- Returns:
- this variable for method chaining
-
setUnit
Description copied from class:MPCVariableSet the unit for this variable.- Overrides:
setUnitin classMPCVariable- Parameters:
unit- the unit string- Returns:
- this variable for method chaining
-
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
-
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
-