Class MultiStartDifferentiableMultivariateVectorialOptimizer
- java.lang.Object
 - 
- org.apache.commons.math.optimization.MultiStartDifferentiableMultivariateVectorialOptimizer
 
 
- 
- All Implemented Interfaces:
 DifferentiableMultivariateVectorialOptimizer
public class MultiStartDifferentiableMultivariateVectorialOptimizer extends java.lang.Object implements DifferentiableMultivariateVectorialOptimizer
Special implementation of theDifferentiableMultivariateVectorialOptimizerinterface adding multi-start features to an existing optimizer.This class wraps a classical optimizer to use it several times in turn with different starting points in order to avoid being trapped into a local extremum when looking for a global one.
- Since:
 - 2.0
 
 
- 
- 
Constructor Summary
Constructors Constructor Description MultiStartDifferentiableMultivariateVectorialOptimizer(DifferentiableMultivariateVectorialOptimizer optimizer, int starts, RandomVectorGenerator generator)Create a multi-start optimizer from a single-start optimizer 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VectorialConvergenceCheckergetConvergenceChecker()Get the convergence checker.intgetEvaluations()Get the number of evaluations of the objective function.intgetIterations()Get the number of iterations realized by the algorithm.intgetJacobianEvaluations()Get the number of evaluations of the objective function jacobian .intgetMaxEvaluations()Get the maximal number of functions evaluations.intgetMaxIterations()Get the maximal number of iterations of the algorithm.VectorialPointValuePair[]getOptima()Get all the optima found during the last call tooptimize.VectorialPointValuePairoptimize(DifferentiableMultivariateVectorialFunction f, double[] target, double[] weights, double[] startPoint)Optimizes an objective function.voidsetConvergenceChecker(VectorialConvergenceChecker checker)Set the convergence checker.voidsetMaxEvaluations(int maxEvaluations)Set the maximal number of functions evaluations.voidsetMaxIterations(int maxIterations)Set the maximal number of iterations of the algorithm. 
 - 
 
- 
- 
Constructor Detail
- 
MultiStartDifferentiableMultivariateVectorialOptimizer
public MultiStartDifferentiableMultivariateVectorialOptimizer(DifferentiableMultivariateVectorialOptimizer optimizer, int starts, RandomVectorGenerator generator)
Create a multi-start optimizer from a single-start optimizer- Parameters:
 optimizer- single-start optimizer to wrapstarts- number of starts to perform (including the first one), multi-start is disabled if value is less than or equal to 1generator- random vector generator to use for restarts
 
 - 
 
- 
Method Detail
- 
getOptima
public VectorialPointValuePair[] getOptima() throws java.lang.IllegalStateException
Get all the optima found during the last call tooptimize.The optimizer stores all the optima found during a set of restarts. The
optimizemethod returns the best point only. This method returns all the points found at the end of each starts, including the best one already returned by theoptimizemethod.The returned array as one element for each start as specified in the constructor. It is ordered with the results from the runs that did converge first, sorted from best to worst objective value (i.e in ascending order if minimizing and in descending order if maximizing), followed by and null elements corresponding to the runs that did not converge. This means all elements will be null if the
optimizemethod did throw aConvergenceException). This also means that if the first element is non null, it is the best point found across all starts.- Returns:
 - array containing the optima
 - Throws:
 java.lang.IllegalStateException- ifoptimizehas not been called
 
- 
setMaxIterations
public void setMaxIterations(int maxIterations)
Set the maximal number of iterations of the algorithm.- Specified by:
 setMaxIterationsin interfaceDifferentiableMultivariateVectorialOptimizer- Parameters:
 maxIterations- maximal number of function calls .
 
- 
getMaxIterations
public int getMaxIterations()
Get the maximal number of iterations of the algorithm.- Specified by:
 getMaxIterationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
 - maximal number of iterations
 
 
- 
getIterations
public int getIterations()
Get the number of iterations realized by the algorithm.- Specified by:
 getIterationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
 - number of iterations
 
 
- 
setMaxEvaluations
public void setMaxEvaluations(int maxEvaluations)
Set the maximal number of functions evaluations.- Specified by:
 setMaxEvaluationsin interfaceDifferentiableMultivariateVectorialOptimizer- Parameters:
 maxEvaluations- maximal number of function evaluations
 
- 
getMaxEvaluations
public int getMaxEvaluations()
Get the maximal number of functions evaluations.- Specified by:
 getMaxEvaluationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
 - maximal number of functions evaluations
 
 
- 
getEvaluations
public int getEvaluations()
Get the number of evaluations of the objective function.The number of evaluation correspond to the last call to the
optimizemethod. It is 0 if the method has not been called yet.- Specified by:
 getEvaluationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
 - number of evaluations of the objective function
 
 
- 
getJacobianEvaluations
public int getJacobianEvaluations()
Get the number of evaluations of the objective function jacobian .The number of evaluation correspond to the last call to the
optimizemethod. It is 0 if the method has not been called yet.- Specified by:
 getJacobianEvaluationsin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
 - number of evaluations of the objective function jacobian
 
 
- 
setConvergenceChecker
public void setConvergenceChecker(VectorialConvergenceChecker checker)
Set the convergence checker.- Specified by:
 setConvergenceCheckerin interfaceDifferentiableMultivariateVectorialOptimizer- Parameters:
 checker- object to use to check for convergence
 
- 
getConvergenceChecker
public VectorialConvergenceChecker getConvergenceChecker()
Get the convergence checker.- Specified by:
 getConvergenceCheckerin interfaceDifferentiableMultivariateVectorialOptimizer- Returns:
 - object used to check for convergence
 
 
- 
optimize
public VectorialPointValuePair optimize(DifferentiableMultivariateVectorialFunction f, double[] target, double[] weights, double[] startPoint) throws FunctionEvaluationException, OptimizationException, java.lang.IllegalArgumentException
Optimizes an objective function.Optimization is considered to be a weighted least-squares minimization. The cost function to be minimized is ∑weighti(objectivei-targeti)2
- Specified by:
 optimizein interfaceDifferentiableMultivariateVectorialOptimizer- Parameters:
 f- objective functiontarget- target value for the objective functions at optimumweights- weight for the least squares cost computationstartPoint- the start point for optimization- Returns:
 - the point/value pair giving the optimal value for objective function
 - Throws:
 FunctionEvaluationException- if the objective function throws one during the searchOptimizationException- if the algorithm failed to convergejava.lang.IllegalArgumentException- if the start point dimension is wrong
 
 - 
 
 -