neat4jsmall
Home
Tutorials
  Using the MSE Fitness Function
  Creating Experiments
  Creating Operators
  Creating Data Loaders
  Creating A Game
  Distributed Learning
Documentation
Screenshots
Downloads
Contact
Writing the Forex Fitness Function
Creating your own experiment is fairly straight forward. All you need to do is write a class that extends org.neat4j.neat.core.NeuralFitnessFunction and create your own implementation of the evaluate(Chromosome genoType) method.

You can see an examples at:
1) org.neat4j.neat.core.fitness.MSENEATFitnessFunction.java (used for XOR experiment)
2) org.neat4j.neat.core.fitness.FXTradingNEATFitnessFunction.java
You will need to have dowloaded the source pack to see these source files.

The first thing you need to do is to create the network structure. This is simply a call to the createNetFromChromo(Chromosome genoType) method which lives in the NEATFitnessFunction class.

Next, you need to get hold of the evaluation data used for training. To do this, call evaluationData() which is located in org.neat4j.neat.ga.core.NeuralFitnessFunction, the super class of NEATFitnessFunction. The return from this call is a NetworkDataSet which contains both input and expected output data sets. You can then use this data according to your experimental needs. You can see from looking at the source from the examples above that they work very differently, yet to the main code they appear the same. Note, don't forget to set the NATURAL.ORDER.STRATEGY in your .ga file appropriately, see Configuration for more details on this setting.

There is an advanced feature of fitness functions in that you can modify an arbitary input value. This can be useful if, for example, you want to tell your trading network the result of the previous trade. To do this, you will need to create a org.neat4j.neat.data.modify.ModifiableInput and then modify using one of the three methods it provides. Obviously, this will overwrite any data from your input data, so you can create dummy data entries that get modified. To see an example, look at the FXTradingNEATFitnessFunction. The relevant block of code is commented out.