Compare commits
3 Commits
164286d59a
...
7abac5e995
Author | SHA1 | Date | |
---|---|---|---|
7abac5e995 | |||
adff19b765 | |||
3cae011dfe |
7
TODO.md
7
TODO.md
@ -5,8 +5,8 @@
|
|||||||
- [X] Make all vector functions applicable to string functions and vice versa
|
- [X] Make all vector functions applicable to string functions and vice versa
|
||||||
- [X] Implement all functions as seen in propeller
|
- [X] Implement all functions as seen in propeller
|
||||||
- [X] Implement all functions as seen in the specification
|
- [X] Implement all functions as seen in the specification
|
||||||
- [ ] Implement Linear Algebra functions as specified in the previous papers
|
- [X] Implement Linear Algebra functions as specified in the previous papers
|
||||||
- [ ] These are in a separate branch, just need merging now
|
- [X] These are in a separate branch, just need merging now
|
||||||
- [X] Add a function to sort a vector forward and backwards
|
- [X] Add a function to sort a vector forward and backwards
|
||||||
- [X] Disambiguate isEmpty and stackIsEmpty
|
- [X] Disambiguate isEmpty and stackIsEmpty
|
||||||
- [X] Rename Logical to Bool
|
- [X] Rename Logical to Bool
|
||||||
@ -19,7 +19,7 @@
|
|||||||
- [X] Move utility functions to their own file
|
- [X] Move utility functions to their own file
|
||||||
- [ ] Make add/sub/mult/div/mod instructions generic
|
- [ ] Make add/sub/mult/div/mod instructions generic
|
||||||
- [ ] Use template haskell to (mostly) generate functions from generic ones (Split files based on the arity of their functions)
|
- [ ] Use template haskell to (mostly) generate functions from generic ones (Split files based on the arity of their functions)
|
||||||
- [ ] Add more special functions like sqrt, pow
|
- [X] Add more special functions like sqrt, pow
|
||||||
|
|
||||||
## PushGP TODO
|
## PushGP TODO
|
||||||
- [X] Implement a Plushy genome translator
|
- [X] Implement a Plushy genome translator
|
||||||
@ -36,6 +36,7 @@
|
|||||||
- [ ] Add history stack(s), like a call stack
|
- [ ] Add history stack(s), like a call stack
|
||||||
- [ ] Implement interpreter options (PushArgs would work well)
|
- [ ] Implement interpreter options (PushArgs would work well)
|
||||||
- Should probably place this in a separate file
|
- Should probably place this in a separate file
|
||||||
|
- [ ] Implement Novelty Lexicase selection
|
||||||
- [X] Implement different forms of downsampling
|
- [X] Implement different forms of downsampling
|
||||||
- [ ] Implement concurrent execution of creating random plushies and evaluating individuals
|
- [ ] Implement concurrent execution of creating random plushies and evaluating individuals
|
||||||
- [X] Devise a good way to implement ERCs
|
- [X] Devise a good way to implement ERCs
|
||||||
|
@ -164,6 +164,10 @@ instructionFloatShove = instructionShove float
|
|||||||
instructionFloatIsStackEmpty :: State -> State
|
instructionFloatIsStackEmpty :: State -> State
|
||||||
instructionFloatIsStackEmpty = instructionIsStackEmpty float
|
instructionFloatIsStackEmpty = instructionIsStackEmpty float
|
||||||
|
|
||||||
|
-- |Duplicate the top N items from the float stack based on the top int from the int stack.
|
||||||
|
instructionFloatDupItems :: State -> State
|
||||||
|
instructionFloatDupItems = instructionDupItems float
|
||||||
|
|
||||||
-- |Pushes the sin of the top float to the float stack.
|
-- |Pushes the sin of the top float to the float stack.
|
||||||
instructionFloatSin :: State -> State
|
instructionFloatSin :: State -> State
|
||||||
instructionFloatSin state@(State {_float = f1 : fs}) = state {_float = sin f1 : fs}
|
instructionFloatSin state@(State {_float = f1 : fs}) = state {_float = sin f1 : fs}
|
||||||
@ -179,9 +183,40 @@ instructionFloatTan :: State -> State
|
|||||||
instructionFloatTan state@(State {_float = f1 : fs}) = state {_float = tan f1 : fs}
|
instructionFloatTan state@(State {_float = f1 : fs}) = state {_float = tan f1 : fs}
|
||||||
instructionFloatTan state = state
|
instructionFloatTan state = state
|
||||||
|
|
||||||
-- |Duplicate the top N items from the float stack based on the top int from the int stack.
|
-- |Pushes the absolute value of the top float to the float stack.
|
||||||
instructionFloatDupItems :: State -> State
|
instructionFloatAbs :: State -> State
|
||||||
instructionFloatDupItems = instructionDupItems float
|
instructionFloatAbs state@(State {_float = f1 : fs}) = state {_float = abs f1 : fs}
|
||||||
|
instructionFloatAbs state = state
|
||||||
|
|
||||||
|
-- |Pushes the exponential of the top float to the float stack.
|
||||||
|
instructionFloatExp :: State -> State
|
||||||
|
instructionFloatExp state@(State {_float = f1 : fs}) = state {_float = exp f1 : fs}
|
||||||
|
instructionFloatExp state = state
|
||||||
|
|
||||||
|
-- |Pushes the log of the top float to the float stack.
|
||||||
|
instructionFloatLog :: State -> State
|
||||||
|
instructionFloatLog state@(State {_float = f1 : fs}) = state {_float = log f1 : fs}
|
||||||
|
instructionFloatLog state = state
|
||||||
|
|
||||||
|
-- |Pushes the squared value of the top float to the float stack.
|
||||||
|
instructionFloatSquare :: State -> State
|
||||||
|
instructionFloatSquare state@(State {_float = f1 : fs}) = state {_float = f1 ^ (2 :: Int) : fs}
|
||||||
|
instructionFloatSquare state = state
|
||||||
|
|
||||||
|
-- |Pushes the cubed value of the top float to the float stack.
|
||||||
|
instructionFloatCube :: State -> State
|
||||||
|
instructionFloatCube state@(State {_float = f1 : fs}) = state {_float = f1 ^ (3 :: Int) : fs}
|
||||||
|
instructionFloatCube state = state
|
||||||
|
|
||||||
|
-- |Pushes the square rooted value of the top float to the float stack.
|
||||||
|
instructionFloatSqrt :: State -> State
|
||||||
|
instructionFloatSqrt state@(State {_float = f1 : fs}) = state {_float = sqrt f1 : fs}
|
||||||
|
instructionFloatSqrt state = state
|
||||||
|
|
||||||
|
-- |Pushes the top float with its sign reversed to the top of the float stack.
|
||||||
|
instructionFloatReverseSign :: State -> State
|
||||||
|
instructionFloatReverseSign state@(State {_float = f1 : fs}) = state {_float = (-1) * f1 : fs}
|
||||||
|
instructionFloatReverseSign state = state
|
||||||
|
|
||||||
allFloatInstructions :: [Gene]
|
allFloatInstructions :: [Gene]
|
||||||
allFloatInstructions = map StateFunc ($(functionExtractor "instruction"))
|
allFloatInstructions = map StateFunc ($(functionExtractor "instruction"))
|
||||||
|
@ -168,5 +168,55 @@ instructionIntIsStackEmpty = instructionIsStackEmpty int
|
|||||||
instructionIntDupItems :: State -> State
|
instructionIntDupItems :: State -> State
|
||||||
instructionIntDupItems = instructionDupItems int
|
instructionIntDupItems = instructionDupItems int
|
||||||
|
|
||||||
|
-- |Pushes the sin of the top int to the int stack. Rounding if needed.
|
||||||
|
instructionIntSin :: State -> State
|
||||||
|
instructionIntSin state@(State {_int = i1 : is}) = state {_int = round (sin (fromIntegral @Integer @Double i1)) : is}
|
||||||
|
instructionIntSin state = state
|
||||||
|
|
||||||
|
-- |Pushes the cos of the top int to the int stack. Rounding if needed.
|
||||||
|
instructionIntCos :: State -> State
|
||||||
|
instructionIntCos state@(State {_int = i1 : is}) = state {_int = round (cos (fromIntegral @Integer @Double i1)) : is}
|
||||||
|
instructionIntCos state = state
|
||||||
|
|
||||||
|
-- |Pushes the tan of the top int to the int stack. Rounding if needed.
|
||||||
|
instructionIntTan :: State -> State
|
||||||
|
instructionIntTan state@(State {_int = i1 : is}) = state {_int = round (tan (fromIntegral @Integer @Double i1)) : is}
|
||||||
|
instructionIntTan state = state
|
||||||
|
|
||||||
|
-- |Pushes the absolute value of the top int to the int stack.
|
||||||
|
instructionIntAbs :: State -> State
|
||||||
|
instructionIntAbs state@(State {_int = i1 : is}) = state {_int = abs i1 : is}
|
||||||
|
instructionIntAbs state = state
|
||||||
|
|
||||||
|
-- |Pushes the exponential of the top int to the int stack. Rounding if needed.
|
||||||
|
instructionIntExp :: State -> State
|
||||||
|
instructionIntExp state@(State {_int = i1 : is}) = state {_int = round (exp (fromIntegral @Integer @Double i1)) : is}
|
||||||
|
instructionIntExp state = state
|
||||||
|
|
||||||
|
-- |Pushes the log of the top int to the int stack. Rounding if needed.
|
||||||
|
instructionIntLog :: State -> State
|
||||||
|
instructionIntLog state@(State {_int = i1 : is}) = state {_int = round (log (fromIntegral @Integer @Double i1)) : is}
|
||||||
|
instructionIntLog state = state
|
||||||
|
|
||||||
|
-- |Pushes the squared value of the top int to the int stack.
|
||||||
|
instructionIntSquare :: State -> State
|
||||||
|
instructionIntSquare state@(State {_int = i1 : is}) = state {_int = i1 ^ (2 :: Int) : is}
|
||||||
|
instructionIntSquare state = state
|
||||||
|
|
||||||
|
-- |Pushes the cubed value of the top int to the int stack.
|
||||||
|
instructionIntCube :: State -> State
|
||||||
|
instructionIntCube state@(State {_int = i1 : is}) = state {_int = i1 ^ (3 :: Int) : is}
|
||||||
|
instructionIntCube state = state
|
||||||
|
|
||||||
|
-- |Pushes the square rooted value of the top int to the int stack. Rounding if needed.
|
||||||
|
instructionIntSqrt :: State -> State
|
||||||
|
instructionIntSqrt state@(State {_int = i1 : is}) = state {_int = round (sqrt (fromIntegral @Integer @Double i1)) : is}
|
||||||
|
instructionIntSqrt state = state
|
||||||
|
|
||||||
|
-- |Pushes the top int with its sign reversed to the top of the int stack.
|
||||||
|
instructionIntReverseSign :: State -> State
|
||||||
|
instructionIntReverseSign state@(State {_int = i1 : is}) = state {_int = (-1) * i1 : is}
|
||||||
|
instructionIntReverseSign state = state
|
||||||
|
|
||||||
allIntInstructions :: [Gene]
|
allIntInstructions :: [Gene]
|
||||||
allIntInstructions = map StateFunc ($(functionExtractor "instruction"))
|
allIntInstructions = map StateFunc ($(functionExtractor "instruction"))
|
||||||
|
@ -335,7 +335,7 @@ instructionVectorFloatInsertVectorFloat = instructionVectorInsertVector vectorFl
|
|||||||
-- |Takes the mean of the top float vector and pushes the rounded float value
|
-- |Takes the mean of the top float vector and pushes the rounded float value
|
||||||
-- to the float stack.
|
-- to the float stack.
|
||||||
instructionVectorFloatMean :: State -> State
|
instructionVectorFloatMean :: State -> State
|
||||||
instructionVectorFloatMean state@(State {_vectorFloat = [] : vs}) = instructionVectorFuncVectorToPrim float vectorFloat retZero state
|
instructionVectorFloatMean state@(State {_vectorFloat = [] : _}) = instructionVectorFuncVectorToPrim float vectorFloat retZero state
|
||||||
instructionVectorFloatMean state = instructionVectorFuncVectorToPrim float vectorFloat (\xs -> sum xs / fromIntegral @Int @Double (length xs)) state
|
instructionVectorFloatMean state = instructionVectorFuncVectorToPrim float vectorFloat (\xs -> sum xs / fromIntegral @Int @Double (length xs)) state
|
||||||
|
|
||||||
-- |Takes the maximum of the top float vector and pushes the float value
|
-- |Takes the maximum of the top float vector and pushes the float value
|
||||||
@ -413,11 +413,11 @@ instructionVectorFloatAbs = instructionVectorFuncVectorToVector vectorFloat (map
|
|||||||
|
|
||||||
-- |Applies the square function to all indices in an float vector, rounds the result as it moves along.
|
-- |Applies the square function to all indices in an float vector, rounds the result as it moves along.
|
||||||
instructionVectorFloatSquare :: State -> State
|
instructionVectorFloatSquare :: State -> State
|
||||||
instructionVectorFloatSquare = instructionVectorFuncVectorToVector vectorFloat (map (^ 2))
|
instructionVectorFloatSquare = instructionVectorFuncVectorToVector vectorFloat (map (^ (2 :: Int)))
|
||||||
|
|
||||||
-- |Applies the cube function to all indices in an float vector, rounds the result as it moves along.
|
-- |Applies the cube function to all indices in an float vector, rounds the result as it moves along.
|
||||||
instructionVectorFloatCube :: State -> State
|
instructionVectorFloatCube :: State -> State
|
||||||
instructionVectorFloatCube = instructionVectorFuncVectorToVector vectorFloat (map (^ 3))
|
instructionVectorFloatCube = instructionVectorFuncVectorToVector vectorFloat (map (^ (3 :: Int)))
|
||||||
|
|
||||||
-- |Applies the sqrt function to all indices in an float vector, rounds the result as it moves along.
|
-- |Applies the sqrt function to all indices in an float vector, rounds the result as it moves along.
|
||||||
instructionVectorFloatSqrt :: State -> State
|
instructionVectorFloatSqrt :: State -> State
|
||||||
|
@ -335,7 +335,7 @@ instructionVectorIntInsertVectorInt = instructionVectorInsertVector vectorInt
|
|||||||
-- |Takes the mean of the top int vector and pushes the rounded int value
|
-- |Takes the mean of the top int vector and pushes the rounded int value
|
||||||
-- to the int stack.
|
-- to the int stack.
|
||||||
instructionVectorIntMean :: State -> State
|
instructionVectorIntMean :: State -> State
|
||||||
instructionVectorIntMean state@(State {_vectorInt = [] : vs}) = instructionVectorFuncVectorToPrim int vectorInt retZero state
|
instructionVectorIntMean state@(State {_vectorInt = [] : _}) = instructionVectorFuncVectorToPrim int vectorInt retZero state
|
||||||
instructionVectorIntMean state = instructionVectorFuncVectorToPrim int vectorInt (\xs -> round $ sum (map (fromIntegral @Integer @Double) xs) / fromIntegral @Int @Double (length xs)) state
|
instructionVectorIntMean state = instructionVectorFuncVectorToPrim int vectorInt (\xs -> round $ sum (map (fromIntegral @Integer @Double) xs) / fromIntegral @Int @Double (length xs)) state
|
||||||
|
|
||||||
-- |Takes the maximum of the top int vector and pushes the int value
|
-- |Takes the maximum of the top int vector and pushes the int value
|
||||||
@ -413,11 +413,11 @@ instructionVectorIntAbs = instructionVectorFuncVectorToVector vectorInt (map (ro
|
|||||||
|
|
||||||
-- |Applies the square function to all indices in an int vector, rounds the result as it moves along.
|
-- |Applies the square function to all indices in an int vector, rounds the result as it moves along.
|
||||||
instructionVectorIntSquare :: State -> State
|
instructionVectorIntSquare :: State -> State
|
||||||
instructionVectorIntSquare = instructionVectorFuncVectorToVector vectorInt (map (round . (^ 2) . fromIntegral @Integer @Double))
|
instructionVectorIntSquare = instructionVectorFuncVectorToVector vectorInt (map (round . (^ (2 :: Int)) . fromIntegral @Integer @Double))
|
||||||
|
|
||||||
-- |Applies the cube function to all indices in an int vector, rounds the result as it moves along.
|
-- |Applies the cube function to all indices in an int vector, rounds the result as it moves along.
|
||||||
instructionVectorIntCube :: State -> State
|
instructionVectorIntCube :: State -> State
|
||||||
instructionVectorIntCube = instructionVectorFuncVectorToVector vectorInt (map (round . (^ 3) . fromIntegral @Integer @Double))
|
instructionVectorIntCube = instructionVectorFuncVectorToVector vectorInt (map (round . (^ (3 :: Int)) . fromIntegral @Integer @Double))
|
||||||
|
|
||||||
-- |Applies the sqrt function to all indices in an int vector, rounds the result as it moves along.
|
-- |Applies the sqrt function to all indices in an int vector, rounds the result as it moves along.
|
||||||
instructionVectorIntSqrt :: State -> State
|
instructionVectorIntSqrt :: State -> State
|
||||||
|
Loading…
x
Reference in New Issue
Block a user