heukarya-0.1.0.1: A genetic programming based on tree structure.

Safe HaskellNone

AI.Heukarya.Gene

Contents

Description

Operation and interface for Genes

Synopsis

Documentation

module Data.Tree

Gene Operations

genEukaryaSource

Arguments

:: (RandomGen g, HeukaryaGene d) 
=> g

RandomGenerator

-> Int

depth of tree structure

-> Text

String representation of output's Type

-> [d]

Ingredient(Gene) of Eukarya for constructing Eukarya

-> Tree d 

generate a tree structured Eukarya.

crossEukaryaSource

Arguments

:: (RandomGen g, HeukaryaGene d) 
=> g

RandomGenerator

-> Int

depth of tree structure. no functionality here

-> (Tree d, Tree d)

origin Eukarya pair

-> (Tree d, Tree d)

crossovered Eukarya pair

crossover two Eukarya

mutateEukaryaSource

Arguments

:: (RandomGen g, HeukaryaGene d) 
=> g

RandomGenerator

-> Int

depth of tree structure

-> [d]

Ingredient(Gene) of Eukarya for mutating Eukarya

-> Tree d

input Eukarya

-> Tree d

mutated Eukarya

mutate Eukarya

Interfaces or Gene implementation

class (NFData d, Show d) => HeukaryaGene d whereSource

Gene's interface use Text to represent types

Methods

evalTreeGene :: Tree d -> dSource

Transform a syntax tree to a expression

geneTypeRep :: d -> TextSource

Get Gene's Type representation

geneHTypes :: d -> [([Text], Text)]Source

Get every possible input type and output type

>>> geneHTypes $ toDyn "(+)" ((+)::Int -> Int -> Int)
[([],"Int -> Int -> Int"),(["Int"],"Int -> Int"),(["Int","Int"],"Int")]

outputHTreeType :: Tree d -> TextSource

get tree's actual output type.

instanceOf :: d -> Text -> Text -> BoolSource

the first parameter is just a typeclass indicator that makes which instance to use get whether the former type is the special case of latter type

equalType :: d -> Text -> Text -> BoolSource

the first parameter is just a typeclass indicator that makes which instance to use get whether two types are the same

directType :: d -> Text -> Text -> BoolSource

the first parameter is just a typeclass indicator that makes which instance to use get whether two types have direct relation.

generalizeType :: d -> Text -> Text -> Maybe TextSource

the first parameter is just a typeclass indicator that makes which instance to use return a generalized one if they have direct relation.