From 27b29f84498ea92e95d815ba805cdcae9370ad69 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Sat, 1 Mar 2025 16:23:19 -0600 Subject: [PATCH] formatting --- src/HushGP/GP.hs | 9 ++++++--- src/HushGP/Genome.hs | 6 +++--- src/HushGP/Utility.hs | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/HushGP/GP.hs b/src/HushGP/GP.hs index 009c14d..9166d92 100644 --- a/src/HushGP/GP.hs +++ b/src/HushGP/GP.hs @@ -46,9 +46,12 @@ gpLoop' pushArgs generation evaluations population indexedTrainingData = do print "Put information about each generation here." when bestIndPassesDownsample $ print $ "Semi Success Generation: " <> show generation let nextAction - | (bestIndPassesDownsample && - ((case totalFitness (updateIndividual (errorFunction epsilonPushArgs epsilonPushArgs indexedTrainingData (plushy bestInd)) bestInd) of (Just x) -> x; _ -> error "Error: Best downsample individual has no fitness!") - <= solutionErrorThreshold epsilonPushArgs)) || (not (enableDownsampling epsilonPushArgs) && ((case totalFitness bestInd of (Just x) -> x; _ -> error "error: Best non-downsample individual has no fitness!") <= solutionErrorThreshold epsilonPushArgs)) = + | ( bestIndPassesDownsample + && ( (case totalFitness (updateIndividual (errorFunction epsilonPushArgs epsilonPushArgs indexedTrainingData (plushy bestInd)) bestInd) of (Just x) -> x; _ -> error "Error: Best downsample individual has no fitness!") + <= solutionErrorThreshold epsilonPushArgs + ) + ) + || (not (enableDownsampling epsilonPushArgs) && ((case totalFitness bestInd of (Just x) -> x; _ -> error "error: Best non-downsample individual has no fitness!") <= solutionErrorThreshold epsilonPushArgs)) = do print $ "Successful generation: " <> show generation print $ "Successful plushy: " <> show (plushy bestInd) diff --git a/src/HushGP/Genome.hs b/src/HushGP/Genome.hs index a768773..b648442 100644 --- a/src/HushGP/Genome.hs +++ b/src/HushGP/Genome.hs @@ -23,10 +23,10 @@ data Individual = Individual instance Ord Individual where ind0 <= ind1 = totalFitness ind0 <= totalFitness ind1 --- |Extracts the fitnessCases from an Individual. Errors if the field is empty. +-- | Extracts the fitnessCases from an Individual. Errors if the field is empty. extractFitnessCases :: Individual -> [Double] -extractFitnessCases Individual{fitnessCases = Nothing} = error "Error: fitnessCases is empty!" -extractFitnessCases Individual{fitnessCases = Just xs} = xs +extractFitnessCases Individual {fitnessCases = Nothing} = error "Error: fitnessCases is empty!" +extractFitnessCases Individual {fitnessCases = Just xs} = xs -- | Makes a random individual based on the variables in a passed PushArgs. makeRandomIndividual :: PushArgs -> IO Individual diff --git a/src/HushGP/Utility.hs b/src/HushGP/Utility.hs index 560bb9e..db2ebe5 100644 --- a/src/HushGP/Utility.hs +++ b/src/HushGP/Utility.hs @@ -22,4 +22,4 @@ mapIndexed = mapIndexed' 0 -- with mapIndexed. mapIndexed' :: Int -> (Int -> a -> b) -> [a] -> [b] mapIndexed' _ _ [] = [] -mapIndexed' count f (x:xs) = f count x : mapIndexed' (count + 1) f xs +mapIndexed' count f (x : xs) = f count x : mapIndexed' (count + 1) f xs