From bac7751a83e57c59711bcb3e9339dc5dc9de8ea6 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Wed, 5 Mar 2025 00:55:18 -0600 Subject: [PATCH] start of simplification --- HushGP.cabal | 1 + src/HushGP/GP/Simplification.hs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/HushGP/GP/Simplification.hs diff --git a/HushGP.cabal b/HushGP.cabal index 97c2778..5e6dc78 100644 --- a/HushGP.cabal +++ b/HushGP.cabal @@ -68,6 +68,7 @@ library , HushGP.GP.PushData , HushGP.GP.Selection , HushGP.GP.Individual + , HushGP.GP.Simplification , HushGP.Problems.IntegerRegression , HushGP.Tools.Metrics diff --git a/src/HushGP/GP/Simplification.hs b/src/HushGP/GP/Simplification.hs new file mode 100644 index 0000000..f6d9dbf --- /dev/null +++ b/src/HushGP/GP/Simplification.hs @@ -0,0 +1,19 @@ +module HushGP.GP.Simplification where + +import Control.Monad +import HushGP.State +import HushGP.GP.PushArgs + +-- | Simplifies a Plushy by randomly deleting instructions and seeing how it impacts +-- performance. Removes genes that have zero to negative performance impact. +autoSimplifyPlushy :: PushArgs -> [Gene] -> IO [Gene] +autoSimplifyPlushy pushArgs@PushArgs{simplificationVerbose = simpVerbose, errorFunction = eFunc, trainingData = tData} plushy = do + when simpVerbose (print ("simplification start plushy length: " <> show (length plushy))) + autoSimplifyPlushy' pushArgs (eFunc pushArgs tData plushy) 0 plushy + +autoSimplifyPlushy' :: PushArgs -> [Double] -> Int -> [Gene] -> IO [Gene] +autoSimplifyPlushy' pushArgs@PushArgs{simplificationSteps = simpSteps} initialErrors step plushy + | step < simpSteps = do + newPlushy <- undefined + undefined + | otherwise = undefined