jsat.math.optimization
Class WolfeNWLineSearch
- java.lang.Object
-
- jsat.math.optimization.WolfeNWLineSearch
-
- All Implemented Interfaces:
- LineSearch
public class WolfeNWLineSearch extends java.lang.Object implements LineSearch
An implementation of the Wolfe Line Search algorithm described by Nocedal and Wright in Numerical Optimization (2nd edition) on pages 59-63.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classWolfeNWLineSearch.AlphaInit
-
Constructor Summary
Constructors Constructor and Description WolfeNWLineSearch()WolfeNWLineSearch(double c1, double c2)Creates a new Wolfe line search
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description WolfeNWLineSearchclone()Returns a clone of the line search objectdoublegetC1()Returns the sufficient decrease condition constantdoublegetC2()Returns the curvature condition constantdoublelineSearch(double alpha_max, Vec x_k, Vec x_grad, Vec p_k, Function f, FunctionVec fp, double f_x, double gradP, Vec x_alpha_pk, double[] fxApRet, Vec grad_x_alpha_pk, boolean parallel)Attempts to find the value of α that minimizes f(x+α p)voidsetC1(double c1)Sets the constant used for the sufficient decrease condition f(x+α p) ≤ f(x) + c1 α pT∇f(x)
This value must always be less thansetC2(double)voidsetC2(double c2)Sets the constant used for the curvature condition pT ∇f(x+α p) ≥ c2 pT∇f(x)booleanupdatesGrad()When performing thelinear searchstep some line searches may or may not use the gradient information.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jsat.math.optimization.LineSearch
lineSearch
-
-
-
-
Constructor Detail
-
WolfeNWLineSearch
public WolfeNWLineSearch()
-
WolfeNWLineSearch
public WolfeNWLineSearch(double c1, double c2)Creates a new Wolfe line search- Parameters:
c1- the sufficient decrease condition constantc2- the curvature condition constant
-
-
Method Detail
-
setC1
public void setC1(double c1)
Sets the constant used for the sufficient decrease condition f(x+α p) ≤ f(x) + c1 α pT∇f(x)
This value must always be less thansetC2(double)- Parameters:
c1- the sufficient decrease condition
-
getC1
public double getC1()
Returns the sufficient decrease condition constant- Returns:
- the sufficient decrease condition constant
-
setC2
public void setC2(double c2)
Sets the constant used for the curvature condition pT ∇f(x+α p) ≥ c2 pT∇f(x)- Parameters:
c2- the curvature condition constant
-
getC2
public double getC2()
Returns the curvature condition constant- Returns:
- the curvature condition constant
-
lineSearch
public double lineSearch(double alpha_max, Vec x_k, Vec x_grad, Vec p_k, Function f, FunctionVec fp, double f_x, double gradP, Vec x_alpha_pk, double[] fxApRet, Vec grad_x_alpha_pk, boolean parallel)Description copied from interface:LineSearchAttempts to find the value of α that minimizes f(x+α p)- Specified by:
lineSearchin interfaceLineSearch- Parameters:
alpha_max- the maximum value for α to search forx_k- the initial value to search fromx_grad- the gradient of ∇ f(xk)p_k- the direction updatef- the function to minimize the value of f(xk + α pk)fp- the gradient of f, ∇f(x), may benulldepending upon the line search methodf_x- the value of f(xk), orDouble.NaNif it needs to be computedgradP- the value of ∇f(xk)Tpk, orDouble.NaNif it needs to be computedx_alpha_pk- the location to store the value of xk + α pkfxApRet- an array to store the computed result of f(xk + α pk) in the first index contain. May benulland the value will not be returnedgrad_x_alpha_pk- location to store the value of ∇ f(xkα+pk). May benull, local storage will be allocated if neededparallel-trueif this line search should be done using multiple cores, orfalseto be single threaded.- Returns:
- the value of α that satisfies the line search in minimizing f(xk + α pk)
-
updatesGrad
public boolean updatesGrad()
Description copied from interface:LineSearchWhen performing thelinear searchstep some line searches may or may not use the gradient information. If the gradient information is used and updated, this method will returntrue. If not the given vector will be unused and not updated, and this method will returnfalse- Specified by:
updatesGradin interfaceLineSearch- Returns:
trueif thegrad_x_alpha_pkparameter of lineSearch will be up-to-date after the call, orfalseif the gradient value will need to be computed after.
-
clone
public WolfeNWLineSearch clone()
Description copied from interface:LineSearchReturns a clone of the line search object- Specified by:
clonein interfaceLineSearch- Overrides:
clonein classjava.lang.Object- Returns:
- a clone of the line search object
-
-
DataMelt 3.0 © DataMelt by jWork.ORG