Class BatchParameterEstimator
java.lang.Object
neqsim.process.calibration.BatchParameterEstimator
- All Implemented Interfaces:
Serializable
Batch parameter estimator using Levenberg-Marquardt optimization.
This class provides batch (offline) parameter estimation for process models using historical or experimental data. It bridges the process calibration framework with NeqSim's existing Levenberg-Marquardt optimizer in the statistics package.
When to use BatchParameterEstimator vs EnKFParameterEstimator:
- Multiple parameters, batch/historical data: BatchParameterEstimator (this class)
- Live streaming data, uncertainty tracking: EnKFParameterEstimator
- Single parameter tuning: Adjuster class
Usage Example:
// 1. Build your process
ProcessSystem process = buildProductionNetwork();
// 2. Create batch estimator
BatchParameterEstimator estimator = new BatchParameterEstimator(process);
// 3. Define parameters to estimate
estimator.addTunableParameter("Pipe1.heatTransferCoefficient", "W/(m2·K)", 1.0, 100.0, 15.0);
estimator.addTunableParameter("Pipe2.heatTransferCoefficient", "W/(m2·K)", 1.0, 100.0, 15.0);
// 4. Define measurements
estimator.addMeasuredVariable("Manifold.outletStream.temperature", "C", 0.5);
// 5. Add historical data points
for (HistoricalRecord record : historicalData) {
Map<String, Double> conditions = new HashMap<>();
conditions.put("feedStream.flowRate", record.getFlowRate());
Map<String, Double> measurements = new HashMap<>();
measurements.put("Manifold.outletStream.temperature", record.getOutletTemp());
estimator.addDataPoint(conditions, measurements);
}
// 6. Configure and solve
estimator.setMaxIterations(100);
BatchResult result = estimator.solve();
// 7. Use results
result.printSummary();
double[] estimates = result.getEstimates();
double[] uncertainties = result.getUncertainties();
- Version:
- 1.0
- Author:
- ESOL
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a data point with conditions and measurements.static classRepresents a measured variable.static classRepresents a tunable parameter. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<BatchParameterEstimator.DataPoint> Data points for calibration.private ProcessSimulationFunctionThe underlying function for the optimizer.private BatchResultResult from the last solve.(package private) static org.apache.logging.log4j.LoggerLogger object for class.private intMaximum number of iterations.private final List<BatchParameterEstimator.MeasuredVariable> Measured variables.private LevenbergMarquardtThe Levenberg-Marquardt optimizer.private final ProcessSystemThe process system to calibrate.private static final longprivate final List<BatchParameterEstimator.TunableParameter> Tunable parameters.private booleanWhether to use analytical Jacobian from ProcessSensitivityAnalyzer. -
Constructor Summary
ConstructorsConstructorDescriptionBatchParameterEstimator(ProcessSystem processSystem) Creates a new batch parameter estimator. -
Method Summary
Modifier and TypeMethodDescriptionaddDataPoint(Map<String, Double> measurements) Adds a data point with only measurements (no condition changes).Adds a data point for calibration.addMeasuredVariable(String path, String unit, double standardDeviation) Adds a measured variable.addTunableParameter(String path, String unit, double lowerBound, double upperBound, double initialGuess) Adds a tunable parameter.private ProcessSimulationFunctionBuilds the ProcessSimulationFunction.private BatchResultBuilds the result from the optimizer output.private SampleSetBuilds the SampleSet for the optimizer.Clears all data points.private double[]Computes additional statistics: [MAD, bias, R-squared].private doubleComputes chi-square from the sample set.voidDisplays the curve fit using the optimizer's built-in visualization.voidDisplays the result using the optimizer's built-in visualization.private doubleGets the chi-square value from the optimizer.private double[][]Gets the correlation matrix from the optimizer.private double[][]Gets the covariance matrix from the optimizer.intGets the number of data points.Gets the result from the last solve.String[]Gets the measurement names.Gets the underlying optimizer (for advanced use).String[]Gets the parameter names.private double[]Gets parameter standard deviations from the optimizer.Gets the underlying process system.reset()Resets the estimator to initial state.voidrunMonteCarloSimulation(int numRuns) Runs Monte Carlo simulation for uncertainty analysis.setMaxIterations(int maxIterations) Sets the maximum number of iterations.setUseAnalyticalJacobian(boolean useAnalytical) Enables or disables analytical Jacobian computation.solve()Runs the Levenberg-Marquardt optimization.Converts the last result to a CalibrationResult for API compatibility.private voidValidates the configuration before solving.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
logger
static org.apache.logging.log4j.Logger loggerLogger object for class. -
processSystem
The process system to calibrate. -
tunableParameters
Tunable parameters. -
measuredVariables
Measured variables. -
dataPoints
Data points for calibration. -
maxIterations
private int maxIterationsMaximum number of iterations. -
useAnalyticalJacobian
private boolean useAnalyticalJacobianWhether to use analytical Jacobian from ProcessSensitivityAnalyzer. -
function
The underlying function for the optimizer. -
optimizer
The Levenberg-Marquardt optimizer. -
lastResult
Result from the last solve.
-
-
Constructor Details
-
BatchParameterEstimator
Creates a new batch parameter estimator.- Parameters:
processSystem- the process system to calibrate
-
-
Method Details
-
addTunableParameter
public BatchParameterEstimator addTunableParameter(String path, String unit, double lowerBound, double upperBound, double initialGuess) Adds a tunable parameter.- Parameters:
path- path to the parameter (e.g., "Pipe1.heatTransferCoefficient")unit- unit of the parameterlowerBound- minimum allowed valueupperBound- maximum allowed valueinitialGuess- initial guess for optimization- Returns:
- this estimator for chaining
-
addMeasuredVariable
public BatchParameterEstimator addMeasuredVariable(String path, String unit, double standardDeviation) Adds a measured variable.- Parameters:
path- path to the measurement (e.g., "Manifold.outletStream.temperature")unit- unit of the measurementstandardDeviation- measurement uncertainty (noise standard deviation)- Returns:
- this estimator for chaining
-
addDataPoint
-
addDataPoint
Adds a data point with only measurements (no condition changes).- Parameters:
measurements- measured values (path -> value)- Returns:
- this estimator for chaining
-
setMaxIterations
Sets the maximum number of iterations.- Parameters:
maxIterations- maximum iterations- Returns:
- this estimator for chaining
-
setUseAnalyticalJacobian
Enables or disables analytical Jacobian computation.When enabled, uses
ProcessSensitivityAnalyzerfor more efficient derivative computation, potentially reusing Broyden Jacobians from recycle convergence.- Parameters:
useAnalytical- true to use analytical Jacobian- Returns:
- this estimator for chaining
-
solve
Runs the Levenberg-Marquardt optimization.- Returns:
- the optimization result
-
validateConfiguration
private void validateConfiguration()Validates the configuration before solving. -
buildFunction
Builds the ProcessSimulationFunction.- Returns:
- the constructed ProcessSimulationFunction
-
buildSampleSet
Builds the SampleSet for the optimizer.- Returns:
- the constructed SampleSet
-
buildResult
Builds the result from the optimizer output.- Returns:
- the constructed BatchResult
-
getChiSquareFromOptimizer
private double getChiSquareFromOptimizer()Gets the chi-square value from the optimizer.- Returns:
- the chi-square value
-
computeChiSquare
private double computeChiSquare()Computes chi-square from the sample set.- Returns:
- the computed chi-square value
-
getParameterStandardDeviations
private double[] getParameterStandardDeviations()Gets parameter standard deviations from the optimizer.- Returns:
- array of parameter standard deviations
-
getCoVarianceMatrix
private double[][] getCoVarianceMatrix()Gets the covariance matrix from the optimizer.- Returns:
- the covariance matrix
-
getCorrelationMatrix
private double[][] getCorrelationMatrix()Gets the correlation matrix from the optimizer.- Returns:
- the correlation matrix
-
computeAdditionalStatistics
private double[] computeAdditionalStatistics()Computes additional statistics: [MAD, bias, R-squared].- Returns:
- array of additional statistics
-
getLastResult
Gets the result from the last solve.- Returns:
- the last result, or null if not yet solved
-
toCalibrationResult
Converts the last result to a CalibrationResult for API compatibility.- Returns:
- calibration result, or failure if not yet solved
-
getParameterNames
-
getMeasurementNames
Gets the measurement names.- Returns:
- array of measurement paths
-
getDataPointCount
public int getDataPointCount()Gets the number of data points.- Returns:
- number of data points
-
getProcessSystem
Gets the underlying process system.- Returns:
- the process system
-
getOptimizer
Gets the underlying optimizer (for advanced use).- Returns:
- the L-M optimizer, or null if not yet solved
-
clearDataPoints
Clears all data points.- Returns:
- this estimator for chaining
-
reset
Resets the estimator to initial state.- Returns:
- this estimator for chaining
-
displayCurveFit
public void displayCurveFit()Displays the curve fit using the optimizer's built-in visualization. -
displayResult
public void displayResult()Displays the result using the optimizer's built-in visualization. -
runMonteCarloSimulation
public void runMonteCarloSimulation(int numRuns) Runs Monte Carlo simulation for uncertainty analysis.- Parameters:
numRuns- number of Monte Carlo runs
-