de.htwdd.rosenkoenig.ga
Class GeneticRosenkoenig

java.lang.Object
  extended by de.htwdd.ga.GeneticAlgorithm
      extended by de.htwdd.rosenkoenig.ga.GeneticRosenkoenig

public class GeneticRosenkoenig
extends de.htwdd.ga.GeneticAlgorithm

This implementation of GeneticAlgorithm tries to determine an appropriate neural network for an artificial Rosenkoenig player.

Because of the time consuming fitness function, this Genetic Algorithm should be run on a multiprocessor machine. The algorithm runs for 200 cycles, after each cycle the current generation is written to a file. GeneticRosenkoenig uses TwoPointCrossover, RankingSelection and NetworkFitness.
Also some methods of GeneticAlgorithm have been overwritten to make the algorithm more "talkative". E.g. after each replacement, the fitness of the current population is written to the log.

See Also:
NeuroPlayer

Field Summary
static java.lang.String FILE_PREFIX
           
static java.lang.String[] FILENAMES
           
private  org.apache.log4j.Logger log
           
private static java.lang.String POPULATION_FILE_PREFIX
           
private  long start
           
private  long stop
           
 
Fields inherited from class de.htwdd.ga.GeneticAlgorithm
children, chromosomeLength, crossoverMethod, cycle, initializationFunction, matingCandidates, maxCycles, multiThreaded, mutationRate, numThreads, population, populationSize, replacementStrategy, selectionStrategy, terminatonFitness
 
Constructor Summary
GeneticRosenkoenig(int chromosomeLength, int numCycles, int populationSize)
          Creates a GeneticAlgorithm with the given parameters and a termination fitness of 0.98.
 
Method Summary
static void main(java.lang.String[] args)
          Initializes and starts the Genetic Algorithm.
protected  void runReplacement()
          
protected  void runReproduction()
          
protected  void runSelection()
          
 
Methods inherited from class de.htwdd.ga.GeneticAlgorithm
calculateFitness, getBestFitness, getChildren, getChromosomeLength, getCrossoverMethod, getFitnessFunction, getInitializationFunction, getMaxCycles, getMutationRate, getPopulation, getPopulationSize, getReplacementStrategy, getSelectionStrategy, getTerminatonFitness, instantiateFitnessFunction, isMultiThreaded, run, setChromosomeLength, setCrossoverMethod, setFitnessFunction, setInitializationFunction, setMaxCycles, setMultiThreaded, setMutationRate, setPopulationSize, setReplacementStrategy, setSelectionStrategy, setTerminatonFitness
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POPULATION_FILE_PREFIX

private static final java.lang.String POPULATION_FILE_PREFIX
See Also:
Constant Field Values

FILE_PREFIX

public static final java.lang.String FILE_PREFIX
See Also:
Constant Field Values

FILENAMES

public static final java.lang.String[] FILENAMES

log

private org.apache.log4j.Logger log

start

private long start

stop

private long stop
Constructor Detail

GeneticRosenkoenig

public GeneticRosenkoenig(int chromosomeLength,
                          int numCycles,
                          int populationSize)
Creates a GeneticAlgorithm with the given parameters and a termination fitness of 0.98.

Parameters:
chromosomeLength -
numCycles -
populationSize -
Method Detail

runSelection

protected void runSelection()

Overrides:
runSelection in class de.htwdd.ga.GeneticAlgorithm

runReproduction

protected void runReproduction()

Overrides:
runReproduction in class de.htwdd.ga.GeneticAlgorithm

runReplacement

protected void runReplacement()

Overrides:
runReplacement in class de.htwdd.ga.GeneticAlgorithm

main

public static void main(java.lang.String[] args)
Initializes and starts the Genetic Algorithm.

Parameters:
args - specify a filename to initialize with a population