formatting

This commit is contained in:
Rowan Torbitzky-Lane 2025-03-01 16:23:19 -06:00
parent 690b4507b2
commit 27b29f8449
3 changed files with 10 additions and 7 deletions

@ -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)

@ -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

@ -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