Package pal.math
Class LineFunction
- java.lang.Object
-
- pal.math.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
-
-
Constructor Summary
Constructors Constructor Description LineFunction(MultivariateFunction func)
construct univariate function from multivariate function
-
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 boundsint
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 argumentint
getLowerBoundParameter()
get parameter that limits the lower boundvoid
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 argumentint
getUpperBoundParameter()
get parameter that limits the upper boundvoid
update(double[] start, double[] dir)
update start point and direction (bounds and search direction are NOT checked)
-
-
-
Constructor Detail
-
LineFunction
public LineFunction(MultivariateFunction func)
construct univariate function from multivariate function- Parameters:
func
- multivariate functionstart
- start pointdir
- 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 pointdir
- 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
- argumentp
- array for coordinates of corresponding point
-
evaluate
public double evaluate(double lambda)
evaluate f(start+lambda*dir)- Specified by:
evaluate
in interfaceUnivariateFunction
- Returns:
- function value
-
getLowerBound
public double getLowerBound()
Description copied from interface:UnivariateFunction
get lower bound of argument- Specified by:
getLowerBound
in interfaceUnivariateFunction
- Returns:
- lower bound
-
getUpperBound
public double getUpperBound()
Description copied from interface:UnivariateFunction
get upper bound of argument- Specified by:
getUpperBound
in interfaceUnivariateFunction
- Returns:
- upper bound
-
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 pointgrad
- gradient at that pointlist
- 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 pointdir
- direction vector at that point- Returns:
- number of changed components in direction vector
-
-