Class DerivativeLineMultiOptimizer

Direct Known Subclasses:
DerivativeConjugateGradientMultiOptimizer

public abstract class DerivativeLineMultiOptimizer extends MultiOptimizer
Class to find a minimum on a multidimensional function along a given line of input values. The difference between this abstract class and LineMultiOptimizer is that subclasses of this class will use the function gradient information. By using gradient information, typically convergence is faster, although, if gradient does not have a closed expression, then a GradientEstimator will be needed in the gradient listener provided to this class. Notice that a GradientEstimator might estimate gradients with a certain error, so depending on the function topology, LineMultiOptimizer subclasses might obtain greater accuracy than subclasses of this class.
  • Field Details

    • p

      protected double[] p
      n-dimensional point containing a minimum in a given line.
    • xi

      protected double[] xi
      Direction to make the search.
    • n

      private int n
      Number of dimensions on function being evaluated.
    • gradientListener

      protected GradientFunctionEvaluatorListener gradientListener
      Listener to evaluate the function's gradient. If the function's gradient is not know (e.g. does not have a closed expression), then a GradientEstimator might be used inside the listener implementation.
    • evaluator

      private DirectionalDerivativeEvaluator evaluator
      Class in charge of evaluating a function through a given line.
    • dbrent

      Internal optimizer to find a minimum of a function along a line of input values. Hence, input is converted to a single dimension using a DirectionalEvaluator.
  • Constructor Details

    • DerivativeLineMultiOptimizer

      protected DerivativeLineMultiOptimizer()
      Empty constructor.
    • DerivativeLineMultiOptimizer

      protected DerivativeLineMultiOptimizer(MultiDimensionFunctionEvaluatorListener listener, GradientFunctionEvaluatorListener gradientListener, double[] point, double[] direction)
      Constructor.
      Parameters:
      listener - Listener to evaluate a multi-dimension function.
      gradientListener - Listener to evaluate the function's gradient.
      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.
      direction - Direction to start looking for a minimum. Provided array must have the same length as the number of dimensions of the function being evaluated. Provided direction is considered as a vector pointing to the minimum to be found.
      Throws:
      IllegalArgumentException - Raised if provided point and direction don't have the same length.
  • Method Details

    • isStartPointAvailable

      public boolean isStartPointAvailable()
      Returns boolean indicating whether start point has already been provided and is ready for retrieval.
      Returns:
      True if available, false otherwise.
    • getStartPoint

      public double[] getStartPoint() throws NotAvailableException
      Returns start point where algorithm will be started. Start point should be close to the local minimum to be found.
      Returns:
      Start point where algorithm will be started.
      Throws:
      NotAvailableException - Raised if start point has not yet been provided and is not available.
    • isDirectionAvailable

      public boolean isDirectionAvailable()
      Returns boolean indicating whether direction has already been provided and is ready for retrieval.
      Returns:
      True if available, false otherwise.
    • getDirection

      public double[] getDirection() throws NotAvailableException
      Returns direction to start looking for a minimum. Provided array must have the same length as the number of dimensions of the function being evaluated. Provided direction is considered as a vector pointing to the minimum to be found.
      Returns:
      Direction to start looking for a minimum.
      Throws:
      NotAvailableException - Raised if direction has not yet been provided and is not available.
    • internalSetStartPointAndDirection

      private void internalSetStartPointAndDirection(double[] point, double[] direction)
      Internal method to set start point and direction to start the search for a local 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.
      direction - Direction to start looking for a minimum. Provided array must have the same length as the number of dimensions of the function being evaluated. Provided direction is considered as a vector pointing to the minimum to be found.
      Throws:
      IllegalArgumentException - Raised if provided point and direction don't have the same length.
    • setStartPointAndDirection

      public void setStartPointAndDirection(double[] point, double[] direction) throws LockedException
      Internal method to set start point and direction to start the search for a local 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.
      direction - Direction to start looking for a minimum. Provided array must have the same length as the number of dimensions of the function being evaluated. Provided direction is considered as a vector pointing to the minimum to be found.
      Throws:
      LockedException - Raised if this instance is locked.
      IllegalArgumentException - Raised if provided point and direction don't have the same length.
    • isReady

      public boolean isReady()
      Returns boolean indicating whether this instance is considered to be ready to start the estimation of a minimum. This instance is considered to be ready once a listener, gradient listener, start point and direction are provided.
      Overrides:
      isReady in class MultiOptimizer
      Returns:
      True if this instance is ready, false otherwise.
    • getGradientListener

      public GradientFunctionEvaluatorListener getGradientListener() throws NotAvailableException
      Returns gradient listener. The gradient listener is used to evaluate the function's gradient. If the function's gradient is not know (e.g. does not have a closed expression), then a GradientEstimator might be used inside the listener implementation.
      Returns:
      Gradient listener.
      Throws:
      NotAvailableException - Raised if gradient listener is not available for retrieval.
    • setGradientListener

      public void setGradientListener(GradientFunctionEvaluatorListener gradientListener) throws LockedException
      Sets gradient listener. The gradient listener is used to evaluate the function's gradient. If the function's gradient is not know (e.g. does not have a closed expression), then a GradientEstimator might be used inside the listener implementation.
      Parameters:
      gradientListener - Gradient listener.
      Throws:
      LockedException - Raised if this instance is locked.
    • isGradientListenerAvailable

      public boolean isGradientListenerAvailable()
      Returns boolean indicating whether the gradient listener has been provided and is available for retrieval.
      Returns:
      True if available, false otherwise.
    • linmin

      protected double linmin()
      Searches for a minimum along a given line of input values. The line being searched is obtained by using a start point and direction.
      Returns:
      Returns function evaluation at minimum that has been found.