|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.util.TravellingSalesman
org.generation5.demos.EvoTravellingSalesman
This class implements a simple evolvable solution to the travelling salesman problem.
| Field Summary | |
protected double |
fitnessValue
The fitness value. |
protected static java.util.Random |
random
An instance of java.util.Random, useful for generating a range of random numbers. |
| Fields inherited from class org.generation5.util.TravellingSalesman |
cityCoordinates, maximumCities, maximumX, maximumY, nodeLabels, numberCities, route, routeGradient |
| Constructor Summary | |
EvoTravellingSalesman()
Creates a new instance of EvoTravellingSalesman |
|
| Method Summary | |
void |
calculateFitness()
Calculate the fitness of this route. |
int |
compareTo(java.lang.Object o)
Implementation for the Comparable interface. |
protected void |
flip(int i1,
int i2)
Flip two route positions. |
double |
getFitness()
Return the fitness of this route. |
static void |
main(java.lang.String[] args)
A basic test function. |
Evolvable |
mate(Evolvable partner)
Mate two routes together. |
void |
mutate()
Mutates a route. |
void |
randomInitialize()
Initialize the route randomly. |
java.lang.String |
toString()
Returns the route as a string. |
| Methods inherited from class org.generation5.util.TravellingSalesman |
addCity, addCity, getCity, getCityDistance, getDimensionX, getDimensionY, render, resetCities, routeLength, routeLength, setDimension, setMaximumCities, writeImage |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected double fitnessValue
protected static java.util.Random random
| Constructor Detail |
public EvoTravellingSalesman()
| Method Detail |
public static void main(java.lang.String[] args)
TravellingSalesman
args - the command line argumentspublic java.lang.String toString()
public void calculateFitness()
calculateFitness in interface Evolvablepublic Evolvable mate(Evolvable partner)
mate in interface Evolvablepartner - Partner object.
public void mutate()
mutate in interface Evolvablepublic void randomInitialize()
randomInitialize in interface Evolvable
protected void flip(int i1,
int i2)
i1 - the first index.i2 - the second index.public int compareTo(java.lang.Object o)
Comparable interface. Compares two route's
length.
compareTo in interface java.lang.Comparableo - object to compare to.
public double getFitness()
getFitness in interface Evolvable
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||