diff --git a/src/GA.hs b/src/GA.hs index 49f24e2..987d476 100644 --- a/src/GA.hs +++ b/src/GA.hs @@ -174,11 +174,14 @@ step -> Population i -> m (Population i) step nParents nX pop = do + iBests <- bests 1 pop is <- proportionate nParents pop i :| is' <- children nX is iWorsts <- worst nParents pop - let popClean = foldr L.delete (NE.toList . unPop $ pop) iWorsts - return . Pop $ i :| is' <> popClean + let popClean = foldr L.delete (NE.toList . unPop $ pop) $ iBests <> iWorsts + -- TODO why does this not work? (we should use it!) + -- Pop <$> (shuffle' . NE.nub $ i :| is' <> popClean <> iBests) + return . Pop . NE.nub $ i :| is' <> popClean <> iBests {-| Runs the GA, using in each iteration diff --git a/src/Main.hs b/src/Main.hs index 1639f01..ae7b3d9 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -20,7 +20,6 @@ main = do res <- bests 5 pop' sequence_ $ format <$> res where - format :: (Individual i, MonadIO m, Pretty i) => i -> m () format s = do f <- liftIO $ fitness s putErrText $ show f <> "\n" <> pretty s