part of the maxmin loop done

This commit is contained in:
Rowan Torbitzky-Lane 2025-02-27 02:52:19 -06:00
parent 8e40396828
commit 4aa8aa9f2a
3 changed files with 15 additions and 2 deletions

View File

@ -66,6 +66,7 @@ library
, HushGP.GP.Downsample , HushGP.GP.Downsample
, HushGP.GP.PushData , HushGP.GP.PushData
, HushGP.Problems.IntegerRegression , HushGP.Problems.IntegerRegression
, HushGP.Tools.Metrics
-- Modules included in this library but not exported. -- Modules included in this library but not exported.

View File

@ -24,7 +24,7 @@ selectDownsampleRandom :: PushArgs -> [PushData] -> IO [PushData]
selectDownsampleRandom pushArgs pushData = take (floor (downsampleRate pushArgs * fromIntegral @Int @Float (length pushData))) . shuffle' pushData (length pushData) <$> initStdGen selectDownsampleRandom pushArgs pushData = take (floor (downsampleRate pushArgs * fromIntegral @Int @Float (length pushData))) . shuffle' pushData (length pushData) <$> initStdGen
-- |Selects a downsample that has it's cases maximally far away by sequentially -- |Selects a downsample that has it's cases maximally far away by sequentially
-- adding cases to the downsample that have their closest case maximally far away -- adding cases to the downsample that have their closest case maximally far away.
selectDownsampleMaxmin :: PushArgs -> [PushData] -> IO [PushData] selectDownsampleMaxmin :: PushArgs -> [PushData] -> IO [PushData]
selectDownsampleMaxmin (PushArgs {downsampleRate = dsRate}) pushData = do selectDownsampleMaxmin (PushArgs {downsampleRate = dsRate}) pushData = do
shuffledCases <- shuffle' pushData (length pushData) <$> initStdGen shuffledCases <- shuffle' pushData (length pushData) <$> initStdGen
@ -34,5 +34,14 @@ selectDownsampleMaxmin (PushArgs {downsampleRate = dsRate}) pushData = do
(drop 1 shuffledCases) (drop 1 shuffledCases)
goalSize goalSize
-- |The main loop of selectDownsampleMaxmin. This is where most of calculation happens.
-- When called from selectDownsampleMaxmin: The first [PushData] holds the head of the
-- original pushData wrapped in a list, the second [PushData] holds the rest of the list
-- without the aformentioned head. The Int is the goal size derived from the downsample rate
-- and the length of the original [pushData].
selectDownsampleMaxmin' :: [PushData] -> [PushData] -> Int -> IO [PushData] selectDownsampleMaxmin' :: [PushData] -> [PushData] -> Int -> IO [PushData]
selectDownsampleMaxmin' newDownsample casesToPickFrom goalSize = undefined selectDownsampleMaxmin' newDownsample casesToPickFrom goalSize
| length newDownsample >= goalSize = pure newDownsample
| otherwise = do
minCaseDistances

View File

@ -0,0 +1,3 @@
module HushGP.Tools.Metrics where