Class PowellMultiOptimizer
java.lang.Object
com.irurueta.numerical.optimization.Optimizer
com.irurueta.numerical.optimization.MultiOptimizer
com.irurueta.numerical.optimization.LineMultiOptimizer
com.irurueta.numerical.optimization.PowellMultiOptimizer
This class searches for a multi dimension function local minimum.
The local minimum is searched by starting the algorithm at a start point
and a given direction which should be close and point to the local minimum to
be found to achieve the best accuracy with the lowest number of iterations.
The implementation of this class is based on Numerical Recipes 3rd ed.
Section 10.7 page 509.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
Constant defining default tolerance or accuracy to be achieved on the minimum being estimated by this class.private double
Value of the function at the minimum.private int
Member contains number of iterations that were needed to estimate a minimum.static final int
Maximum allowed iterations.static final double
Minimum allowed tolerance value.static final double
A small number.private double
The fractional tolerance in the function value such that failure to decrease by more than this amount on one iteration signals doneness.private com.irurueta.algebra.Matrix
Set of directions.Fields inherited from class com.irurueta.numerical.optimization.LineMultiOptimizer
p, xi
Fields inherited from class com.irurueta.numerical.optimization.MultiOptimizer
fmin, listener, resultAvailable, xmin
Fields inherited from class com.irurueta.numerical.optimization.Optimizer
iterationCompletedListener, locked
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor.PowellMultiOptimizer
(MultiDimensionFunctionEvaluatorListener listener, double tolerance) Constructor.PowellMultiOptimizer
(MultiDimensionFunctionEvaluatorListener listener, double[] point, com.irurueta.algebra.Matrix directions, double tolerance) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns boolean indicating whether set of directions is available for retrieval.private void
Internal method to build or rebuild the set of directions if needed.com.irurueta.algebra.Matrix
Returns set of directions to start looking for a minimum.double
Returns tolerance or accuracy to be expected on estimated local minimum.private void
internalSetPointAndDirections
(double[] point, com.irurueta.algebra.Matrix directions) Internal method to set start point and set of directions to start looking for minimum.private void
internalSetTolerance
(double tolerance) Internal method to set tolerance or accuracy to be expected on estimated local minimum.boolean
isReady()
Returns boolean indicating whether this instance is ready to start the estimation of a local minimum.void
minimize()
This function estimates a function minimum.void
setPointAndDirections
(double[] point, com.irurueta.algebra.Matrix directions) Sets start point and set of directions to start looking for minimum.void
setStartPoint
(double[] startPoint) Sets start point where local minimum is searched nearby.void
setTolerance
(double tolerance) Sets tolerance or accuracy to be expected on estimated local minimum.private double
sqr
(double x) Computes the squared value of provided double.Methods inherited from class com.irurueta.numerical.optimization.LineMultiOptimizer
getDirection, getStartPoint, isDirectionAvailable, isStartPointAvailable, linmin, setStartPointAndDirection
Methods inherited from class com.irurueta.numerical.optimization.MultiOptimizer
getEvaluationAtResult, getListener, getResult, isListenerAvailable, isResultAvailable, setListener
Methods inherited from class com.irurueta.numerical.optimization.Optimizer
getOnIterationCompletedListener, isLocked, setOnIterationCompletedListener
-
Field Details
-
DEFAULT_TOLERANCE
public static final double DEFAULT_TOLERANCEConstant defining default tolerance or accuracy to be achieved on the minimum being estimated by this class.- See Also:
-
MIN_TOLERANCE
public static final double MIN_TOLERANCEMinimum allowed tolerance value.- See Also:
-
ITMAX
public static final int ITMAXMaximum allowed iterations.- See Also:
-
TINY
public static final double TINYA small number.- See Also:
-
tolerance
private double toleranceThe fractional tolerance in the function value such that failure to decrease by more than this amount on one iteration signals doneness. -
iter
private int iterMember contains number of iterations that were needed to estimate a minimum. -
fret
private double fretValue of the function at the minimum. -
ximat
private com.irurueta.algebra.Matrix ximatSet of directions.
-
-
Constructor Details
-
PowellMultiOptimizer
public PowellMultiOptimizer()Empty constructor. -
PowellMultiOptimizer
Constructor.- Parameters:
listener
- Listener to evaluate a multidimensional function.tolerance
- Tolerance or accuracy to be expected on estimated local minimum.- Throws:
IllegalArgumentException
- Raised if tolerance is negative.
-
PowellMultiOptimizer
public PowellMultiOptimizer(MultiDimensionFunctionEvaluatorListener listener, double[] point, com.irurueta.algebra.Matrix directions, double tolerance) Constructor.- Parameters:
listener
- Listener to evaluate a multidimensional function.point
- Start point where algorithm will be started. Start point should be close to the local minimum to be found. Provided array must have a length equal to the number of dimensions of the function being evaluated, otherwise and exception will be raised when searching for the minimum.directions
- Set of directions to start looking for a minimum. Provided matrix must have the same rows as the number of dimensions of the function being evaluated. Each column will be a direction to search for a minimum.tolerance
- Tolerance or accuracy to be expected on estimated local minimum.- Throws:
IllegalArgumentException
- Raised if provided point and direction don't have the same length or if provided tolerance is negative.
-
-
Method Details
-
getDirections
Returns set of directions to start looking for a minimum. Returned matrix will have the same number of rows as the number of dimensions of the function (or the start point). Each column of the matrix will represent a vector containing a direction to search for a minimum.- Returns:
- Set of directions.
- Throws:
NotAvailableException
- Raised if this has not yet been provided or computed.
-
areDirectionsAvailable
public boolean areDirectionsAvailable()Returns boolean indicating whether set of directions is available for retrieval.- Returns:
- True if available, false otherwise.
-
setPointAndDirections
public void setPointAndDirections(double[] point, com.irurueta.algebra.Matrix directions) throws LockedException Sets start point and set of directions to start looking for minimum.- Parameters:
point
- Start point where algorithm will be started. Start point should be close to the local minimum to be found. Provided array must have a length equal to the number of dimensions of the function being evaluated, otherwise and exception will be raised when searching for the minimum.directions
- Set of directions to start looking for a minimum. Provided matrix must have the same rows as the number of dimensions of the function being evaluated. Each column will be a direction to search for a minimum.- Throws:
LockedException
- Raised if this instance is locked.IllegalArgumentException
- Raised if provided point and direction don't have the same length.
-
setStartPoint
Sets start point where local minimum is searched nearby.- Parameters:
startPoint
- Start point to search for a local minimum- Throws:
LockedException
- Raised if this instance is locked.
-
getTolerance
public double getTolerance()Returns tolerance or accuracy to be expected on estimated local minimum.- Returns:
- Tolerance or accuracy to be expected on estimated local minimum.
-
internalSetTolerance
private void internalSetTolerance(double tolerance) Internal method to set tolerance or accuracy to be expected on estimated local minimum. This method does not check whether this instance is locked.- Parameters:
tolerance
- Tolerance or accuracy to be expected on estimated local minimum.- Throws:
IllegalArgumentException
- Raised if provided tolerance is negative.
-
setTolerance
Sets tolerance or accuracy to be expected on estimated local minimum.- Parameters:
tolerance
- Tolerance or accuracy to be expected on estimated local minimum.- Throws:
LockedException
- Raised if this instance is locked.IllegalArgumentException
- Raised if provided tolerance is negative.
-
minimize
This function estimates a function minimum. Implementations of this class will usually search a local minimum close to a start point and will start looking into provided start direction. Minimization of a function f. Input consists of an initial starting point p. The initial matrix ximat, whose columns contain the initial set of directions, is set to the identity. Returned is the best point found, at which point fret is the minimum function value and iter is the number of iterations taken.- Overrides:
minimize
in classOptimizer
- Throws:
LockedException
- Raised if this instance is locked, because estimation is being computed.NotReadyException
- Raised if this instance is not ready, because a listener, a gradient listener and a start point haven't been provided.OptimizationException
- Raised if the algorithm failed because of lack of convergence or because function couldn't be evaluated.
-
isReady
public boolean isReady()Returns boolean indicating whether this instance is ready to start the estimation of a local minimum. An instance is ready once a listener and a start point are provided.- Overrides:
isReady
in classLineMultiOptimizer
- Returns:
- True if this instance is ready, false otherwise.
-
internalSetPointAndDirections
private void internalSetPointAndDirections(double[] point, com.irurueta.algebra.Matrix directions) Internal method to set start point and set of directions to start looking for minimum. This method does not check whether this instance is locked.- Parameters:
point
- Start point where algorithm will be started. Start point should be close to the local minimum to be found. Provided array must have a length equal to the number of dimensions of the function being evaluated, otherwise and exception will be raised when searching for the minimum.directions
- Set of directions to start looking for a minimum. Provided matrix must have the same rows as the number of dimensions of the function being evaluated. Each column will be a direction to search for a minimum.- Throws:
IllegalArgumentException
- Raised if provided point and direction don't have the same length.
-
buildDirections
Internal method to build or rebuild the set of directions if needed.- Throws:
NotReadyException
- Raised if no start point has yet been provided.
-
sqr
private double sqr(double x) Computes the squared value of provided double.- Parameters:
x
- Value to be squared.- Returns:
- Squared value.
-