Copyright | (c) Leon Medvinsky, 2015 |
---|---|
License | GPL-3 |
Maintainer | lmedvinsky@hotmail.com |
Stability | experimental |
Portability | ghc |
Safe Haskell | None |
Language | Haskell2010 |
- newtype NodeId = NodeId {}
- data NodeType
- data NodeGene = NodeGene {}
- data ConnGene = ConnGene {
- connIn :: NodeId
- connOut :: NodeId
- connWeight :: Double
- connEnabled :: Bool
- connRec :: Bool
- newtype InnoId = InnoId {}
- data ConnSig
- data Genome = Genome {}
- fullConn :: MonadRandom m => MutParams -> Int -> Int -> m Genome
- sparseConn :: MonadRandom m => MutParams -> Int -> Int -> Int -> m Genome
- genomeComplexity :: Genome -> Int
- mutateAdd :: (MonadRandom m, MonadFresh InnoId m) => MutParams -> Map ConnSig InnoId -> Genome -> m (Map ConnSig InnoId, Genome)
- mutateSub :: MonadRandom m => MutParams -> Genome -> m Genome
- crossover :: MonadRandom m => MutParams -> Genome -> Genome -> m Genome
- breed :: (MonadRandom m, MonadFresh InnoId m) => MutParams -> Map ConnSig InnoId -> Genome -> Genome -> m (Map ConnSig InnoId, Genome)
- distance :: Parameters -> Genome -> Genome -> Double
- data GenScorer score = GS {
- gScorer :: Genome -> score
- fitnessFunction :: score -> Double
- winCriteria :: score -> Bool
- renderGenome :: Genome -> IO ()
- printGenome :: Genome -> IO ()
- validateGenome :: Genome -> Maybe [String]
Genes
The IDs node genes use to refer to nodes.
Types of 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 => MutParams -> 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.
sparseConn :: MonadRandom m => MutParams -> Int -> Int -> Int -> m Genome Source
Like fullConn
, but with only some input-outputs connected. First integer
parameters is the max number of connections to start with.
Stats
genomeComplexity :: Genome -> Int Source
Total number of links and nodes.
Breeding
mutateAdd :: (MonadRandom m, MonadFresh InnoId m) => MutParams -> Map ConnSig InnoId -> Genome -> m (Map ConnSig InnoId, Genome) Source
Mutates the genome, using the specified parameters and innovation context.
mutateSub :: MonadRandom m => MutParams -> Genome -> m Genome Source
Mutates the genome, but uses subtractive mutations instead of additive.
crossover :: MonadRandom m => MutParams -> Genome -> Genome -> m Genome Source
Crossover. The first argument is the fittest genome.
breed :: (MonadRandom m, MonadFresh InnoId m) => MutParams -> Map ConnSig InnoId -> Genome -> Genome -> m (Map ConnSig InnoId, Genome) Source
Breed two genomes together
Distance
Fitness
Parameters for search. The type parameter determines the intermediate type for determining if a solution is valid.
GS | |
|
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.
printGenome :: Genome -> IO () Source
A nicer way to display a Genome
than the Show instance.