Class ZeroSystem
- All Implemented Interfaces:
Serializable,Cloneable
ZeroSystem is based on the MINPACK subroutine HYBRDJ
, which uses a modification of M.J.D. Powell's hybrid algorithm. This
algorithm is a variation of Newton's method, which uses a finite-difference
approximation to the Jacobian and takes precautions to avoid large step sizes
or increasing residuals. For further description, see More et al. (1980).
A finite-difference method is used to estimate the Jacobian. Whenever the
exact Jacobian can be easily provided, objectF should implement
ZeroSystem.Jacobian.
Note that one can use the JDK 1.4 JAVA Logging API to generate intermediate output for the solver. Accumulated levels of detail correspond to JAVA's CONFIG, FINE, FINER, and FINEST logging levels with CONFIG yielding the smallest amount of information and FINEST yielding the most. The levels of output yield the following:
| Level | Output |
| CONFIG | Iteration increments are printed. |
| FINE | Prints convergnce tests. |
| FINER | Intermediate solution values are provided. |
| FINEST | Tracks progress through internal methods. |
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe iteration did not converge.static interfacePublic interface for user supplied function toZeroSystemobject.static interfacePublic interface for user supplied function toZeroSystemobject.static classTolerance too smallstatic classToo many iterations. -
Constructor Summary
ConstructorsConstructorDescriptionZeroSystem(int n) Creates an object to find the zeros of a system of n equations. -
Method Summary
Modifier and TypeMethodDescriptionReturns the logger object.voidsetGuess(double[] xguess) Sets the initial estimate of the root.voidsetMaxIterations(int maxIterations) Sets the maximum number of iterations allowed.voidsetRelativeError(double errorRelative) Sets the relative error tolerance.double[]solve(ZeroSystem.Function objectF) Solve a system of nonlinear equations using the modified Powell hybrid algorithm
-
Constructor Details
-
ZeroSystem
public ZeroSystem(int n) Creates an object to find the zeros of a system of n equations.- Parameters:
n- anintindicating the number of equations to be solved and the number of unknowns.
-
-
Method Details
-
setGuess
public void setGuess(double[] xguess) Sets the initial estimate of the root. The default is to setxguessto all zeros.- Parameters:
xguess- adoublearray containing the initial guess. The length ofxguessmust be equal to the number of equations.
-
setMaxIterations
public void setMaxIterations(int maxIterations) Sets the maximum number of iterations allowed. The default value is 200.- Parameters:
maxIterations- anintspecifying the maximum number of iterations allowed- Throws:
IllegalArgumentException- is thrown if maxIterations is less than or equal to zero.
-
setRelativeError
public void setRelativeError(double errorRelative) Sets the relative error tolerance. The root is accepted if the relative error between two successive approximations to this root is within errorRelative. The default is the square root of the precision, about 1.0e-08.- Parameters:
errorRelative- adoublespecifying the relative error tolerance- Throws:
IllegalArgumentException- is thrown iferrorRelativeis less than 0 or greater than 1.
-
getLogger
Returns the logger object.- Returns:
- a
java.util.logging.Loggerobject, if present, ornull.
-
solve
public double[] solve(ZeroSystem.Function objectF) throws ZeroSystem.TooManyIterationsException, ZeroSystem.ToleranceTooSmallException, ZeroSystem.DidNotConvergeException Solve a system of nonlinear equations using the modified Powell hybrid algorithm- Parameters:
objectF- aZeroSystem.Functionthat defines the function whose zero is to be found. IfobjectFimplements a Jacobian then its Jacobian is used. Otherwise a finite difference is computed.- Returns:
- a
doublearray containing the solution - Throws:
ZeroSystem.TooManyIterationsException- is thrown if the maximum number of iterations is exceededZeroSystem.ToleranceTooSmallException- is thrown if the error tolerance is too smallZeroSystem.DidNotConvergeException- is thrown if the algorithm does not converge- See Also:
-