ml

Copyright(c) Guilherme S I Aldeia 2018
Heitor R Savegnago 2018
LicenseGPL-3
Maintainerguilherme.aldeia@aluno.ufabc.edu.br heitor.rodrigues@aluno.ufabc.edu.br
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone

Manipulators

Description

Module containing implementation of expression manipulation functions.

Synopsis

Documentation

newtype Score #

Double ranging from [0,1] indicating the performance of the solution for a given dataset

Constructors

Score Double 
Instances
Eq Score # 
Instance details

Defined in Manipulators

Methods

(==) :: Score -> Score -> Bool

(/=) :: Score -> Score -> Bool

Ord Score # 
Instance details

Defined in Manipulators

Methods

compare :: Score -> Score -> Ordering

(<) :: Score -> Score -> Bool

(<=) :: Score -> Score -> Bool

(>) :: Score -> Score -> Bool

(>=) :: Score -> Score -> Bool

max :: Score -> Score -> Score

min :: Score -> Score -> Score

Show Score # 
Instance details

Defined in Manipulators

Methods

showsPrec :: Int -> Score -> ShowS

show :: Score -> String

showList :: [Score] -> ShowS

newtype Coeff #

Coefficient associated with the ITs

Constructors

Coeff Double 
Instances
Eq Coeff # 
Instance details

Defined in Manipulators

Methods

(==) :: Coeff -> Coeff -> Bool

(/=) :: Coeff -> Coeff -> Bool

Ord Coeff # 
Instance details

Defined in Manipulators

Methods

compare :: Coeff -> Coeff -> Ordering

(<) :: Coeff -> Coeff -> Bool

(<=) :: Coeff -> Coeff -> Bool

(>) :: Coeff -> Coeff -> Bool

(>=) :: Coeff -> Coeff -> Bool

max :: Coeff -> Coeff -> Coeff

min :: Coeff -> Coeff -> Coeff

Show Coeff # 
Instance details

Defined in Manipulators

Methods

showsPrec :: Int -> Coeff -> ShowS

show :: Coeff -> String

showList :: [Coeff] -> ShowS

newtype Exps #

Vector of expoents of ITs, to be applied to the samples on IT evaluation

Constructors

Exps [Int] 
Instances
Eq Exps # 
Instance details

Defined in Manipulators

Methods

(==) :: Exps -> Exps -> Bool

(/=) :: Exps -> Exps -> Bool

Ord Exps # 
Instance details

Defined in Manipulators

Methods

compare :: Exps -> Exps -> Ordering

(<) :: Exps -> Exps -> Bool

(<=) :: Exps -> Exps -> Bool

(>) :: Exps -> Exps -> Bool

(>=) :: Exps -> Exps -> Bool

max :: Exps -> Exps -> Exps

min :: Exps -> Exps -> Exps

Show Exps # 
Instance details

Defined in Manipulators

Methods

showsPrec :: Int -> Exps -> ShowS

show :: Exps -> String

showList :: [Exps] -> ShowS

newtype Op #

Index of the operator of the ITs

Constructors

Op Int 
Instances
Eq Op # 
Instance details

Defined in Manipulators

Methods

(==) :: Op -> Op -> Bool

(/=) :: Op -> Op -> Bool

Ord Op # 
Instance details

Defined in Manipulators

Methods

compare :: Op -> Op -> Ordering

(<) :: Op -> Op -> Bool

(<=) :: Op -> Op -> Bool

(>) :: Op -> Op -> Bool

(>=) :: Op -> Op -> Bool

max :: Op -> Op -> Op

min :: Op -> Op -> Op

Show Op # 
Instance details

Defined in Manipulators

Methods

showsPrec :: Int -> Op -> ShowS

show :: Op -> String

showList :: [Op] -> ShowS

newtype It #

IT data structure

Constructors

It (Coeff, Op, Exps) 
Instances
Eq It # 
Instance details

Defined in Manipulators

Methods

(==) :: It -> It -> Bool

(/=) :: It -> It -> Bool

Ord It # 
Instance details

Defined in Manipulators

Methods

compare :: It -> It -> Ordering

(<) :: It -> It -> Bool

(<=) :: It -> It -> Bool

(>) :: It -> It -> Bool

