Portability | portable |
---|---|
Stability | experimental |
Maintainer | amy@nualeargais.ie |
Safe Haskell | None |
Utilities for working with genes that are encoded as a sequence of bits, using a Binary Reflected Gray Code (BRGC).
A Gray code maps values to codes in a way that guarantees that the codes for two consecutive values will differ by only one bit. This feature can be useful in evolutionary programming because the genes resulting from a crossover operation are likely to be similar to the inputs. This helps to ensure that offspring are similar to their parents, as any radical changes from one generation to the next are the result of mutation alone.
- class Genetic g where
- type Sequence = [Bool]
- type Writer = StateT Sequence Identity
- write :: Genetic x => x -> Sequence
- runWriter :: Writer () -> Sequence
- type Reader = StateT (Sequence, Int) Identity
- read :: Genetic g => Sequence -> Either [String] g
- runReader :: Reader g -> Sequence -> g
- copy :: Reader Sequence
- consumed :: Reader Sequence
- type DiploidSequence = (Sequence, Sequence)
- type DiploidReader = StateT ((Sequence, Int), (Sequence, Int)) Identity
- readAndExpress :: (Genetic g, Diploid g) => DiploidSequence -> Either [String] g
- runDiploidReader :: DiploidReader g -> DiploidSequence -> g
- getAndExpress :: (Genetic g, Diploid g) => DiploidReader (Either [String] g)
- getAndExpressWithDefault :: (Genetic g, Diploid g) => g -> DiploidReader g
- copy2 :: DiploidReader DiploidSequence
- consumed2 :: DiploidReader DiploidSequence
Documentation
A class representing anything which is represented in, and determined by, an agent's genome. This might include traits, parameters, organs (components of agents), or even entire agents. Instances of this class can be thought of as genes, i.e., instructions for building an agent.
type DiploidSequence = (Sequence, Sequence)Source
readAndExpress :: (Genetic g, Diploid g) => DiploidSequence -> Either [String] gSource
runDiploidReader :: DiploidReader g -> DiploidSequence -> gSource
getAndExpress :: (Genetic g, Diploid g) => DiploidReader (Either [String] g)Source
Read the next pair of genes from twin sequences of genetic information, and return the resulting gene (after taking into account any dominance relationship) and the remaining (unread) portion of the two nucleotide strands.
getAndExpressWithDefault :: (Genetic g, Diploid g) => g -> DiploidReader gSource
copy2 :: DiploidReader DiploidSequenceSource
Return the entire genome.
consumed2 :: DiploidReader DiploidSequenceSource
Return the portion of the genome that has been read.