jsat.math.optimization
Class LBFGS
- java.lang.Object
-
- jsat.math.optimization.LBFGS
-
-
Constructor Summary
Constructors Constructor and Description LBFGS()Creates a new L-BFGS optimization object that uses a maximum of 500 iterations and aBacktrackingline search.LBFGS(int m)Creates a new L-BFGS optimization object that uses a maximum of 500 iterations and aBacktrackingline search.LBFGS(int m, int maxIterations, LineSearch lineSearch)Creates a new L-BFGS optimization object
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description LBFGSclone()LineSearchgetLineSearch()Returns the line search method used at each iterationintgetM()Returns the number of history items that will be usedintgetMaximumIterations()Returns the maximum number of iterations to performbooleanisInftNormCriterion()Returns whether or not the infinity norm (true) or 2 norm (false) is used to determine convergence.voidoptimize(double tolerance, Vec w, Vec x0, Function f, FunctionVec fp, boolean parallel)Attempts to optimize the given function by finding the value ofwthat will minimize the value returned byf(w), using w = x0 as an initial starting point.voidsetInftNormCriterion(boolean inftNormCriterion)By default the infinity norm is used to judge convergence.voidsetLineSearch(LineSearch lineSearch)Sets the line search method used at each iterationvoidsetM(int m)Sets the number of history items to keep that are used to approximate the Hessian of the problemvoidsetMaximumIterations(int iterations)Sets the maximum number of iterations allowed for the optimization methodstatic voidtwoLoopHp(Vec x_grad, java.util.List<java.lang.Double> rho, java.util.List<Vec> s, java.util.List<Vec> y, Vec q, double[] alphas)See Algorithm 7.4 (L-BFGS two-loop recursion).
-
-
-
Constructor Detail
-
LBFGS
public LBFGS()
Creates a new L-BFGS optimization object that uses a maximum of 500 iterations and aBacktrackingline search. Ahistoryof 10 items will be used
-
LBFGS
public LBFGS(int m)
Creates a new L-BFGS optimization object that uses a maximum of 500 iterations and aBacktrackingline search.- Parameters:
m- the number of history items
-
LBFGS
public LBFGS(int m, int maxIterations, LineSearch lineSearch)Creates a new L-BFGS optimization object- Parameters:
m- the number of history itemsmaxIterations- the maximum number of iterations before stoppinglineSearch- the line search method to use for optimization
-
-
Method Detail
-
twoLoopHp
public static void twoLoopHp(Vec x_grad, java.util.List<java.lang.Double> rho, java.util.List<Vec> s, java.util.List<Vec> y, Vec q, double[] alphas)
See Algorithm 7.4 (L-BFGS two-loop recursion).- Parameters:
x_grad- the initial value ∇ fkrho-s-y-q- the location to store the value of Hk ∇ fkalphas- temp space to do work, should be as large as the number of history vectors
-
optimize
public void optimize(double tolerance, Vec w, Vec x0, Function f, FunctionVec fp, boolean parallel)Description copied from interface:OptimizerAttempts to optimize the given function by finding the value ofwthat will minimize the value returned byf(w), using w = x0 as an initial starting point.- Specified by:
optimizein interfaceOptimizer- Parameters:
tolerance- the value that the gradient norm must be less than to consider convergedw- the the location to store the final solutionx0- the initial guess for the solution. This value will not be changed, and intermediate matrices will be created as the same type.f- the objective function to minimizerfp- the derivative of the objective function, may benulldepending on the optimizerparallel-trueif multiple threads should be used for optimization, orfalseif a single thread should be used.
-
setInftNormCriterion
public void setInftNormCriterion(boolean inftNormCriterion)
By default the infinity norm is used to judge convergence. If set tofalse, the 2 norm will be used instead.- Parameters:
inftNormCriterion-
-
isInftNormCriterion
public boolean isInftNormCriterion()
Returns whether or not the infinity norm (true) or 2 norm (false) is used to determine convergence.- Returns:
trueif the infinity norm is in use,falsefor the 2 norm
-
setM
public void setM(int m)
Sets the number of history items to keep that are used to approximate the Hessian of the problem- Parameters:
m- the number of history items to keep
-
getM
public int getM()
Returns the number of history items that will be used- Returns:
- the number of history items that will be used
-
setLineSearch
public void setLineSearch(LineSearch lineSearch)
Sets the line search method used at each iteration- Parameters:
lineSearch- the line search method used at each iteration
-
getLineSearch
public LineSearch getLineSearch()
Returns the line search method used at each iteration- Returns:
- the line search method used at each iteration
-
setMaximumIterations
public void setMaximumIterations(int iterations)
Description copied from interface:OptimizerSets the maximum number of iterations allowed for the optimization method- Specified by:
setMaximumIterationsin interfaceOptimizer- Parameters:
iterations- the maximum number of iterations to perform
-
getMaximumIterations
public int getMaximumIterations()
Description copied from interface:OptimizerReturns the maximum number of iterations to perform- Specified by:
getMaximumIterationsin interfaceOptimizer- Returns:
- the maximum number of iterations to perform
-
-
DataMelt 3.0 © DataMelt by jWork.ORG