Copyright | (c) Guilherme S I Aldeia 2018 Heitor R Savegnago 2018 |
---|---|
License | GPL-3 |
Maintainer | guilherme.aldeia@aluno.ufabc.edu.br heitor.rodrigues@aluno.ufabc.edu.br |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Module containing implementation of expression manipulation functions.
Synopsis
- newtype Score = Score Double
- newtype Coeff = Coeff Double
- newtype Exps = Exps [Int]
- newtype Op = Op Int
- newtype It = It (Coeff, Op, Exps)
- type Le = [It]
- type Pop = [Le]
- type Operator = Double -> Double
- type Op'n'Name = (Operator, String)
- type SimplifyT = Double
- type SupressionT = Int
- type PopSize = Int
- type LeSize = Int
- ops :: [Op'n'Name]
- operator :: Op'n'Name -> Operator
- nomeator :: Op'n'Name -> String
- linearExpression :: Int -> Le
- randomExps :: Int -> IO [Int]
- randomIt :: Int -> IO It
- randomExpression :: Int -> Int -> IO Le
- textRepresentation :: Le -> String
- uniques :: Le -> Le
- solve :: Le -> DataPoint -> [Double]
- adjust :: Le -> Dataset -> Le
- evaluate :: Le -> Dataset -> Score
- simplify :: Le -> SimplifyT -> Maybe Le
- mutateTrans :: Le -> IO Le
- mutateExps :: Exps -> IO Exps
- mutateInter :: Int -> Le -> IO Le
- simplifyPop :: Pop -> SimplifyT -> Pop
- sortByScore :: Pop -> Dataset -> Pop
- mutatePop :: Pop -> Int -> IO Pop
- rndPopulation :: PopSize -> LeSize -> Dataset -> IO Pop
- dummyDist :: It -> Int
- distExpr :: Le -> Le -> Int
- supress :: Pop -> SupressionT -> Dataset -> Pop
Documentation
Double ranging from [0,1] indicating the performance of the solution for a given dataset
Score Double |
Vector of expoents of ITs, to be applied to the samples on IT evaluation
Exps [Int] |
type SupressionT = Int #
Supression threshold
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 Opn
Name here.
operator :: Op'n'Name -> Operator #
Takes one Opn
Name tuple and returns the operator (first 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].
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.
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.
Takes one It and calculates the distance between the IT and a dummy it (internal use only).
Takes two LEs and return an integer representing the index of similarity.