diff --git a/src/HushGP/GP/Downsample.hs b/src/HushGP/GP/Downsample.hs index c544c0a..1681feb 100644 --- a/src/HushGP/GP/Downsample.hs +++ b/src/HushGP/GP/Downsample.hs @@ -3,6 +3,7 @@ module HushGP.GP.Downsample where import System.Random.Shuffle import System.Random import Data.List +import Data.Maybe import HushGP.Genome import HushGP.Utility import HushGP.GP.PushData @@ -112,9 +113,16 @@ updateAtIndices' bigList _ [] = bigList updateAtIndices' bigList [] _ = bigList updateAtIndices' bigList (sval:svals) (idx:idxs) = updateAtIndices' (replaceAt idx sval bigList) svals idxs +-- |Merges two lists of [Pushdata], replacing the PushData in the lists with their corresponding +-- (based on index) PushData in the small list. +mergePushDataListsAtIndex :: [PushData] -> [PushData] -> [PushData] +mergePushDataListsAtIndex bigList smallList = map (\x -> let correspondingSmall = find (\y -> extractIndex x == extractIndex y) smallList in fromMaybe x correspondingSmall) bigList + -- |Updates the cases distances when downsampling. updateCaseDistances :: [Individual] -> [PushData] -> [PushData] -> String -> Double -> [PushData] updateCaseDistances evaledPop downsampleData trainingData informedDownsamplingType solutionThreshold = undefined + + -- map (\other -> getDistanceBetweenCases [[0,0],[0,0]] 0 other) [0..(length [3,4] - 1)] -- tempData = intTrainData !! 0 -- dCase = tempData{_downsampleIndex = Just 3, _caseDistances = Just [2,2,2,2,2]} diff --git a/src/HushGP/Problems/IntegerRegression.hs b/src/HushGP/Problems/IntegerRegression.hs index 9999ba7..0bc1b2d 100644 --- a/src/HushGP/Problems/IntegerRegression.hs +++ b/src/HushGP/Problems/IntegerRegression.hs @@ -31,6 +31,7 @@ testIntDsData = [ (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