neet-0.1.0.0: A NEAT library for Haskell

Copyright(c) Leon Medvinsky, 2015
LicenseGPL-3
Maintainerlmedvinsky@hotmail.com
Stabilityexperimental
Portabilityghc
Safe HaskellNone
LanguageHaskell2010

Neet.Genome

Contents

Description

 

Synopsis

Genes

newtype NodeId Source

The IDs node genes use to refer to nodes.

Constructors

NodeId Int 

data NodeType Source

Types of nodes

Constructors

Input 
Hidden 
Output 

Instances

data NodeGene Source

Node genes

Constructors

NodeGene 

Fields

nodeType :: NodeType
 
yHint :: Rational

A hint for recurrency

Instances

data ConnGene Source

Connection genes

Constructors

ConnGene 

Fields

connIn :: NodeId
 
connOut :: NodeId
 
connWeight :: Double
 
connEnabled :: Bool
 
connRec :: Bool

A hint for recurrency

Instances

newtype InnoId Source

Innovation IDs

Constructors

InnoId Int 

data ConnSig Source

Signature of a connection, used in matching innovations fromthe same generation.

Genome

data Genome Source

A NEAT genome. The innovation numbers are stored in here, and not the genes, to prevent data duplication.

Instances

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

distance :: Parameters -> Genome -> Genome -> Double Source

Genetic distance between two genomes

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.