Package pal.math
Class LineFunction
java.lang.Object
pal.math.LineFunction
- All Implemented Interfaces:
UnivariateFunction
converts a multivariate function into a univariate function
- Author:
- Korbinian Strimmer
-
Constructor Summary
ConstructorsConstructorDescriptionconstruct univariate function from multivariate function -
Method Summary
Modifier and TypeMethodDescriptionintcheckDirection(double[] p, double[] dir) check direction vector.booleancheckPoint(double[] p) check (and modify, if necessary) whether a point lies properly within the predefined boundsintcheckVariables(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)doubleevaluate(double lambda) evaluate f(start+lambda*dir)doublefind 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)doubleget lower bound of argumentintget parameter that limits the lower boundvoidgetPoint(double lambda, double[] p) get point associated with the one-dimensional parameter (bounds of of multivariate function are NOT checked)doubleget upper bound of argumentintget parameter that limits the upper boundvoidupdate(double[] start, double[] dir) update start point and direction (bounds and search direction are NOT checked)
-
Constructor Details
-
LineFunction
construct univariate function from multivariate function- Parameters:
func- multivariate functionstart- start pointdir- direction vector
-
-
Method Details
-
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:
evaluatein interfaceUnivariateFunction- Returns:
- function value
-
getLowerBound
public double getLowerBound()Description copied from interface:UnivariateFunctionget lower bound of argument- Specified by:
getLowerBoundin interfaceUnivariateFunction- Returns:
- lower bound
-
getUpperBound
public double getUpperBound()Description copied from interface:UnivariateFunctionget upper bound of argument- Specified by:
getUpperBoundin 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
-