Copyright(c) Fabricio Olivetti de Franca 2020
LicenseGPL-3
Maintainerfabricio.olivetti@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone

IT.ITEA

Description

Generic implementation of Interaction-Transformation Evolutionary Algorithm for any instance of IT expression.

To run itea you just need to call 'itea mutFun pop0', where mutFun is a mutation function of the type Mutation, a fitness function of type Fitness, and pop0 is the initial Population of solutions. This function will result in an infinite list of populations, with the i-th element being the population of the i-th generation.

This library also provides some generic mutation function builders.

Synopsis

ITEA

itea :: Mutation -> Fitness -> Population -> Rnd [Population] Source #

Creates a stream of generations the i-th element corresponds to the population of the i-th generation.

initialPop Source #

Arguments

:: Int

maxTerms

-> Int

nPop

-> Rnd Term

random term generator

-> Fitness

fitness function

-> Rnd Population 

Generate an Initial Population at Random

tournamentSeq :: Population -> Int -> Rnd Population Source #

Tournament Selection

given the concatenation of the previous population and the mutated children, it will return a sampled selection of these combined population with the same size as the original population.

tournament :: Population -> Int -> Rnd Population Source #

For small population, do not convert to Finger Tree to avoid overhead

step :: Mutation -> Fitness -> Int -> Population -> Rnd Population Source #

Perform one iteration of ITEA

stepPar :: Mutation -> Fitness -> Int -> Population -> Rnd Population Source #

EXPERIMENTAL: step function with parallel evaluation

Parallel random functions

parRndMap :: Int -> (Solution -> Rnd Expr) -> (Expr -> Maybe Solution) -> [Solution] -> Rnd [Solution] Source #

Runs in parallel the composition of a function that generates random effects with a function that maybe returns a result. parRndMap :: NFData c => Int -> (a -> Rnd b) -> (b -> Maybe c) -> [a] -> Rnd [c] parRndMap :: Int -> Mutation -> (Solution -> Maybe Expr) -> [Solution] -> Rnd [Solution]

numberOfSplits :: Int -> Int Source #

Calculates the number of splits as twice the number of cores

genNseeds :: Int -> StdGen -> [StdGen] Source #

Generates n random seeds.

genseeds :: StdGen -> [StdGen] Source #

Generates an infinite list of random seeds.

parMaybeMap :: Int -> ((StdGen, Solution) -> Maybe Solution) -> [(StdGen, Solution)] -> Population Source #

Runs a computation that may returns a result in parallel. parMaybeMap :: NFData b => Int -> (a -> Maybe b) -> [a] -> [b]