Class PowellMultiOptimizer


public class PowellMultiOptimizer extends LineMultiOptimizer
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 Details

    • DEFAULT_TOLERANCE

      public static final double DEFAULT_TOLERANCE
      Constant 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_TOLERANCE
      Minimum allowed tolerance value.
      See Also:
    • ITMAX

      public static final int ITMAX
      Maximum allowed iterations.
      See Also:
    • TINY

      public static final double TINY
      A small number.
      See Also:
    • tolerance

      private double tolerance
      The fractional tolerance in the function value such that failure to decrease by more than this amount on one iteration signals doneness.
    • iter

      private int iter
      Member contains number of iterations that were needed to estimate a minimum.
    • fret

      private double fret
      Value of the function at the minimum.
    • ximat

      private com.irurueta.algebra.Matrix ximat
      Set of directions.
  • Constructor Details

    • PowellMultiOptimizer

      public PowellMultiOptimizer()
      Empty constructor.
    • PowellMultiOptimizer

      public PowellMultiOptimizer(MultiDimensionFunctionEvaluatorListener listener, double tolerance)
      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

      public com.irurueta.algebra.Matrix getDirections() throws NotAvailableException
      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

      public void setStartPoint(double[] startPoint) throws LockedException
      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

      public void setTolerance(double tolerance) throws LockedException
      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

      public void minimize() throws LockedException, NotReadyException, OptimizationException
      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 class Optimizer
      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 class LineMultiOptimizer
      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

      private void buildDirections() throws NotReadyException
      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.