Class BroydenAccelerator
- All Implemented Interfaces:
Serializable
This class implements Broyden's "good" method for accelerating the convergence of multi-variable fixed-point iteration problems, particularly suited for process simulations with multiple coupled recycle streams.
The method approximates the Jacobian matrix of the fixed-point function and updates it using rank-one corrections based on the secant condition. This avoids the expensive computation of numerical derivatives while still providing Newton-like convergence.
Broyden's update formula: B_{k+1} = B_k + (delta_f - B_k * delta_x) * delta_x^T / (delta_x^T * delta_x)
Where: - B_k is the current Jacobian approximation (stored as inverse for efficiency) - delta_x = x_k - x_{k-1} (change in input) - delta_f = f(x_k) - f(x_{k-1}) (change in residual)
- Version:
- 1.0
- Author:
- Even Solbraa
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intMinimum number of iterations before applying acceleration.private intNumber of variables being accelerated.private static final doubleTolerance for detecting near-zero denominators.private double[][]Inverse Jacobian approximation (stored for efficiency using Sherman-Morrison).private intNumber of iterations performed.private static final org.apache.logging.log4j.LoggerLogger object for class.private doubleMaximum step size to prevent divergence.private double[]Previous iteration residual values (f(x) = g(x) - x).private double[]Previous iteration input values.private doubleRelaxation factor for damping updates (0 < factor <= 1).private static final longSerialization version UID. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Broyden accelerator.BroydenAccelerator(int dimension) Creates a new Broyden accelerator with specified dimension. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]accelerate(double[] currentX, double[] functionOutput) Computes the accelerated next iterate using Broyden's method.private doubledotProduct(double[] a, double[] b) Computes dot product of two vectors.intGets the number of delay iterations before acceleration starts.intGets the dimension of the problem.double[][]Gets a copy of the current inverse Jacobian approximation.intGets the current iteration count.doubleGets the maximum step size.doubleGets the relaxation factor.doubleGets the current residual norm (||f(x)||).voidinitialize(int dim) Initializes the accelerator for a given dimension.private double[]matrixVectorMultiply(double[][] matrix, double[] vector) Multiplies a matrix by a vector.voidreset()Resets the accelerator state while keeping the dimension.voidsetDelayIterations(int delayIterations) Sets the number of delay iterations before acceleration starts.voidsetMaxStepSize(double maxStepSize) Sets the maximum step size to prevent divergence.voidsetRelaxationFactor(double relaxationFactor) Sets the relaxation factor for damping updates.private voidupdateInverseJacobian(double[] deltaX, double[] deltaF) Updates the inverse Jacobian approximation using Broyden's "good" method.private doublevectorNorm(double[] v) Computes Euclidean norm of a vector.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
logger
private static final org.apache.logging.log4j.Logger loggerLogger object for class. -
dimension
private int dimensionNumber of variables being accelerated. -
inverseJacobian
private double[][] inverseJacobianInverse Jacobian approximation (stored for efficiency using Sherman-Morrison). -
previousX
private double[] previousXPrevious iteration input values. -
previousF
private double[] previousFPrevious iteration residual values (f(x) = g(x) - x). -
iterationCount
private int iterationCountNumber of iterations performed. -
delayIterations
private int delayIterationsMinimum number of iterations before applying acceleration. -
relaxationFactor
private double relaxationFactorRelaxation factor for damping updates (0 < factor <= 1). -
maxStepSize
private double maxStepSizeMaximum step size to prevent divergence. -
EPSILON
private static final double EPSILONTolerance for detecting near-zero denominators.- See Also:
-
-
Constructor Details
-
BroydenAccelerator
public BroydenAccelerator()Creates a new Broyden accelerator. -
BroydenAccelerator
public BroydenAccelerator(int dimension) Creates a new Broyden accelerator with specified dimension.- Parameters:
dimension- number of variables to accelerate
-
-
Method Details
-
initialize
public void initialize(int dim) Initializes the accelerator for a given dimension. Must be called before first use or when dimension changes.- Parameters:
dim- number of variables
-
reset
public void reset()Resets the accelerator state while keeping the dimension. -
accelerate
public double[] accelerate(double[] currentX, double[] functionOutput) Computes the accelerated next iterate using Broyden's method.Given the current iterate x and the fixed-point function output g(x), this method computes an accelerated next iterate that should converge faster than direct substitution (x_{n+1} = g(x_n)).
- Parameters:
currentX- current input values (x_n)functionOutput- output from fixed-point function (g(x_n))- Returns:
- accelerated next iterate
-
updateInverseJacobian
private void updateInverseJacobian(double[] deltaX, double[] deltaF) Updates the inverse Jacobian approximation using Broyden's "good" method.Uses Sherman-Morrison formula for efficient rank-one update of the inverse: B^{-1}_{k+1} = B^{-1}_k + (delta_x - B^{-1}_k * delta_f) * delta_x^T * B^{-1}_k / (delta_x^T * B^{-1}_k * delta_f)
- Parameters:
deltaX- change in input (x_k - x_{k-1})deltaF- change in residual (f_k - f_{k-1})
-
matrixVectorMultiply
private double[] matrixVectorMultiply(double[][] matrix, double[] vector) Multiplies a matrix by a vector.- Parameters:
matrix- the matrixvector- the vector- Returns:
- result vector
-
dotProduct
private double dotProduct(double[] a, double[] b) Computes dot product of two vectors.- Parameters:
a- first vectorb- second vector- Returns:
- dot product
-
vectorNorm
private double vectorNorm(double[] v) Computes Euclidean norm of a vector.- Parameters:
v- the vector- Returns:
- norm
-
getIterationCount
public int getIterationCount()Gets the current iteration count.- Returns:
- iteration count
-
getDelayIterations
public int getDelayIterations()Gets the number of delay iterations before acceleration starts.- Returns:
- delay iterations
-
setDelayIterations
public void setDelayIterations(int delayIterations) Sets the number of delay iterations before acceleration starts.- Parameters:
delayIterations- number of iterations to delay
-
getRelaxationFactor
public double getRelaxationFactor()Gets the relaxation factor.- Returns:
- relaxation factor (0 < factor <= 1)
-
setRelaxationFactor
public void setRelaxationFactor(double relaxationFactor) Sets the relaxation factor for damping updates. Values less than 1.0 provide damping for difficult convergence cases.- Parameters:
relaxationFactor- factor between 0 and 1
-
getMaxStepSize
public double getMaxStepSize()Gets the maximum step size.- Returns:
- maximum step size
-
setMaxStepSize
public void setMaxStepSize(double maxStepSize) Sets the maximum step size to prevent divergence.- Parameters:
maxStepSize- maximum allowed step norm
-
getDimension
public int getDimension()Gets the dimension of the problem.- Returns:
- number of variables
-
getInverseJacobian
public double[][] getInverseJacobian()Gets a copy of the current inverse Jacobian approximation.- Returns:
- copy of inverse Jacobian matrix
-
getResidualNorm
public double getResidualNorm()Gets the current residual norm (||f(x)||).- Returns:
- residual norm, or -1 if not yet computed
-