From 70fd7143405d356939e903c11e1d04762aa7cbad Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Sat, 1 Mar 2025 16:31:20 -0600 Subject: [PATCH] bestIndPassesDownsample done --- src/HushGP/GP.hs | 4 ++-- src/HushGP/Genome.hs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/HushGP/GP.hs b/src/HushGP/GP.hs index 9166d92..942310d 100644 --- a/src/HushGP/GP.hs +++ b/src/HushGP/GP.hs @@ -42,7 +42,7 @@ gpLoop pushArgs@(PushArgs {trainingData = tData}) = do -- holds the evaluation count. The list of Individuals is the population. The last parameter is -- the training data (possibly downsampled). gpLoop' :: PushArgs -> Int -> Int -> [Individual] -> [PushData] -> IO () -gpLoop' pushArgs generation evaluations population indexedTrainingData = do +gpLoop' pushArgs@(PushArgs {enableDownsampling = enableDS, solutionErrorThreshold = seThresh}) generation evaluations population indexedTrainingData = do print "Put information about each generation here." when bestIndPassesDownsample $ print $ "Semi Success Generation: " <> show generation let nextAction @@ -95,6 +95,6 @@ gpLoop' pushArgs generation evaluations population indexedTrainingData = do bestInd :: Individual bestInd = case uncons evaledPop of Just (x, _) -> x; _ -> error "Error: Population is empty!" bestIndPassesDownsample :: Bool - bestIndPassesDownsample = False -- TODO: fix this later + bestIndPassesDownsample = enableDS && (extractTotalFitness bestInd <= seThresh) epsilonPushArgs :: PushArgs epsilonPushArgs = pushArgs {epsilons = Nothing} -- TODO: And this diff --git a/src/HushGP/Genome.hs b/src/HushGP/Genome.hs index b648442..a1ff9f6 100644 --- a/src/HushGP/Genome.hs +++ b/src/HushGP/Genome.hs @@ -28,6 +28,10 @@ extractFitnessCases :: Individual -> [Double] extractFitnessCases Individual {fitnessCases = Nothing} = error "Error: fitnessCases is empty!" extractFitnessCases Individual {fitnessCases = Just xs} = xs +extractTotalFitness :: Individual -> Double +extractTotalFitness Individual {totalFitness = Nothing} = error "Error: totalFitness is empty!" +extractTotalFitness Individual {totalFitness = Just x} = x + -- | Makes a random individual based on the variables in a passed PushArgs. makeRandomIndividual :: PushArgs -> IO Individual makeRandomIndividual pushArgs = do