A Kotlin implementation of NEAT(NeuroEvolution of Augmenting Topologies ) for the generation of evolving artificial neural networks with Coroutines support.
Implimentation of http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.Advice-Dog:evo-NEAT:-SNAPSHOT'
}
You must implement the Environment
interface and override the evaluateFitness(population: List<Genome>)
function.
For each Genome
in the population, you want to call Genome.evaluateNetwork(...)
with your inputs, and then calculate the fitness from the result and set it on the Genome
.
You can config how the model is created using the NEATConfig.Builder
.
val config: NeatConfig = NEATConfig.Builder()
.setPopulationSize(300)
.setBatchSize(100)
.setInputs(2)
.setOutputs(1)
.build()
For each generation, the library will separate them into batches and calculate their fitness in parallel. The number of Coroutines is based on the population size / the batch size.
With the following config, the library will create 10
Coroutines each generation.
val config: NeatConfig = NEATConfig.Builder()
.setPopulationSize(500)
.setBatchSize(50)
.build()
A full example of the XOR implementation is given in the folder evo-NEAT/src/examples/ .