Top Description Fields Constructors Methods
org.apache.commons.math3.optimization.univariate

public Class UnivariateMultiStartOptimizer<FUNC extends UnivariateFunction>

extends Object
implements BaseUnivariateOptimizer<FUNC extends UnivariateFunction>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.optimization.univariate.BaseUnivariateOptimizer, org.apache.commons.math3.optimization.BaseOptimizer
Annotations
@Deprecated
Type Parameters
<FUNC>
Type of the objective function to be optimized.
Imports
java.util.Arrays, .Comparator, org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.exception.MathIllegalStateException, .NotStrictlyPositiveException, .NullArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.random.RandomGenerator, org.apache.commons.math3.optimization.GoalType, .ConvergenceChecker

Deprecated

As of 3.1 (to be removed in 4.0).

Special implementation of the UnivariateOptimizer interface 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
3.0

Field Summary

Modifier and TypeField and Description
private RandomGenerator
generator

Random generator for multi-start.

private int
maxEvaluations

Maximal number of evaluations allowed.

private UnivariatePointValuePair[]
optima

Deprecated as a consequence of UnivariatePointValuePair being deprecated.
Found optima.
private final BaseUnivariateOptimizer<FUNC>
optimizer

Deprecated as a consequence of BaseUnivariateOptimizer being deprecated.
Underlying classical optimizer.
private int
starts

Number of starts to go.

private int
totalEvaluations

Number of evaluations already performed for all starts.

Constructor Summary

AccessConstructor and Description
public
UnivariateMultiStartOptimizer(final BaseUnivariateOptimizer<FUNC>
Single-start optimizer to wrap.
optimizer
,
final int
Number of starts to perform. If starts == 1, the optimize methods will return the same solution as optimizer would.
starts
,
final RandomGenerator
Random generator to use for restarts.
generator
)
Deprecated as a consequence of BaseUnivariateOptimizer being deprecated.

Create a multi-start optimizer from a single-start optimizer.

Method Summary

Modifier and TypeMethod and Description
public ConvergenceChecker<UnivariatePointValuePair>
getConvergenceChecker()

Implements org.apache.commons.math3.optimization.BaseOptimizer.getConvergenceChecker.

Deprecated as a consequence of ConvergenceChecker being deprecated.

Get the convergence checker.

public int
getEvaluations()

Implements org.apache.commons.math3.optimization.BaseOptimizer.getEvaluations.

Get the number of evaluations of the objective function.

public int
getMaxEvaluations()

Implements org.apache.commons.math3.optimization.BaseOptimizer.getMaxEvaluations.

Get the maximal number of function evaluations.

public UnivariatePointValuePair[]

Returns:

an array containing the optima.
getOptima
()
Deprecated as a consequence of UnivariatePointValuePair being deprecated.

Get all the optima found during the last call to optimize.

public UnivariatePointValuePair
optimize(int
Maximum number of function evaluations.
maxEval
,
final FUNC
Function to optimize.
f
,
final GoalType
Type of optimization goal: either GoalType#MAXIMIZE or GoalType#MINIMIZE.
goal
,
final double
Lower bound for the interval.
min
,
final double
Upper bound for the interval.
max
)

Implements org.apache.commons.math3.optimization.univariate.BaseUnivariateOptimizer.optimize.

Deprecated as a consequence of GoalType and UnivariatePointValuePair being deprecated.

Find an optimum in the given interval.

public UnivariatePointValuePair
optimize(int
Maximum number of function evaluations.
maxEval
,
final FUNC
Function to optimize.
f
,
final GoalType
Type of optimization goal: either GoalType#MAXIMIZE or GoalType#MINIMIZE.
goal
,
final double
Lower bound for the interval.
min
,
final double
Upper bound for the interval.
max
,
final double
Start value to use.
startValue
)

Implements org.apache.commons.math3.optimization.univariate.BaseUnivariateOptimizer.optimize.

Deprecated as a consequence of GoalType and UnivariatePointValuePair being deprecated.

Find an optimum in the given interval, start at startValue.

private void
sortPairs(final GoalType
Goal type.
goal
)
Deprecated as a consequence of GoalType being deprecated.

Sort the optima from best to worst, followed by null elements.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

generatorback to summary
private RandomGenerator generator

Random generator for multi-start.

maxEvaluationsback to summary
private int maxEvaluations

Maximal number of evaluations allowed.

optimaback to summary
private UnivariatePointValuePair[] optima

Deprecated

as a consequence of UnivariatePointValuePair being deprecated. See corresponding docs for further information.

Found optima.

optimizerback to summary
private final BaseUnivariateOptimizer<FUNC> optimizer

Deprecated

as a consequence of BaseUnivariateOptimizer being deprecated. See corresponding docs for further information.

Underlying classical optimizer.

startsback to summary
private int starts

Number of starts to go.

totalEvaluationsback to summary
private int totalEvaluations

