Class ProcessRewardFunction

java.lang.Object
neqsim.process.ml.ProcessRewardFunction
All Implemented Interfaces:
Serializable

public class ProcessRewardFunction extends Object implements 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:

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:
  • Field Details

  • Constructor Details

    • ProcessRewardFunction

      public ProcessRewardFunction(ProcessSystem process)
      Create a reward function for a process system.
      Parameters:
      process - the process system to evaluate
  • Method Details

    • addEnergyMinimization

      public ProcessRewardFunction addEnergyMinimization(double weight)
      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 equipment
      propertyName - property to track (e.g., "temperature", "methane_molfrac")
      target - target value in physical units
      weight - reward weight
      Returns:
      this for chaining
    • addThroughputMaximization

      public ProcessRewardFunction addThroughputMaximization(String streamName, double weight)
      Add throughput maximization for a product stream.
      Parameters:
      streamName - name of the product stream equipment
      weight - reward weight
      Returns:
      this for chaining
    • addConstraintPenalty

      public ProcessRewardFunction addConstraintPenalty(double weight)
      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

      public ProcessRewardFunction addSpecificEnergyMinimization(String productStreamName, double weight)
      Add specific energy minimization (energy per unit product).
      Parameters:
      productStreamName - name of the product stream
      weight - 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

      public Map<String,Double> getLastBreakdown()
      Get the breakdown of the last reward computation.
      Returns:
      map of component name to weighted reward value
    • getBreakdownJson

      public String getBreakdownJson()
      Get the last breakdown as JSON string.
      Returns:
      JSON formatted breakdown
    • energyEfficiency

      public static double energyEfficiency(ProcessSystem proc)
      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 system
      streamName - equipment name of the product stream
      propertyName - "temperature" (K), "pressure" (bar), or component name for mole fraction
      target - target value
      Returns:
      squared normalized deviation (0 at target, increases with distance)
    • throughput

      public static double throughput(ProcessSystem proc, String streamName)
      Compute mass throughput of a product stream in kg/s.
      Parameters:
      proc - the process system
      streamName - equipment name
      Returns:
      mass flow rate in kg/s, or 0 if not found
    • constraintSatisfaction

      public static double constraintSatisfaction(ProcessSystem proc)
      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

      public static double specificEnergy(ProcessSystem proc, String productStreamName)
      Compute specific energy consumption (energy per unit of product).
      Parameters:
      proc - the process system
      productStreamName - 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 stream
      propertyName - "temperature", "pressure", or component name for mole fraction
      target - target value
      Returns:
      squared normalized deviation