HSGEP-0.1.5: Gene Expression Programming evolutionary algorithm in Haskell

Safe HaskellSafe-Inferred

GEP.Types

Contents

Description

This module defines the types used for implementing GEP problems and operations. A few functions are also provided for convenience here for performing common operations.

Synopsis

Types

data Genome Source

Data type representing a genome. The genome contains all necessary parameters to interpret a chromosome. These include the alphabet (split between terminal and nonterminal characters), connective characters for multi-gene chromosomes, the maximum arity of any nonterminal, the length of the head of a gene, and the number of genes per chromosome.

Constructors

Genome 

Fields

terminals :: [Symbol]

Set of terminal symbols

nonterminals :: [Symbol]

Set of nonterminal symbols

geneConnector :: Symbol

Symbol connecting genes in a chromosome

maxArity :: Int

Highest arity nonterminal function

headLength :: Int

Length of gene head sequence

numGenes :: Int

Number of genes per chromosome

Instances

type Symbol = CharSource

A symbol in a chromosome

type Sequence = [Char]Source

A sequence of symbols not neccessaryly a gene or chromosome. Used in gene operations.

type Gene = SequenceSource

A gene in a chromosome is a list of symbols

type Chromosome = SequenceSource

A chromosome is a list of symbols. We avoided using a list of genes to maintain the view of a chromosome as nothing more than a flattened, linear sequence of genes.

type SymTable a = [(Symbol, a)]Source

Symbol table used for fitness tests. We assume that there is exactly one pair per symbol. If there are symbols missing, fitness testing may fail (the library does not have facilities yet to allow for default values). If a symbol occurs multiple times in the symbol table, no guarantee is provided for which value will be chosen.

type ExpressionFunction a = Chromosome -> Genome -> aSource

Function to express an individual into a list of ET structures

Functions

tailLengthSource

Arguments

:: Genome

Genome

-> Int

Number of symbols in a gene tail

Return the length of the tail of a gene for a given genome

geneLengthSource

Arguments

:: Genome

Genome

-> Int

Total length of a gene.

Return length of a gene (tail + head) for a given genome

allsymbolsSource

Arguments

:: Genome

Genome

-> [Symbol]

List of symbols

Given a genome, provide the list of all symbols possible in a chromosome. This is just nonterminals ++ terminals.

chromToGenesSource

Arguments

:: Chromosome

Chromosome to split into a set of genes

-> Int

Length of a single gene

-> [Gene]

Ordered list of genes from chromosome

Fracture a chromosome into a set of genes

genesToChromSource

Arguments

:: [Gene]

List of genes

-> Chromosome

Chromosome assembled from genes

Assemble a chromosome from a set of genes

isNonterminalSource

Arguments

:: Symbol

Symbol to test

-> Genome

Genome providing context

-> Bool

True if symbol is a nonterminal, false otherwise

Test if a symbol is a nonterminal