more downsample progress, only a few more functions to go :), need to test this

This commit is contained in:
Rowan Torbitzky-Lane 2025-03-01 04:21:10 -06:00
parent fc2aaff280
commit d51a20f66f
2 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,7 @@ module HushGP.GP.Downsample where
import System.Random.Shuffle import System.Random.Shuffle
import System.Random import System.Random
import Data.List import Data.List
import Data.Maybe
import HushGP.Genome import HushGP.Genome
import HushGP.Utility import HushGP.Utility
import HushGP.GP.PushData import HushGP.GP.PushData
@ -112,9 +113,16 @@ updateAtIndices' bigList _ [] = bigList
updateAtIndices' bigList [] _ = bigList updateAtIndices' bigList [] _ = bigList
updateAtIndices' bigList (sval:svals) (idx:idxs) = updateAtIndices' (replaceAt idx sval bigList) svals idxs 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. -- |Updates the cases distances when downsampling.
updateCaseDistances :: [Individual] -> [PushData] -> [PushData] -> String -> Double -> [PushData] updateCaseDistances :: [Individual] -> [PushData] -> [PushData] -> String -> Double -> [PushData]
updateCaseDistances evaledPop downsampleData trainingData informedDownsamplingType solutionThreshold = undefined updateCaseDistances evaledPop downsampleData trainingData informedDownsamplingType solutionThreshold = undefined
-- map (\other -> getDistanceBetweenCases [[0,0],[0,0]] 0 other) [0..(length [3,4] - 1)] -- map (\other -> getDistanceBetweenCases [[0,0],[0,0]] 0 other) [0..(length [3,4] - 1)]
-- tempData = intTrainData !! 0 -- tempData = intTrainData !! 0
-- dCase = tempData{_downsampleIndex = Just 3, _caseDistances = Just [2,2,2,2,2]} -- dCase = tempData{_downsampleIndex = Just 3, _caseDistances = Just [2,2,2,2,2]}

View File

@ -31,6 +31,7 @@ testIntDsData = [
(intTrainData !! 1){_downsampleIndex = Just 4, _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 :: [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 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