|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectFacemorph.Powell
public abstract class Powell
Implements Powells method, classes should subclass this and implement the func and onIteration methods to use
| Field Summary | |
|---|---|
java.util.ArrayList<java.lang.Double> |
fittnessMemo
|
int |
kNN
|
java.util.ArrayList<double[]> |
memo
|
static double |
TINY
A very small amount |
| Constructor Summary | |
|---|---|
Powell()
Creates a new instance of Powell |
|
| Method Summary | |
|---|---|
abstract double |
func(double[] params)
Func should be overrided to calculate the error given the parameters params |
void |
linmin(double[] p,
double[] xi,
int n,
double[] fret)
Given an n-dimensional point p[1..n] and an n-dimensional direction xi[1..n], moves and resets p to where the function func(p) takes on a minimum along the direction xi from p, and replaces xi by the actual vector displacement that p was moved. |
abstract void |
onIteration(double[] params)
onIteration is called once per complete itrations to show the best current guess. |
void |
optimiseGA(double[] p,
int samples,
double mutationRate,
boolean keepBest,
int maxIts)
Genetic algorith optimisation |
void |
powell(double[] p,
double[][] xi,
int n,
double ftol,
int[] iter,
double[] fret,
int maxits)
Minimization of a function func of n variables. |
double |
powell(double[] p,
double ftol,
int[] iter,
int maxits)
Minimization of a function func of n variables. |
void |
spsa(double[] p,
double a,
double c,
double A,
double alpha,
double gamma,
double ftol,
int maxIts)
Implements basic Simultaneous Perturbation Stochastic Approximation (SPSA) algortihm |
void |
spsa2(double[] p,
double a,
double c,
double A,
double alpha,
double gamma,
double ftol,
int maxIts)
Implements basic Simultaneous Perturbation Stochastic Approximation (SPSA) algortihm |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public java.util.ArrayList<double[]> memo
public java.util.ArrayList<java.lang.Double> fittnessMemo
public int kNN
public static final double TINY
| Constructor Detail |
|---|
public Powell()
| Method Detail |
|---|
public abstract double func(double[] params)
params - the parameters to evaluate
public abstract void onIteration(double[] params)
params - the current params of the model
public void optimiseGA(double[] p,
int samples,
double mutationRate,
boolean keepBest,
int maxIts)
p - the initial start point (mutated and bred with itself to form the initial populationsamples - number of samples in each generationmutationRate - mutation rate as fractionkeepBest - keep the optimal from each generation, or notmaxIts - maximum number of iterations
public double powell(double[] p,
double ftol,
int[] iter,
int maxits)
throws PowellException
p - starting pointiter - number of iterations takenftol - the fractional tolerance in the function valuemaxits - maximum number of iterations permitted
PowellException - if something goes wrong e.g. max iterations exceeded
public void powell(double[] p,
double[][] xi,
int n,
double ftol,
int[] iter,
double[] fret,
int maxits)
throws PowellException
p - starting pointn - size of vectorsxi - initial direction setfret - returned function value at final pointiter - number of iterations takenftol - the fractional tolerance in the function valuemaxits - maximum number of iterations permitted
PowellException - if something goes wrong e.g. max iterations exceeded
public void spsa(double[] p,
double a,
double c,
double A,
double alpha,
double gamma,
double ftol,
int maxIts)
p - the initial guess, will also contain the output estimatea - c - A - alpha - gamma - ftol - termination parametermaxIts - number of iterations to compute (should be replaced with termination condition)
public void spsa2(double[] p,
double a,
double c,
double A,
double alpha,
double gamma,
double ftol,
int maxIts)
p - the initial guess, will also contain the output estimatea - c - A - alpha - gamma - ftol - related to the termination condition, change in error should be below thismaxIts - number of iterations to compute (should be replaced with termination condition)
public void linmin(double[] p,
double[] xi,
int n,
double[] fret)
throws PowellException
p - an n-dimensional point, used for outputxi - an n-dimensional directionn - the dimensions of the search spacefret - returns the value of func at the returned location p
PowellException - if there is a problem
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||