add push arguments, more fun to come

This commit is contained in:
Rowan Torbitzky-Lane 2025-02-14 20:02:38 -06:00
parent 054d321102
commit feddc3cbfe
3 changed files with 138 additions and 2 deletions

View File

@ -58,6 +58,7 @@ library
, HushGP.PushTests.IntTests , HushGP.PushTests.IntTests
, HushGP.PushTests.GenericTests , HushGP.PushTests.GenericTests
, HushGP.PushTests.UtilTests , HushGP.PushTests.UtilTests
, HushGP.GP.PushArgs
, HushGP.TH , HushGP.TH
, HushGP.Utility , HushGP.Utility
, HushGP.Genome , HushGP.Genome

View File

@ -21,15 +21,19 @@
## PushGP TODO ## PushGP TODO
- [X] Implement a Plushy genome translator - [X] Implement a Plushy genome translator
- [ ] Implement silent and skip markers as well - [X] Implement ~~silent and~~ skip marker(s) as well
~~[ ] Have close amt of 1,2, and 3~~ ~~[ ] Have close amt of 1,2, and 3~~
- [X] Need a random genome generator - [X] Need a random genome generator
- I'm only going to implement propeller's :specified version - I'm only going to implement propeller's :specified version
- Is the best according to the papers - Is the best according to the papers
- [ ] Need a NoOp that opens blocks - [X] Need a NoOp that opens blocks
- [ ] Need to make genomes serializable (Check pysh json files) - [ ] Need to make genomes serializable (Check pysh json files)
- [ ] Add Memory - [ ] Add Memory
- [ ] Add history stack(s), like a call stack - [ ] Add history stack(s), like a call stack
- [ ] Implement interpreter options (could probably just place this into a map) - [ ] Implement interpreter options (could probably just place this into a map)
- Should probably place this in a separate file - Should probably place this in a separate file
- [ ] Implement different forms of downsampling
- [ ] 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
- [ ] Implement random simplification of genomes
- [ ] Find a way to multi-thread this

131
src/HushGP/GP/PushArgs.hs Normal file
View File

@ -0,0 +1,131 @@
module HushGP.GP.PushArgs where
import HushGP.State
import Data.Map qualified as Map
import HushGP.Instructions
data PushArgs = PushArgs
{
-- | For alternation, std deviation fo index when alternating.
alignmentDeviation :: Int,
-- | For alternation, probability of switching parents at each location.
alternationRate :: Float,
-- | For bmx, rate genes are exchanged.
bmxExchangeRate :: Float,
-- | For bmx, max length of a gene.
bmxGeneLengthLimit :: Int,
-- | For bmx, mutation rate for gaps.
bmxGapChangeProbability :: Float,
-- | For bmx, whether mates selected using reverse case sequences of first parent
bmxIsComplementary :: Bool,
-- | For bmx, don't exchange distance if greater than this
bmxMaxDistance :: Int,
-- | For bmx, only allow exchanges between individual with same number of genes.
bmxSameGeneCount :: Bool,
-- | For bmx, swap segment with same sequence index, not by best match
ssxNotBmx :: Bool,
-- | Ways to construct a phenotype from a plushy genome, so far only "specified" is implemented. Unused (for now).
closes :: String,
-- | Custom report for each generation if provided.
customReport :: Maybe (PushArgs -> IO ()),
-- | If True, keeps running regardless of success.
dontEnd :: Bool,
-- | Whether of not to use downsampling.
enableDownsampling :: Bool,
-- | The downsample function to use. "caseRand", "caseMaxim", "caseMaximAuto".
downsampleFunction :: String,
-- | Proportion of data used in downsample.
downsampleRate :: Float,
-- | Proportion of parents used to evaluate case distances.
downsampleParentRate :: Float,
-- | Amount of generations between parent distance computation
downsampleParentsGens :: Int,
-- | Whether or not to add the best individual to the next generation.
elitism :: Bool,
-- User must provide their own error function. TODO: This
-- errorFunction :: (PushArgs -> )
-- | Type of informed downsampling. "solved", "elite", "soft".
informedDownsamplingType :: String,
-- | List of instructions to use in the evolutionary run.
instructionList :: [Gene],
-- | For motely batch lexicase selection, max size of a batch of cases.
maxMotelyBatchSize :: Int,
-- | Max size of plushy genomes in a population.
maxInitialPlushySize :: Int,
-- | Maximum amount of generations allowed in an evolutionary run.
maxGenerations :: Int,
-- | Type of parent selection to use. Think "lexicase" and "tournament" for now.
parentSelectionAlgo :: String,
-- |Size of the population in the evolutionary run.
populationSize :: Int,
-- | For uniform replacement, rate of item replacement.
replacementRate :: Float,
-- | Whether or not to auto simplify solutions.
useSimplification :: Bool,
-- | When auto simplifying, max amt items deleted in a single step.
simplificationMaxAmt :: Int,
-- | When auto simplifying, number of simplification steps.
simplificationSteps :: Int,
-- | When auto simplifying, whether to print verbose information.
simplificationVerbose :: Bool,
-- | Whether to use mutli-threading.
useMultiThreading :: Bool,
-- | Max total error for solutions.
solutionErrorThreshold :: Int,
-- | Limit of push interpreter steps in push program evaluation.
stepLimit :: Int,
-- | For tournament selection, amount of individuals in each tournament.
tournamentSize :: Int,
-- Training data for the gp, must be provided.
-- trainingData :: something
-- Testing data for the gp, must be provided if there is any.
-- testingData :: something
-- | Addition rate for UMAD (deletion rate derived from this).
umadRate :: Float,
-- | Genetic operators and probabilities for their use, should sum to one
-- Takes a Map of String -> Float where the string is the genetic operator
variation :: Map.Map String Float
}
defaultPushArgs :: PushArgs
defaultPushArgs = PushArgs {
alignmentDeviation = 2,
alternationRate = 0.1,
bmxExchangeRate = 0.5,
bmxGeneLengthLimit = 10,
bmxGapChangeProbability = 0.001,
bmxIsComplementary = False,
bmxMaxDistance = 1000000,
bmxSameGeneCount = False,
closes = "specified",
customReport = Nothing,
dontEnd = False,
enableDownsampling = True,
downsampleFunction = "caseMaxim",
downsampleRate = 0.05,
downsampleParentRate = 0.01,
downsampleParentsGens = 10,
elitism = False,
-- errorFunction = something,
informedDownsamplingType = "solved",
instructionList = allInstructions,
maxMotelyBatchSize = 10,
maxInitialPlushySize = 100,
maxGenerations = 1000,
parentSelectionAlgo = "lexicase",
populationSize = 1000,
replacementRate = 0.1,
useSimplification = True,
simplificationMaxAmt = 4,
simplificationSteps = 1000,
simplificationVerbose = False,
useMultiThreading = False, -- False for now, change to True later.
solutionErrorThreshold = 0,
ssxNotBmx = False,
stepLimit = 1000,
tournamentSize = 5,
-- testingData = [],
-- trainingData = [],
umadRate = 0.1,
variation = Map.fromList [("umad", 1.0)]
}