jsat.math.optimization
Class BFGS
- java.lang.Object
-
- jsat.math.optimization.BFGS
-
- All Implemented Interfaces:
- Optimizer
public class BFGS extends java.lang.Object implements Optimizer
Implementation of the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm for function minimization. Forndimensional problems it requires O(n2) work per iteration and uses first order information to approximate the Hessian.
-
-
Constructor Summary
Constructors Constructor and Description BFGS()Creates a new BFGS optimization object that uses a maximum of 250 iterations and abacktrackingline search.BFGS(int maxIterations, LineSearch lineSearch)Creates a new BFGS optimization object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Optimizerclone()LineSearchgetLineSearch()Returns the line search method used at each iterationintgetMaximumIterations()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 iterationvoidsetMaximumIterations(int iterations)Sets the maximum number of iterations allowed for the optimization method
-
-
-
Constructor Detail
-
BFGS
public BFGS()
Creates a new BFGS optimization object that uses a maximum of 250 iterations and abacktrackingline search.
-
BFGS
public BFGS(int maxIterations, LineSearch lineSearch)Creates a new BFGS optimization object- Parameters:
maxIterations- the maximum number of iterations to allow before stoppinglineSearch- the line search method to use on updates
-
-
Method Detail
-
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
-
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
-
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
-
-
DataMelt 3.0 © DataMelt by jWork.ORG