Copyright | (c) Leon Medvinsky, 2015 |
---|---|
License | GPL-3 |
Maintainer | lmedvinsky@hotmail.com |
Stability | experimental |
Portability | ghc |
Safe Haskell | None |
Language | Haskell2010 |
- newtype NodeId = NodeId Int
- data NodeType
- data NodeGene = NodeGene {}
- data ConnGene = ConnGene {
- connIn :: NodeId
- connOut :: NodeId
- connWeight :: Double
- connEnabled :: Bool
- connRec :: Bool
- newtype InnoId = InnoId Int
- data ConnSig
- data Genome = Genome {}
- fullConn :: MonadRandom m => Parameters -> Int -> Int -> m Genome
- mutate :: (MonadRandom m, MonadFresh InnoId m) => Parameters -> Map ConnSig InnoId -> Genome -> m (Map ConnSig InnoId, Genome)
- crossover :: MonadRandom m => Parameters -> Genome -> Genome -> m Genome
- breed :: (MonadRandom m, MonadFresh InnoId m) => Parameters -> Map ConnSig InnoId -> Genome -> Genome -> m (Map ConnSig InnoId, Genome)
- distance :: Parameters -> Genome -> Genome -> Double
- renderGenome :: Genome -> IO ()
Genes
The IDs node genes use to refer to nodes.
Node genes
Connection genes
Innovation IDs
Signature of a connection, used in matching innovations fromthe same generation.
Genome
A NEAT genome. The innovation numbers are stored in here, and not the genes, to prevent data duplication.
Construction
fullConn :: MonadRandom m => Parameters -> Int -> Int -> m Genome Source
Takes the number of inputs, the number of outputs, and gives a genome with the inputs fully connected to the outputs with random weights. The order of the connections are deterministic, so when generating a population, you can just start the innovation number at (iSize + 1) * oSize, since the network includes an additional input for the bias.
Breeding
mutate :: (MonadRandom m, MonadFresh InnoId m) => Parameters -> Map ConnSig InnoId -> Genome -> m (Map ConnSig InnoId, Genome) Source
Mutates the genome, using the specified parameters and innovation context.
crossover :: MonadRandom m => Parameters -> Genome -> Genome -> m Genome Source
Crossover. The first argument is the fittest genome.
breed :: (MonadRandom m, MonadFresh InnoId m) => Parameters -> Map ConnSig InnoId -> Genome -> Genome -> m (Map ConnSig InnoId, Genome) Source
Breed two genomes together
Distance
Visualization
renderGenome :: Genome -> IO () Source
This graph produced is ugly and janky and will have bugs, like hidden nodes occasionally appearing with output nodes, and weird clustering overall. If you see some problems in the graph, confirm with the Show instance or something else that there really is a problem.