Class ProcessRewardFunction
java.lang.Object
neqsim.process.ml.ProcessRewardFunction
- All Implemented Interfaces:
Serializable
Physics-grounded reward functions for reinforcement learning process optimization.
Provides pre-built, composable reward functions for common process engineering optimization objectives. Each reward component is physically meaningful and grounded in engineering metrics (energy efficiency, product quality, throughput, safety compliance). Rewards are designed to be combined with configurable weights for multi-objective optimization.
Available Reward Components:
energyEfficiency(ProcessSystem)— Minimizes total energy consumption (compressor power + heater/cooler duty)productQuality(ProcessSystem, String, String, double)— Tracks a product stream property toward a target setpointthroughput(ProcessSystem, String)— Maximizes production throughputconstraintSatisfaction(ProcessSystem)— Penalizes operating envelope violationsspecificEnergy(ProcessSystem, String)— Minimizes energy per unit of product
Usage Example:
ProcessRewardFunction reward = new ProcessRewardFunction(process);
reward.addEnergyMinimization(1.0);
reward.addProductQualityTarget("export gas", "methane_molfrac", 0.95, 10.0);
reward.addThroughputMaximization("export gas", 0.5);
reward.addConstraintPenalty(100.0);
double r = reward.compute();
String breakdown = reward.getBreakdownJson();
- Version:
- 1.0
- Author:
- ESOL
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classAbstract base class for reward components. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<ProcessRewardFunction.RewardComponent> private final ProcessSystemprivate static final long -
Constructor Summary
ConstructorsConstructorDescriptionProcessRewardFunction(ProcessSystem process) Create a reward function for a process system. -
Method Summary
Modifier and TypeMethodDescriptionaddConstraintPenalty(double weight) Add constraint satisfaction penalty.addEnergyMinimization(double weight) Add energy minimization component.addProductQualityTarget(String streamName, String propertyName, double target, double weight) Add product quality tracking toward a target value.addSpecificEnergyMinimization(String productStreamName, double weight) Add specific energy minimization (energy per unit product).addThroughputMaximization(String streamName, double weight) Add throughput maximization for a product stream.doublecompute()Compute the total reward as the weighted sum of all components.private static doublecomputePropertyDeviation(StreamInterface stream, String propertyName, double target) Compute deviation of a stream property from target.static doubleCompute total constraint violation penalty.static doubleCompute total energy consumption of the process normalized to MW.Get the last breakdown as JSON string.Get the breakdown of the last reward computation.static doubleproductQuality(ProcessSystem proc, String streamName, String propertyName, double target) Compute squared deviation of a product stream property from its target.static doublespecificEnergy(ProcessSystem proc, String productStreamName) Compute specific energy consumption (energy per unit of product).static doublethroughput(ProcessSystem proc, String streamName) Compute mass throughput of a product stream in kg/s.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
process
-
components
-
lastBreakdown
-
-
Constructor Details
-
ProcessRewardFunction
Create a reward function for a process system.- Parameters:
process- the process system to evaluate
-
-
Method Details
-
addEnergyMinimization
Add energy minimization component. Sums compressor power and heater/cooler absolute duty, normalized by a reference scale, and applies a negative reward.- Parameters:
weight- reward weight (typically 0.1 to 10.0)- Returns:
- this for chaining
-
addProductQualityTarget
public ProcessRewardFunction addProductQualityTarget(String streamName, String propertyName, double target, double weight) Add product quality tracking toward a target value. Uses quadratic penalty for deviation from the setpoint.- Parameters:
streamName- name of the product stream equipmentpropertyName- property to track (e.g., "temperature", "methane_molfrac")target- target value in physical unitsweight- reward weight- Returns:
- this for chaining
-
addThroughputMaximization
Add throughput maximization for a product stream.- Parameters:
streamName- name of the product stream equipmentweight- reward weight- Returns:
- this for chaining
-
addConstraintPenalty
Add constraint satisfaction penalty. Penalizes streams with non-physical values (negative T, P, compositions outside [0,1]).- Parameters:
weight- penalty weight (typically 50-200)- Returns:
- this for chaining
-
addSpecificEnergyMinimization
Add specific energy minimization (energy per unit product).- Parameters:
productStreamName- name of the product streamweight- reward weight- Returns:
- this for chaining
-
compute
public double compute()Compute the total reward as the weighted sum of all components.- Returns:
- total scalar reward
-
getLastBreakdown
-
getBreakdownJson
Get the last breakdown as JSON string.- Returns:
- JSON formatted breakdown
-
energyEfficiency
Compute total energy consumption of the process normalized to MW.Sums compressor power (positive = consumed), heater duty (positive = consumed), and cooler duty (absolute = energy removed that must be supplied by cooling utility). Returns the total in MW.
- Parameters:
proc- the process system- Returns:
- total energy consumption in MW (always non-negative)
-
productQuality
public static double productQuality(ProcessSystem proc, String streamName, String propertyName, double target) Compute squared deviation of a product stream property from its target.- Parameters:
proc- the process systemstreamName- equipment name of the product streampropertyName- "temperature" (K), "pressure" (bar), or component name for mole fractiontarget- target value- Returns:
- squared normalized deviation (0 at target, increases with distance)
-
throughput
Compute mass throughput of a product stream in kg/s.- Parameters:
proc- the process systemstreamName- equipment name- Returns:
- mass flow rate in kg/s, or 0 if not found
-
constraintSatisfaction
Compute total constraint violation penalty.Checks all streams for non-physical values: T < 0 K, P < 0, compositions outside [0,1], NaN values. Returns the sum of squared violations.
- Parameters:
proc- the process system- Returns:
- total violation penalty (0 = no violations)
-
specificEnergy
Compute specific energy consumption (energy per unit of product).- Parameters:
proc- the process systemproductStreamName- product stream name- Returns:
- specific energy in MJ/kg, or a large number if no throughput
-
computePropertyDeviation
private static double computePropertyDeviation(StreamInterface stream, String propertyName, double target) Compute deviation of a stream property from target.- Parameters:
stream- the streampropertyName- "temperature", "pressure", or component name for mole fractiontarget- target value- Returns:
- squared normalized deviation
-