Compare commits

..

2 Commits

Author SHA1 Message Date
70fd714340 bestIndPassesDownsample done 2025-03-01 16:31:20 -06:00
29617dd604 cleanup testing code 2025-03-01 16:30:40 -06:00
3 changed files with 6 additions and 18 deletions

View File

@ -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 -- holds the evaluation count. The list of Individuals is the population. The last parameter is
-- the training data (possibly downsampled). -- the training data (possibly downsampled).
gpLoop' :: PushArgs -> Int -> Int -> [Individual] -> [PushData] -> IO () 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." print "Put information about each generation here."
when bestIndPassesDownsample $ print $ "Semi Success Generation: " <> show generation when bestIndPassesDownsample $ print $ "Semi Success Generation: " <> show generation
let nextAction let nextAction
@ -95,6 +95,6 @@ gpLoop' pushArgs generation evaluations population indexedTrainingData = do
bestInd :: Individual bestInd :: Individual
bestInd = case uncons evaledPop of Just (x, _) -> x; _ -> error "Error: Population is empty!" bestInd = case uncons evaledPop of Just (x, _) -> x; _ -> error "Error: Population is empty!"
bestIndPassesDownsample :: Bool bestIndPassesDownsample :: Bool
bestIndPassesDownsample = False -- TODO: fix this later bestIndPassesDownsample = enableDS && (extractTotalFitness bestInd <= seThresh)
epsilonPushArgs :: PushArgs epsilonPushArgs :: PushArgs
epsilonPushArgs = pushArgs {epsilons = Nothing} -- TODO: And this epsilonPushArgs = pushArgs {epsilons = Nothing} -- TODO: And this

View File

@ -28,6 +28,10 @@ extractFitnessCases :: Individual -> [Double]
extractFitnessCases Individual {fitnessCases = Nothing} = error "Error: fitnessCases is empty!" extractFitnessCases Individual {fitnessCases = Nothing} = error "Error: fitnessCases is empty!"
extractFitnessCases Individual {fitnessCases = Just xs} = xs 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. -- | Makes a random individual based on the variables in a passed PushArgs.
makeRandomIndividual :: PushArgs -> IO Individual makeRandomIndividual :: PushArgs -> IO Individual
makeRandomIndividual pushArgs = do makeRandomIndividual pushArgs = do

View File

@ -2,7 +2,6 @@ module HushGP.Problems.IntegerRegression where
import Data.List import Data.List
import Data.Map qualified as Map import Data.Map qualified as Map
import Control.Lens hiding (uncons)
import HushGP.State import HushGP.State
import HushGP.Instructions import HushGP.Instructions
import HushGP.GP.PushArgs import HushGP.GP.PushArgs
@ -12,10 +11,6 @@ import HushGP.Push
import HushGP.Instructions.Utility import HushGP.Instructions.Utility
import HushGP.GP import HushGP.GP
-- temporary imports for testing until I get this updated.
import HushGP.Utility
import HushGP.GP.Downsample
testPlushy :: [Gene] testPlushy :: [Gene]
testPlushy = [ testPlushy = [
PlaceInput 0, PlaceInput 0,
@ -24,17 +19,6 @@ testPlushy = [
-- GeneFloat 3.2 -- GeneFloat 3.2
] ]
-- |Equivalent to ds-data
testIntDsData :: [PushData]
testIntDsData = [
(head intTrainData){_downsampleIndex = Just 3, _caseDistances = Just [2,2,2,2,2]},
(intTrainData !! 1){_downsampleIndex = Just 4, _caseDistances = Just [2,2,2,2,2]}
]
-- This is the map-indexed call in the update-case-distances function.
tempFunc :: [PushData]
tempFunc = mapIndexed (\idx dCase -> dCase{_caseDistances = Just (updateAtIndices (extractDistance dCase) (map (\other -> getDistanceBetweenCases [[0,0],[0,0]] idx other) [0..(length [3,4] - 1)]) [3,4])}) testIntDsData
-- | The target function for this run. The function the gp -- | The target function for this run. The function the gp
-- is trying to evolve. -- is trying to evolve.
targetFunction :: Integer -> Integer targetFunction :: Integer -> Integer