(>=) :: It -> It -> Bool

max :: It -> It -> It

min :: It -> It -> It

Show It # 
Instance details

Defined in Manipulators

Methods

showsPrec :: Int -> It -> ShowS

show :: It -> String

showList :: [It] -> ShowS

type Le = [It] #

Linear combination of ITs

type Pop = [Le] #

Vector containing many Les, called population

type Operator = Double -> Double #

One-argument functions, used to compose ITs

type Op'n'Name = (Operator, String) #

Tuple containing One operator and one string to print it

type SimplifyT = Double #

Simplification threshold

type SupressionT = Int #

Supression threshold

type PopSize = Int #

Size of the population

type LeSize = Int #

Size of the expressions

ops :: [Op'n'Name] #

set of operators used to create ITs. Each operator is a tuple containing a function (Double -> Double) and a string to print the name of the operation. To add new operators to the ITs, create a new tuple of type OpnName here.

operator :: Op'n'Name -> Operator #

Takes one OpnName tuple and returns the operator (first element).

nomeator :: Op'n'Name -> String #

Takes one OpnName tuple and returns the name (second element).

linearExpression :: Int -> Le #

Takes the number of variables n and returns an Le with n ITs, where each the linear combination of the ITs results in a linear combination of the n variables.

randomExps :: Int -> IO [Int] #

Takes the number of variables n and return n random expoents ranging from [0,7].

randomIt :: Int -> IO It #

Takes the number of variables n and return an random IT.

randomExpression :: Int -> Int -> IO Le #

Takes the number of ITs m and the number of variables n and returns a random LE of m its, each IT having n variables.

textRepresentation :: Le -> String #

Takes one LE and returns a friendly printable expression to get a better representation when printing out the expression.

uniques :: Le -> Le #

Takes one LE and returns this LE without duplicated elements. Matrix propriety: given a matrix A, if two lines are identical, then the determinant of A is zero and, consequently, A is not inversible. Since the coefficient adjustment is done using OLS, it's important to avoid non-inversible matrices.

solve :: Le -> DataPoint -> [Double] #

Takes one LE and one DataPoint and returns the expression evaluated to the given DataPoint.

adjust :: Le -> Dataset -> Le #

Takes one LE and one Dataset and ajust the LE coefficients using Ordinary Least Squares, then returns the adjusted LE. NOTE: adjusting an expression twice results in the expression with all coefficients equal to 1.

evaluate :: Le -> Dataset -> Score #

Takes one LE and one Dataset and returns the SCORE of the LE for the given dataset.

simplify :: Le -> SimplifyT -> Maybe Le #

Takes one LE and the Simplification Threshold and returns an expression without ITs with coefficient below threshold. If all ITs have low coefficients, then returns the LE without removing any IT.

mutateTrans :: Le -> IO Le #

Takes one LE and applies the transformation mutation on it. The transformation mutation changes the operator. Returns a mutated LE.

mutateExps :: Exps -> IO Exps #

Takes one Exps vector and iterate through with a small chance of changing some expoents randomly.

mutateInter :: Int -> Le -> IO Le #

Takes the number of variables n and one LE and applies the interaction mutation on it. The interaction mutation changes one expoent of one random IT. returns a mutated LE.

simplifyPop :: Pop -> SimplifyT -> Pop #

Takes one Population and the simplification Threshold and calls the simplify for every solution.

sortByScore :: Pop -> Dataset -> Pop #

Takes one population and an dataset and returns the population sorted by their score. It's important that the given population is adjusted.

mutatePop :: Pop -> Int -> IO Pop #

Takes one Population and the number of variables and calls the mutation method in all expressions. returns a mutated population.

rndPopulation :: PopSize -> LeSize -> Dataset -> IO Pop #

Takes the size of the population, the size of the expressions and a dataset used to train the population. Then returns a random population.

dummyDist :: It -> Int #

Takes one It and calculates the distance between the IT and a dummy it (internal use only).

distExpr :: Le -> Le -> Int #

Takes two LEs and return an integer representing the index of similarity.

supress :: Pop -> SupressionT -> Dataset -> Pop #

Takes an population, a supression threshold and a dataset and searchs for nearly identical solutions. Then, keeps the best of them and discarts the remaining.