|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.bio.EvolveStandard
org.generation5.demos.EvoDiophantine
EvoDiophantine is an example of a genetic algorithm solving a
diophantine equation. A diophantine equation is an integer-only equation of the
form ax+by+cz...=t. The class solves for the variables given the
coefficients a, b, c etc. and target t.
| Field Summary |
| Fields inherited from class org.generation5.bio.EvolveStandard |
fitnessValue, minimizeFitness, random |
| Constructor Summary | |
EvoDiophantine()
Creates a new instance of EvoDiophantine |
|
| Method Summary | |
void |
calculateFitness()
Diophantine fitness is calculated as the error between the target value and the calculated value. |
double |
getFitness()
Return the fitness of this object. |
static void |
main(java.lang.String[] args)
Run the genetic algorithm on the specified coefficients and target values. |
Evolvable |
mate(Evolvable partner)
One-point crossover of the equation values. |
void |
mutate()
Mutates one of the equation values by a random value between -2 and 2. |
void |
randomInitialize()
Initialize the equation values to a number within the specified range. |
static void |
setCoefficients(int[] coeff,
int target)
Set the coefficients and target of the equation. |
void |
setRange(int min,
int max)
Set the range the genetic algorithm checks between. |
java.lang.String |
toString()
|
| Methods inherited from class org.generation5.bio.EvolveStandard |
compareTo |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public EvoDiophantine()
| Method Detail |
public void calculateFitness()
calculateFitness in interface EvolvablecalculateFitness in class EvolveStandardpublic double getFitness()
getFitness in interface EvolvablegetFitness in class EvolveStandardpublic Evolvable mate(Evolvable partner)
mate in interface Evolvablemate in class EvolveStandardpartner - the other parent equation.
public void mutate()
mutate in interface Evolvablemutate in class EvolveStandardpublic void randomInitialize()
randomInitialize in interface EvolvablerandomInitialize in class EvolveStandardsetRange(int, int)
public void setRange(int min,
int max)
min - minimum value.max - maximum value.public java.lang.String toString()
public static void setCoefficients(int[] coeff,
int target)
coeff - the coefficients.target - target value.public static void main(java.lang.String[] args)
args - coefficients and target value to run the GA on.
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||