|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvec_math.Amoeba
public class Amoeba
An amoeba is a simplex method for finding (local) minimas of a
multi-dimensional function. It is slow, but very robust. Based on the
algorithm's in Numerical Recipes in C, p.408ff. For function whose evaluation
might introduce some noise, convergence will never be achieved. Thus, a
setNoiseLevel(double) is introduced that relaxes the tolerance criterium a
little bit as the offset reaches the noise level. There is no literature I'm
aware off on these matters, thus we have an ad-hoc approach: In the presence
of noise stop the optimization when either the diameter of the simplex is
smaller then the noise level or if the tolerance level falls below the random
noise level.
| Nested Class Summary | |
|---|---|
static class |
Amoeba.Test
Class for testing the amoeba. |
| Field Summary | |
|---|---|
private double |
chimin
Smalles value of the function ever encountered. |
private double |
dchi
Smalles decrease of the function ever encountered. |
static int |
DEFCRAWL
|
static int |
DEFDIMCRAWL
|
static int |
DEFMAXCRAWL
The default maximum number of crawl tries. |
static double |
DEFTOLERANCE
Default tolerance level. |
private Multidimensional |
f
An n-dimensional function that is evaluated with an VectorG. |
private VectorG |
fout
On output, the evaluation of f at points #out. |
private int |
nmax
A maximum number of crawls. |
private double |
noise
If we have a noisy function, optimize at max to this noise level. |
private VectorG[] |
p
An n+1-dimensional set of starting points. |
private VectorG[] |
pout
On output, the n+1 points lying within tolerance around min. |
private VectorG |
smallest
Vectro where the smalles function value was encountered. |
private static double |
TINY
To avoid 0/0 divisions spoiling the convergence. |
private double |
tolerance
A convergence criteria, a small positive number . |
| Constructor Summary | |
|---|---|
Amoeba()
Creates an amoeba with the default tolerance level and the default maximum number of crawls. |
|
Amoeba(double ftol)
Creates an amoeba with the default maximum number of crawls. |
|
Amoeba(double ftol,
int max)
Creates an amoeba specifying the tolerance level and the maximum number of crawls. |
|
Amoeba(int dimension)
Creates an amoeba with the default tolerance level and the default maximum number of crawls. |
|
| Method Summary | |
|---|---|
private double |
amotry(VectorG[] base,
VectorG val,
VectorG psum,
int ih,
double direction)
An ugly method that extrapolates through the face of the simplex from the highest point. |
int |
crawl()
Slides down from the starting points p until it reaches a local
minimum, i.e. |
int |
crawl(boolean print)
Slides down from the starting points p until it reaches a local
minimum, i.e. |
void |
estimateStart(VectorG single,
double scale)
Tries to estimate a starting simplex from a single start point. |
void |
estimateStart(VectorG single,
VectorG scale)
Tries to estimate a starting simplex from a single start point. |
double |
getApproximation()
On successful crawls, this method returns the last function evaluation closest to the function minimum. |
VectorG |
getClosestPoint()
On successful crawls, this method returns the point closest to the function minimum. |
Multidimensional |
getFunction()
Returns the function set. |
VectorG[] |
getSimplex()
On successful crawls, this method returns the last points of the simplex. |
VectorG |
getSimplexValue()
On successful crawls, this method returns the last function evaluations at the simplex's points, see getSimplex(). |
VectorG |
getSmallestArgument()
On minimization of a chi-square value, it makes sense to record the smallest functional value that was obtained during the Amoeba. |
double |
getSmallestDecrease()
Returns the smallest relative decrease during Amoeba crawl. |
double |
getSmallestValue()
On minimization of a chi-square value, it makes sense to record the smallest functional value that was obtained during the Amoeba. |
private VectorG |
getSum(VectorG[] calc)
Evaluates the sum of a vector array. |
void |
setFunction(Multidimensional fmult)
Sets the multidimensional function that should be minimized. |
void |
setNoiseLevel(double white)
Sets a noise level on the minimization function thus changing the convergence criterium to exit the crawl either when the simplex's diameter or the tolerance level has fallen below the noise level. |
void |
setStart(VectorG[] start)
Sets the starting simplex. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double DEFTOLERANCE
public static final int DEFMAXCRAWL
private static final double TINY
public static final int DEFCRAWL
public static final int DEFDIMCRAWL
private Multidimensional f
VectorG.
private VectorG[] p
private double tolerance
private double chimin
private double dchi
private VectorG smallest
private int nmax
private VectorG[] pout
tolerance around min.
private VectorG fout
f at points #out.
private double noise
| Constructor Detail |
|---|
public Amoeba()
setFunction(vec_math.Multidimensional) and setStart(vec_math.VectorG[])
before calling the crawl() method.
public Amoeba(int dimension)
setFunction(vec_math.Multidimensional) and setStart(vec_math.VectorG[])
before calling the crawl() method.
public Amoeba(double ftol)
setFunction(vec_math.Multidimensional) and setStart(vec_math.VectorG[]) before calling the
crawl() method.
public Amoeba(double ftol,
int max)
setFunction(vec_math.Multidimensional) and setStart(vec_math.VectorG[]) before calling the
crawl() method.
| Method Detail |
|---|
public void setFunction(Multidimensional fmult)
public Multidimensional getFunction()
public void setStart(VectorG[] start)
public void estimateStart(VectorG single,
double scale)
public void estimateStart(VectorG single,
VectorG scale)
public void setNoiseLevel(double white)
public VectorG[] getSimplex()
public VectorG getClosestPoint()
getSimplex()
public VectorG getSimplexValue()
getSimplex(). For convenience, the
smallest value is at index zero.
public double getApproximation()
getSimplexValue() at index zero
public int crawl()
p until it reaches a local
minimum, i.e. until all vertex point lie within tolerance around
the function minimum. It returns the number of steps it took the algoritm
to converge or -1 if no convergence was reached. In case of convergence,
the resulting points and the evaluation of f at these points can
be retrieved with calls to #getVertex and #getValues,
respectively.
public int crawl(boolean print)
p until it reaches a local
minimum, i.e. until all vertex point lie within tolerance around
the function minimum. It returns the number of steps it took the algoritm
to converge or -1 if no convergence was reached. In case of convergence,
the resulting points and the evaluation of f at these points can
be retrieved with calls to #getVertex and #getValues,
respectively.
public double getSmallestValue()
public double getSmallestDecrease()
public VectorG getSmallestArgument()
private double amotry(VectorG[] base,
VectorG val,
VectorG psum,
int ih,
double direction)
private VectorG getSum(VectorG[] calc)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||