jsat.math.optimization
Class NelderMead
- java.lang.Object
-
- jsat.math.optimization.NelderMead
-
- All Implemented Interfaces:
- Optimizer
public class NelderMead extends java.lang.Object implements Optimizer
The Nelder-Mean algorithm is a simple directed search method. As such, it does not need any information about the target functions derivative, or any data points. To perform best, the Nelder-Mean method needs N+1 reasonable initial guesses for an N dimensional problem.
The Nelder-Mean method has the advantage that the only information it needs about the function it is going to minimize, is the function itself.
-
-
Constructor Summary
Constructors Constructor and Description NelderMead()NelderMead(NelderMead toCopy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description NelderMeadclone()intgetMaximumIterations()Returns the maximum number of iterations to performVecoptimize(double eps, int iterationLimit, Function f, java.util.List<Vec> initalPoints, boolean parallel)Attempts to find the minimal value of the given function.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.voidsetContraction(double contraction)Sets the contraction constant, which must be in the range (0, 1)voidsetExpansion(double expansion)Sets the expansion constant, which must be greater than 1 and the reflection constantvoidsetMaximumIterations(int iterations)Sets the maximum number of iterations allowed for the optimization methodvoidsetReflection(double reflection)Sets the reflection constant, which must be greater than 0voidsetShrink(double shrink)Sets the shrinkage constant, which must be in the range (0, 1)
-
-
-
Constructor Detail
-
NelderMead
public NelderMead()
-
NelderMead
public NelderMead(NelderMead toCopy)
-
-
Method Detail
-
setReflection
public void setReflection(double reflection)
Sets the reflection constant, which must be greater than 0- Parameters:
reflection- the reflection constant
-
setExpansion
public void setExpansion(double expansion)
Sets the expansion constant, which must be greater than 1 and the reflection constant- Parameters:
expansion-
-
setContraction
public void setContraction(double contraction)
Sets the contraction constant, which must be in the range (0, 1)- Parameters:
contraction- the contraction constant
-
setShrink
public void setShrink(double shrink)
Sets the shrinkage constant, which must be in the range (0, 1)- Parameters:
shrink-
-
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.
-
optimize
public Vec optimize(double eps, int iterationLimit, Function f, java.util.List<Vec> initalPoints, boolean parallel)
Attempts to find the minimal value of the given function.- Parameters:
eps- the desired accuracy of the result.iterationLimit- the maximum number of iteration steps to allow. This value must be positivef- the function to optimize. This value can not be nullinitalPoints- the list of initial guess points. If too small, new ones will be generated. if too large, the extra ones will be ignored. This list may not be emptyparallel-trueif multiple threads should be used for optimization, orfalseif a single thread should be used.- Returns:
- the computed value for the optimization.
-
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
-
clone
public NelderMead clone()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG