Class ProcessSimulationFunction

All Implemented Interfaces:
Cloneable, FunctionInterface

public class ProcessSimulationFunction extends LevenbergMarquardtFunction
Objective function that bridges process simulation with the Levenberg-Marquardt optimizer.

This class extends LevenbergMarquardtFunction to enable batch parameter estimation for process simulations. It wraps a ProcessSystem and provides the objective function interface expected by the L-M optimizer.

Key Features:

  • Path-based access to process variables (equipment.property notation)
  • Optional analytical Jacobian via ProcessSensitivityAnalyzer
  • Automatic parameter bounds enforcement
  • Support for multiple measured outputs per data point

Usage:


ProcessSimulationFunction function = new ProcessSimulationFunction(process);
function.addParameter("Pipe1.heatTransferCoefficient", 1.0, 100.0);
function.addMeasurement("Manifold.outletStream.temperature");
function.setInitialGuess(new double[] {15.0});

Version:
1.0
Author:
ESOL
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • logger

      static org.apache.logging.log4j.Logger logger
      Logger object for class.
    • processSystem

      private ProcessSystem processSystem
      The process system to simulate.
    • parameterPaths

      private List<String> parameterPaths
      Parameter paths in the process (e.g., "Pipe1.heatTransferCoefficient").
    • measurementPaths

      private List<String> measurementPaths
      Measurement paths in the process (e.g., "Manifold.outletStream.temperature").
    • dataPointConditions

      private List<Map<String,Double>> dataPointConditions
      Conditions to apply for each data point.
    • currentDataPointIndex

      private int currentDataPointIndex
      Current data point index being evaluated.
    • currentMeasurementIndex

      private int currentMeasurementIndex
      Current measurement index being evaluated.
    • useAnalyticalJacobian

      private boolean useAnalyticalJacobian
      Whether to use ProcessSensitivityAnalyzer for Jacobian.
    • sensitivityAnalyzer

      private transient ProcessSensitivityAnalyzer sensitivityAnalyzer
      Cached sensitivity analyzer.
    • cachedJacobian

      private transient SensitivityMatrix cachedJacobian
      Cached Jacobian from last computation.
  • Constructor Details

    • ProcessSimulationFunction

      public ProcessSimulationFunction(ProcessSystem processSystem)
      Creates a new process simulation function.
      Parameters:
      processSystem - the process system to wrap
  • Method Details

    • addParameter

      public ProcessSimulationFunction addParameter(String path, double lowerBound, double upperBound)
      Adds a tunable parameter.
      Parameters:
      path - path to the parameter (e.g., "Pipe1.heatTransferCoefficient")
      lowerBound - minimum allowed value
      upperBound - maximum allowed value
      Returns:
      this function for chaining
    • addMeasurement

      public ProcessSimulationFunction addMeasurement(String path)
      Adds a measured variable.
      Parameters:
      path - path to the measurement (e.g., "Manifold.outletStream.temperature")
      Returns:
      this function for chaining
    • addDataPointConditions

      public void addDataPointConditions(Map<String,Double> conditions)
      Adds conditions for a data point (operating conditions to apply before simulation).
      Parameters:
      conditions - map of path -> value for conditions
    • setCurrentIndices

      public void setCurrentIndices(int dataPointIndex, int measurementIndex)
      Sets the current data point and measurement indices for evaluation.
      Parameters:
      dataPointIndex - index of the data point
      measurementIndex - index of the measurement within the data point
    • setUseAnalyticalJacobian

      public void setUseAnalyticalJacobian(boolean useAnalytical)
      Enables or disables analytical Jacobian computation.

      When enabled, uses ProcessSensitivityAnalyzer to compute the Jacobian more efficiently, potentially reusing Broyden Jacobians from recycle convergence.

      Parameters:
      useAnalytical - true to use analytical Jacobian
    • initSensitivityAnalyzer

      private void initSensitivityAnalyzer()
      Initializes the sensitivity analyzer for Jacobian computation.
    • splitPath

      private String[] splitPath(String path)
      Splits a path like "Equipment.property" into parts.
      Parameters:
      path - the property path to split
      Returns:
      string array with equipment name and property name
    • calcValue

      public double calcValue(double[] dependentValues)

      calcValue.

      Calculates the model prediction for the current data point and measurement. The dependentValues array encodes [dataPointIndex, measurementIndex] to identify which prediction is requested.

      Specified by:
      calcValue in interface FunctionInterface
      Overrides:
      calcValue in class LevenbergMarquardtFunction
      Parameters:
      dependentValues - an array of type double
      Returns:
      a double
    • applyParameters

      private void applyParameters()
      Applies current parameter values to the process system.
    • applyConditions

      private void applyConditions(Map<String,Double> conditions)
      Applies operating conditions for a data point.
      Parameters:
      conditions - map of property paths to values
    • getPropertyValue

      private double getPropertyValue(String path)
      Gets a property value from the process using path-based access.
      Parameters:
      path - the property path (e.g., "Equipment.outletStream.temperature")
      Returns:
      the property value
    • setPropertyValue

      private void setPropertyValue(String path, double value)
      Sets a property value in the process using path-based access.
      Parameters:
      path - the property path
      value - the value to set
    • invokeGetter

      private Object invokeGetter(Object obj, String property) throws Exception
      Invokes a getter method on an object.
      Parameters:
      obj - the object to invoke getter on
      property - the property name
      Returns:
      the property value
      Throws:
      Exception - if reflection fails
    • invokeSetter

      private void invokeSetter(Object obj, String property, double value) throws Exception
      Invokes a setter method on an object.
      Parameters:
      obj - the object to invoke setter on
      property - the property name
      value - the value to set
      Throws:
      Exception - if reflection fails
    • setFittingParams

      public void setFittingParams(int i, double value)

      setFittingParams.

      Specified by:
      setFittingParams in interface FunctionInterface
      Overrides:
      setFittingParams in class LevenbergMarquardtFunction
      Parameters:
      i - a int
      value - a double
    • getParameterPaths

      public List<String> getParameterPaths()
      Gets the parameter paths.
      Returns:
      list of parameter paths
    • getMeasurementPaths

      public List<String> getMeasurementPaths()
      Gets the measurement paths.
      Returns:
      list of measurement paths
    • getParameterCount

      public int getParameterCount()
      Gets the number of parameters.
      Returns:
      number of tunable parameters
    • getMeasurementCount

      public int getMeasurementCount()
      Gets the number of measurements per data point.
      Returns:
      number of measurements
    • computeAnalyticalJacobian

      public SensitivityMatrix computeAnalyticalJacobian()
      Computes the Jacobian using ProcessSensitivityAnalyzer if enabled.

      This method is called by the L-M optimizer when analytical Jacobian is preferred over numerical differentiation.

      Returns:
      the sensitivity matrix, or null if analytical Jacobian is disabled
    • getSensitivity

      public double getSensitivity(int measurementIndex, int parameterIndex)
      Gets the sensitivity for a specific output/input pair from cached Jacobian.
      Parameters:
      measurementIndex - index of the measurement
      parameterIndex - index of the parameter
      Returns:
      the sensitivity value, or NaN if not available
    • getProcessSystem

      public ProcessSystem getProcessSystem()
      Gets the underlying process system.
      Returns:
      the process system