de.htwdd.rosenkoenig.ga
Class NetworkFitness

java.lang.Object
  extended by de.htwdd.rosenkoenig.ga.NetworkFitness
All Implemented Interfaces:
de.htwdd.ga.FitnessFunction

public class NetworkFitness
extends java.lang.Object
implements de.htwdd.ga.FitnessFunction

A FitnessFunction to calculate the fitness of a neural net which could be applied to an artificial player.
To calculate the fitness, the neural network has to be trained, which is a very time consuming process. NetworkFitness does not use realistic numbers of training cycles (e.g. 1000 or more) but trains the network for about 25 cycles. So this fitness function can only approximate if a chromosome could be appropriate for artificial players. NetworkFitness does not calculate a mathematically correct fitness!

See the Rosenkoenig online documentation for more detailed information.


Field Summary
private  Backpropagation backprop
           
private  java.util.ArrayList<Pattern> ffPatterns
          Training patterns to train a Feed Forward Neural Network.
private  int index
          Index of the FitnessFunction.
private  int[] layerSizes
           
private  org.apache.log4j.Logger log
           
private static int numFunctions
          Static member that holds the number of instances of NetworkFitness present in the current process.
private  java.util.ArrayList<double[]> somPatterns
          Training patterns for SOM training.
private  boolean useSom
           
 
Constructor Summary
NetworkFitness()
          Creates a new fitness function and initializes the training data.
 
Method Summary
 double computeFitness(java.util.BitSet chromosome)
          Calculates the fitness for a given chromosome.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numFunctions

private static int numFunctions
Static member that holds the number of instances of NetworkFitness present in the current process.


index

private int index
Index of the FitnessFunction.


log

private org.apache.log4j.Logger log

somPatterns

private java.util.ArrayList<double[]> somPatterns
Training patterns for SOM training.


ffPatterns

private java.util.ArrayList<Pattern> ffPatterns
Training patterns to train a Feed Forward Neural Network.


layerSizes

private int[] layerSizes

useSom

private boolean useSom

backprop

private Backpropagation backprop
Constructor Detail

NetworkFitness

public NetworkFitness()
Creates a new fitness function and initializes the training data. The files used for training are specified by GeneticRosenkoenig.FILENAMES.

Method Detail

computeFitness

public double computeFitness(java.util.BitSet chromosome)
Calculates the fitness for a given chromosome. Extracts the chromosome and determines the number of layers, the number of neurons per layer. The first bit of the chromosome determines if a SOM should be used.
After that a neural network is created and trained for a small number of cycles. The lower the error on the training set, the higher is the chromosome's fitness.

Specified by:
computeFitness in interface de.htwdd.ga.FitnessFunction