Package pal.math

Class LineFunction

  • All Implemented Interfaces:
    UnivariateFunction

    public class LineFunction
    extends java.lang.Object
    implements UnivariateFunction
    converts a multivariate function into a univariate function
    Author:
    Korbinian Strimmer
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int checkDirection​(double[] p, double[] dir)
      check direction vector.
      boolean checkPoint​(double[] p)
      check (and modify, if necessary) whether a point lies properly within the predefined bounds
      int checkVariables​(double[] p, double[] grad, boolean[] active)
      determine active variables at a point p and corresponding gradient grad (if a component of p lies on a border and the corresponding component of the gradient points out of the border the variable is considered inactive)
      double evaluate​(double lambda)
      evaluate f(start+lambda*dir)
      double findMinimum()
      find parameter lambda within the given bounds that minimizes the univariate function (due to numerical inaccuaries it may happen that getPoint for the returned lambda produces a point that lies slightly out of bounds)
      double getLowerBound()
      get lower bound of argument
      int getLowerBoundParameter()
      get parameter that limits the lower bound
      void getPoint​(double lambda, double[] p)
      get point associated with the one-dimensional parameter (bounds of of multivariate function are NOT checked)
      double getUpperBound()
      get upper bound of argument
      int getUpperBoundParameter()
      get parameter that limits the upper bound
      void update​(double[] start, double[] dir)
      update start point and direction (bounds and search direction are NOT checked)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LineFunction

        public LineFunction​(MultivariateFunction func)
        construct univariate function from multivariate function
        Parameters:
        func - multivariate function
        start - start point
        dir - direction vector
    • Method Detail

      • update

        public void update​(double[] start,
                           double[] dir)
        update start point and direction (bounds and search direction are NOT checked)
        Parameters:
        start - new start point
        dir - new direction vector
      • getPoint

        public void getPoint​(double lambda,
                             double[] p)
        get point associated with the one-dimensional parameter (bounds of of multivariate function are NOT checked)
        Parameters:
        lambda - argument
        p - array for coordinates of corresponding point
      • evaluate

        public double evaluate​(double lambda)
        evaluate f(start+lambda*dir)
        Specified by:
        evaluate in interface UnivariateFunction
        Returns:
        function value
      • findMinimum

        public double findMinimum()
        find parameter lambda within the given bounds that minimizes the univariate function (due to numerical inaccuaries it may happen that getPoint for the returned lambda produces a point that lies slightly out of bounds)
        Returns:
        lambda that achieves minimum
      • getUpperBoundParameter

        public int getUpperBoundParameter()
        get parameter that limits the upper bound
        Returns:
        parameter number
      • getLowerBoundParameter

        public int getLowerBoundParameter()
        get parameter that limits the lower bound
        Returns:
        parameter number
      • checkPoint

        public boolean checkPoint​(double[] p)
        check (and modify, if necessary) whether a point lies properly within the predefined bounds
        Parameters:
        p - coordinates of point
        Returns:
        true if p was modified, false otherwise
      • checkVariables

        public int checkVariables​(double[] p,
                                  double[] grad,
                                  boolean[] active)
        determine active variables at a point p and corresponding gradient grad (if a component of p lies on a border and the corresponding component of the gradient points out of the border the variable is considered inactive)
        Parameters:
        p - coordinates of point
        grad - gradient at that point
        list - of active variables (on return)
        Returns:
        number of active variables
      • checkDirection

        public int checkDirection​(double[] p,
                                  double[] dir)
        check direction vector. If it points out of the defined area at a point at the boundary the corresponding component of the direction vector is set to zero.
        Parameters:
        p - coordinates of point
        dir - direction vector at that point
        Returns:
        number of changed components in direction vector