Compare commits

..

No commits in common. "70fd7143405d356939e903c11e1d04762aa7cbad" and "4342803211e68cd5c92ea0458ca8b8457e908437" have entirely different histories.

3 changed files with 18 additions and 6 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@(PushArgs {enableDownsampling = enableDS, solutionErrorThreshold = seThresh}) generation evaluations population indexedTrainingData = do gpLoop' pushArgs 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@(PushArgs {enableDownsampling = enableDS, solutionErrorThreshol
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 = enableDS && (extractTotalFitness bestInd <= seThresh) bestIndPassesDownsample = False -- TODO: fix this later
epsilonPushArgs :: PushArgs epsilonPushArgs :: PushArgs
epsilonPushArgs = pushArgs {epsilons = Nothing} -- TODO: And this epsilonPushArgs = pushArgs {epsilons = Nothing} -- TODO: And this

View File

@ -28,10 +28,6 @@ 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,6 +2,7 @@ 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
@ -11,6 +12,10 @@ 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,
@ -19,6 +24,17 @@ 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