abstract class AlgebraicLoopDirector.AlgebraicLoopSolver
extends java.lang.Object
----------- | ----- | -->| g |--- x -----where x is initially the vector of values corresponding to input ports that have a non-null defaultValue parameter, and g is the network of actors connecting these ports.
For the SuccessiveSubstitution, we simply evaluate g repeatedly until either all signals do not change by more than the errorTolerance, or until there have been maxIterations. Note that it is possible to reach a fixed point where some or all signals are infinite.
For NewtonRaphson, we solve for g(x)=x by solving f(x)=0, where f(x) = g(x)-x. This is done by iterating as follows:
x_n+1 = x_n - f(x_n)/f'(x_n) = x_n - (g(x_n) - x_n)/(g'(x_n) - 1) .To estimate g'(x_n), we do
g'(x_n) = (g(x_n + d) - g(x_n))/dwhere d is the delta parameter.
For Homotopy, we solve f(x) = x - g(x) = 0. The problem is reformulated as H(x, lambda) = x - lambda g(x), where lambda has an initial value of 0 and is successively increased to 1. The implementation is equal to Program 3 of Eugene L. Allgower and Kurt Georg, Introduction to Numerical Continuation Methods, Classics in Applied Mathematics, Vol. 45, SIAM, 2003.
Modifier and Type | Field and Description |
---|---|
protected boolean |
_converged
Flag that indicates whether the solver converged
|
protected int |
_iterationCount
Number of iterations in the last call to the function solve(double[])
|
protected int |
_maxIterations
Maximum number of iterations
|
protected double[] |
_tolerance
Local view of the tolerance vector.
|
protected java.lang.String[] |
_variableNames
Variable names, used for error reporting
|
Constructor and Description |
---|
AlgebraicLoopSolver(java.lang.String[] variableNames,
double[] tolerance,
int maxIterations)
Construct an algebraic loop solver.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
_didConverge(double[] f)
Return true if each element of f is within the solver tolerance.
|
boolean |
converged()
Return true if the solver converged, false otherwise.
|
int |
getIterationCount()
Return the number of iterations done in the last call to the method solve(double[]).
|
abstract void |
solve(double[] xIni)
This method solves the fixed point iteration.
|
protected boolean _converged
protected int _iterationCount
protected int _maxIterations
protected double[] _tolerance
protected java.lang.String[] _variableNames
public AlgebraicLoopSolver(java.lang.String[] variableNames, double[] tolerance, int maxIterations) throws IllegalActionException
variableNames
- Names of each break variable.tolerance
- Tolerance for each variable.maxIterations
- Maximum number of iterations.IllegalActionException
public boolean converged()
public abstract void solve(double[] xIni) throws IllegalActionException
xIni
- Array with the initial values of the variables, to be replaced
with the solution by this method.IllegalActionException
- If the prefire() method
returns false having previously returned true in the same
iteration, or if the prefire() or fire() method of the actor
throws it, or if evaluating the function yields a value that
is not a double, or if the solver fails to find a solution.public int getIterationCount()
protected boolean _didConverge(double[] f)
f
- Value of residual function to be tested.