Compare commits

..

3 Commits

Author SHA1 Message Date
2d9840c51b skeleton done 2025-02-25 18:53:52 -06:00
5012cb2ce1 GP skeleton almost done 2025-02-25 18:48:05 -06:00
2f6675e9f5 add downsample 2025-02-25 18:47:50 -06:00
3 changed files with 12 additions and 1 deletions

View File

@ -63,6 +63,7 @@ library
, HushGP.GP , HushGP.GP
, HushGP.GP.PushArgs , HushGP.GP.PushArgs
, HushGP.GP.Variation , HushGP.GP.Variation
, HushGP.GP.Downsample
, HushGP.Problems.IntegerRegression , HushGP.Problems.IntegerRegression

View File

@ -7,6 +7,8 @@ import Data.List (sort, uncons)
import HushGP.GP.PushArgs import HushGP.GP.PushArgs
import HushGP.Genome import HushGP.Genome
import HushGP.State import HushGP.State
import HushGP.GP.Variation
import HushGP.GP.Downsample
-- import Debug.Trace (trace, traceStack) -- import Debug.Trace (trace, traceStack)
@ -58,7 +60,8 @@ gpLoop' pushArgs generation evaluations population indexedTrainingData = do
print "Incomplete Run, saving the best so far." print "Incomplete Run, saving the best so far."
| otherwise = gpLoop' pushArgs (succ generation) | otherwise = gpLoop' pushArgs (succ generation)
(evaluations + (populationSize pushArgs * length (fst $ trainingData pushArgs)) + (if generation `mod` downsampleParentsGens pushArgs == 0 then length parentReps * (length (fst indexedTrainingData) - length (fst $ trainingData pushArgs)) else 0) + (if bestIndPassesDownsample then length (fst indexedTrainingData) - length (fst $ trainingData pushArgs) else 0)) (evaluations + (populationSize pushArgs * length (fst $ trainingData pushArgs)) + (if generation `mod` downsampleParentsGens pushArgs == 0 then length parentReps * (length (fst indexedTrainingData) - length (fst $ trainingData pushArgs)) else 0) + (if bestIndPassesDownsample then length (fst indexedTrainingData) - length (fst $ trainingData pushArgs) else 0))
(if elitism then bestInd : ) (if elitism pushArgs then bestInd : replicate (populationSize epsilonPushArgs - 1) (newIndividual epsilonPushArgs evaledPop) else replicate (populationSize epsilonPushArgs) (newIndividual epsilonPushArgs evaledPop))
(if enableDownsampling pushArgs && ((generation `mod` downsampleParentsGens pushArgs) == 0) then updateCaseDistances repEvaluatedPop indexedTrainingData indexedTrainingData (informedDownsamplingType pushArgs) (solutionErrorThreshold pushArgs / fromIntegral @Int @Double (length $ fst indexedTrainingData)) else indexedTrainingData)
nextAction nextAction
where where
-- \| This will have downsampling added to it later. -- \| This will have downsampling added to it later.

View File

@ -0,0 +1,7 @@
module HushGP.GP.Downsample where
import HushGP.State
import HushGP.Genome
updateCaseDistances :: [Individual] -> ([[Gene]], [Gene]) -> ([[Gene]], [Gene]) -> String -> Double -> ([[Gene]], [Gene])
updateCaseDistances evaledPop downsampleData trainingData informedDownsamplingType solutionThreshold = undefined