Number of evaluations already performed for all starts.

Constructor Detail

UnivariateMultiStartOptimizerback to summary
public UnivariateMultiStartOptimizer(final BaseUnivariateOptimizer<FUNC> optimizer, final int starts, final RandomGenerator generator)

Deprecated

as a consequence of BaseUnivariateOptimizer being deprecated. See corresponding docs for further information.

Create a multi-start optimizer from a single-start optimizer.

Parameters
optimizer:BaseUnivariateOptimizer<FUNC>

Single-start optimizer to wrap.

starts:int

Number of starts to perform. If starts == 1, the optimize methods will return the same solution as optimizer would.

generator:RandomGenerator

Random generator to use for restarts.

Exceptions
NullArgumentException:
if optimizer or generator is null.
NotStrictlyPositiveException:
if starts < 1.

Method Detail

getConvergenceCheckerback to summary
public ConvergenceChecker<UnivariatePointValuePair> getConvergenceChecker()

Implements org.apache.commons.math3.optimization.BaseOptimizer.getConvergenceChecker.

Doc from org.apache.commons.math3.optimization.BaseOptimizer.getConvergenceChecker.

Deprecated

as a consequence of ConvergenceChecker being deprecated. See corresponding docs for further information.

Get the convergence checker.

Returns:ConvergenceChecker<UnivariatePointValuePair>

the object used to check for convergence.

getEvaluationsback to summary
public int getEvaluations()

Implements org.apache.commons.math3.optimization.BaseOptimizer.getEvaluations.

Doc from org.apache.commons.math3.optimization.BaseOptimizer.getEvaluations.

Get the number of evaluations of the objective function. The number of evaluations corresponds to the last call to the optimize method. It is 0 if the method has not been called yet.

Returns:int

the number of evaluations of the objective function.

getMaxEvaluationsback to summary
public int getMaxEvaluations()

Implements org.apache.commons.math3.optimization.BaseOptimizer.getMaxEvaluations.

Doc from org.apache.commons.math3.optimization.BaseOptimizer.getMaxEvaluations.

Get the maximal number of function evaluations.

Returns:int

the maximal number of function evaluations.

getOptimaback to summary
public UnivariatePointValuePair[] getOptima()

Deprecated

as a consequence of UnivariatePointValuePair being deprecated. See corresponding docs for further information.

Get all the optima found during the last call to optimize. The optimizer stores all the optima found during a set of restarts. The optimize method 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 the optimize method.
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 null elements corresponding to the runs that did not converge. This means all elements will be null if the optimize method did throw an exception. This also means that if the first element is not null, it is the best point found across all starts.

Returns:UnivariatePointValuePair[]

an array containing the optima.

Exceptions
MathIllegalStateException:
if optimize has not been called.
optimizeback to summary
public UnivariatePointValuePair optimize(int maxEval, final FUNC f, final GoalType goal, final double min, final double max)

Implements org.apache.commons.math3.optimization.univariate.BaseUnivariateOptimizer.optimize.

Doc from org.apache.commons.math3.optimization.univariate.BaseUnivariateOptimizer.optimize.

Deprecated

as a consequence of GoalType and UnivariatePointValuePair being deprecated. See corresponding docs for further information.

Find an optimum in the given interval. An optimizer may require that the interval brackets a single optimum.

Parameters
maxEval:int

Maximum number of function evaluations.

f:FUNC

Function to optimize.

goal:GoalType

Type of optimization goal: either GoalType#MAXIMIZE or GoalType#MINIMIZE.

min:double

Lower bound for the interval.

max:double

Upper bound for the interval.

Returns:UnivariatePointValuePair

a (point, value) pair where the function is optimum.

optimizeback to summary
public UnivariatePointValuePair optimize(int maxEval, final FUNC f, final GoalType goal, final double min, final double max, final double startValue)

Implements org.apache.commons.math3.optimization.univariate.BaseUnivariateOptimizer.optimize.

Doc from org.apache.commons.math3.optimization.univariate.BaseUnivariateOptimizer.optimize.

Deprecated

as a consequence of GoalType and UnivariatePointValuePair being deprecated. See corresponding docs for further information.

Find an optimum in the given interval, start at startValue. An optimizer may require that the interval brackets a single optimum.

Parameters
maxEval:int

Maximum number of function evaluations.

f:FUNC

Function to optimize.

goal:GoalType

Type of optimization goal: either GoalType#MAXIMIZE or GoalType#MINIMIZE.

min:double

Lower bound for the interval.

max:double

Upper bound for the interval.

startValue:double

Start value to use.

Returns:UnivariatePointValuePair

a (point, value) pair where the function is optimum.

sortPairsback to summary
private void sortPairs(final GoalType goal)

Deprecated

as a consequence of GoalType being deprecated. See corresponding docs for further information.

Sort the optima from best to worst, followed by null elements.

Parameters
goal:GoalType

Goal type.