|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.math3.optim.BaseOptimizer<PAIR>
org.apache.commons.math3.optim.BaseMultivariateOptimizer<PointValuePair>
org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer
org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer
public class BOBYQAOptimizer
Powell's BOBYQA algorithm. This implementation is translated and
adapted from the Fortran version available
here.
See
this paper for an introduction.
BOBYQA is particularly well suited for high dimensional problems
where derivatives are not available. In most cases it outperforms the
PowellOptimizer
significantly. Stochastic algorithms like
CMAESOptimizer
succeed more often than BOBYQA, but are more
expensive. BOBYQA could also be considered as a replacement of any
derivative-based optimizer when the derivatives are approximated by
finite differences.
Nested Class Summary | |
---|---|
private static class |
BOBYQAOptimizer.PathIsExploredException
Marker for code paths that are not explored with the current unit tests. |
Field Summary | |
---|---|
private ArrayRealVector |
alternativeNewPoint
Alternative to newPoint , chosen by
altmov . |
private Array2DRowRealMatrix |
bMatrix
Last n columns of matrix H (where n is the dimension of the problem). |
private double[] |
boundDifference
Differences between the upper and lower bounds. |
private ArrayRealVector |
currentBest
Current best values for the variables to be optimized. |
static double |
DEFAULT_INITIAL_RADIUS
Default value for initialTrustRegionRadius : 10.0 . |
static double |
DEFAULT_STOPPING_RADIUS
Default value for stoppingTrustRegionRadius : 1.0E-8 . |
private ArrayRealVector |
fAtInterpolationPoints
Values of the objective function at the interpolation points. |
private ArrayRealVector |
gradientAtTrustRegionCenter
Gradient of the quadratic model at originShift +
trustRegionCenterOffset . |
private static double |
HALF
|
private double |
initialTrustRegionRadius
initialTrustRegionRadius XXX |
private Array2DRowRealMatrix |
interpolationPoints
Coordinates of the interpolation points relative to originShift . |
private boolean |
isMinimize
Goal type (minimize or maximize). |
private ArrayRealVector |
lagrangeValuesAtNewPoint
Values of the Lagrange functions at a new point. |
private ArrayRealVector |
lowerDifference
Differences BaseMultivariateOptimizer.getLowerBound() - originShift . |
static int |
MINIMUM_PROBLEM_DIMENSION
Minimum dimension of the problem: 2 |
private static double |
MINUS_ONE
|
private ArrayRealVector |
modelSecondDerivativesParameters
Parameters of the implicit second derivatives of the quadratic model. |
private ArrayRealVector |
modelSecondDerivativesValues
Explicit second derivatives of the quadratic model. |
private ArrayRealVector |
newPoint
Point chosen by function trsbox
or altmov . |
private int |
numberOfInterpolationPoints
numberOfInterpolationPoints XXX |
private static double |
ONE
|
private static double |
ONE_OVER_A_THOUSAND
|
private static double |
ONE_OVER_EIGHT
|
private static double |
ONE_OVER_FOUR
|
private static double |
ONE_OVER_TEN
|
private ArrayRealVector |
originShift
Shift of origin that should reduce the contributions from rounding errors to values of the model and Lagrange functions. |
private static double |
SIXTEEN
|
private double |
stoppingTrustRegionRadius
stoppingTrustRegionRadius XXX |
private static double |
TEN
|
private ArrayRealVector |
trialStepPoint
Trial step from trustRegionCenterOffset which is usually
newPoint - trustRegionCenterOffset . |
private int |
trustRegionCenterInterpolationPointIndex
Index of the interpolation point at the trust region center. |
private ArrayRealVector |
trustRegionCenterOffset
Displacement from originShift of the trust region center. |
private static double |
TWO
|
private static double |
TWO_HUNDRED_FIFTY
|
private ArrayRealVector |
upperDifference
Differences BaseMultivariateOptimizer.getUpperBound() - originShift
All the components of every trustRegionCenterOffset are going
to satisfy the boundstrustRegionCenterOffset i ≤
upperBound i,with appropriate equalities when trustRegionCenterOffset is
on a constraint boundary. |
private static double |
ZERO
|
private Array2DRowRealMatrix |
zMatrix
Factorization of the leading npt square submatrix of H, this factorization being Z ZT, which provides both the correct rank and positive semi-definiteness. |
Fields inherited from class org.apache.commons.math3.optim.BaseOptimizer |
---|
evaluations, iterations |
Constructor Summary | |
---|---|
BOBYQAOptimizer(int numberOfInterpolationPoints)
|
|
BOBYQAOptimizer(int numberOfInterpolationPoints,
double initialTrustRegionRadius,
double stoppingTrustRegionRadius)
|
Method Summary | |
---|---|
private double[] |
altmov(int knew,
double adelt)
The arguments N, NPT, XPT, XOPT, BMAT, ZMAT, NDIM, SL and SU all have the same meanings as the corresponding arguments of BOBYQB. |
private double |
bobyqa(double[] lowerBound,
double[] upperBound)
This subroutine seeks the least value of a function of many variables, by applying a trust region method that forms quadratic models by interpolation. |
private double |
bobyqb(double[] lowerBound,
double[] upperBound)
The arguments N, NPT, X, XL, XU, RHOBEG, RHOEND, IPRINT and MAXFUN are identical to the corresponding arguments in SUBROUTINE BOBYQA. |
private static java.lang.String |
caller(int n)
|
protected PointValuePair |
doOptimize()
Performs the bulk of the optimization algorithm. |
private static double[] |
fillNewArray(int n,
double value)
Creates a new array. |
private void |
prelim(double[] lowerBound,
double[] upperBound)
SUBROUTINE PRELIM sets the elements of XBASE, XPT, FVAL, GOPT, HQ, PQ, BMAT and ZMAT for the first iteration, and it maintains the values of NF and KOPT. |
private static void |
printMethod()
|
private static void |
printState(int s)
|
private void |
setup(double[] lowerBound,
double[] upperBound)
Performs validity checks. |
private double[] |
trsbox(double delta,
ArrayRealVector gnew,
ArrayRealVector xbdi,
ArrayRealVector s,
ArrayRealVector hs,
ArrayRealVector hred)
A version of the truncated conjugate gradient is applied. |
private void |
update(double beta,
double denom,
int knew)
The arrays BMAT and ZMAT are updated, as required by the new position of the interpolation point that has the index KNEW. |
Methods inherited from class org.apache.commons.math3.optim.nonlinear.scalar.MultivariateOptimizer |
---|
computeObjectiveValue, getGoalType, optimize |
Methods inherited from class org.apache.commons.math3.optim.BaseMultivariateOptimizer |
---|
getLowerBound, getStartPoint, getUpperBound |
Methods inherited from class org.apache.commons.math3.optim.BaseOptimizer |
---|
getConvergenceChecker, getEvaluations, getIterations, getMaxEvaluations, getMaxIterations, incrementEvaluationCount, incrementIterationCount |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MINIMUM_PROBLEM_DIMENSION
public static final double DEFAULT_INITIAL_RADIUS
initialTrustRegionRadius
: 10.0 .
public static final double DEFAULT_STOPPING_RADIUS
stoppingTrustRegionRadius
: 1.0E-8 .
private static final double ZERO
private static final double ONE
private static final double TWO
private static final double TEN
private static final double SIXTEEN
private static final double TWO_HUNDRED_FIFTY
private static final double MINUS_ONE
private static final double HALF
private static final double ONE_OVER_FOUR
private static final double ONE_OVER_EIGHT
private static final double ONE_OVER_TEN
private static final double ONE_OVER_A_THOUSAND
private final int numberOfInterpolationPoints
private double initialTrustRegionRadius
private final double stoppingTrustRegionRadius
private boolean isMinimize
private ArrayRealVector currentBest
private double[] boundDifference
private int trustRegionCenterInterpolationPointIndex
private Array2DRowRealMatrix bMatrix
private Array2DRowRealMatrix zMatrix
private Array2DRowRealMatrix interpolationPoints
originShift
.
XXX "xpt" in the original code.
private ArrayRealVector originShift
private ArrayRealVector fAtInterpolationPoints
private ArrayRealVector trustRegionCenterOffset
originShift
of the trust region center.
XXX "xopt" in the original code.
private ArrayRealVector gradientAtTrustRegionCenter
originShift
+
trustRegionCenterOffset
.
XXX "gopt" in the original code.
private ArrayRealVector lowerDifference
BaseMultivariateOptimizer.getLowerBound()
- originShift
.
All the components of every trustRegionCenterOffset
are going
to satisfy the boundslowerBound
i ≤
trustRegionCenterOffset
i,trustRegionCenterOffset
is
on a constraint boundary.
XXX "sl" in the original code.
private ArrayRealVector upperDifference
BaseMultivariateOptimizer.getUpperBound()
- originShift
All the components of every trustRegionCenterOffset
are going
to satisfy the boundstrustRegionCenterOffset
i ≤
upperBound
i,trustRegionCenterOffset
is
on a constraint boundary.
XXX "su" in the original code.
private ArrayRealVector modelSecondDerivativesParameters
private ArrayRealVector newPoint
trsbox
or altmov
.
Usually originShift
+ newPoint
is the vector of
variables for the next evaluation of the objective function.
It also satisfies the constraints indicated in lowerDifference
and upperDifference
.
XXX "xnew" in the original code.
private ArrayRealVector alternativeNewPoint
newPoint
, chosen by
altmov
.
It may replace newPoint
in order to increase the denominator
in the updating procedure
.
XXX "xalt" in the original code.
private ArrayRealVector trialStepPoint
trustRegionCenterOffset
which is usually
newPoint
- trustRegionCenterOffset
.
XXX "d__" in the original code.
private ArrayRealVector lagrangeValuesAtNewPoint
private ArrayRealVector modelSecondDerivativesValues
Constructor Detail |
---|
public BOBYQAOptimizer(int numberOfInterpolationPoints)
numberOfInterpolationPoints
- Number of interpolation conditions.
For a problem of dimension n
, its value must be in the interval
[n+2, (n+1)(n+2)/2]
.
Choices that exceed 2n+1
are not recommended.public BOBYQAOptimizer(int numberOfInterpolationPoints, double initialTrustRegionRadius, double stoppingTrustRegionRadius)
numberOfInterpolationPoints
- Number of interpolation conditions.
For a problem of dimension n
, its value must be in the interval
[n+2, (n+1)(n+2)/2]
.
Choices that exceed 2n+1
are not recommended.initialTrustRegionRadius
- Initial trust region radius.stoppingTrustRegionRadius
- Stopping trust region radius.Method Detail |
---|
protected PointValuePair doOptimize()
doOptimize
in class BaseOptimizer<PointValuePair>
private double bobyqa(double[] lowerBound, double[] upperBound)
lowerBound
- Lower bounds.upperBound
- Upper bounds.
private double bobyqb(double[] lowerBound, double[] upperBound)
lowerBound
- Lower bounds.upperBound
- Upper bounds.
private double[] altmov(int knew, double adelt)
knew
- adelt
- private void prelim(double[] lowerBound, double[] upperBound)
lowerBound
- Lower bounds.upperBound
- Upper bounds.private double[] trsbox(double delta, ArrayRealVector gnew, ArrayRealVector xbdi, ArrayRealVector s, ArrayRealVector hs, ArrayRealVector hred)
delta
- gnew
- xbdi
- s
- hs
- hred
- private void update(double beta, double denom, int knew)
beta
- denom
- knew
- private void setup(double[] lowerBound, double[] upperBound)
lowerBound
- Lower bounds (constraints) of the objective variables.upperBound
- Upperer bounds (constraints) of the objective variables.private static double[] fillNewArray(int n, double value)
n
- Dimension of the returned array.value
- Value for each element.
n
elements set to the given
value
.private static java.lang.String caller(int n)
private static void printState(int s)
private static void printMethod()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |