From 3c45c206fc94b4a6ee2553f79b13f5ddfd3d58af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20P=C3=A4tzel?= Date: Tue, 22 Oct 2019 07:08:37 +0200 Subject: [PATCH] Fix floating point precision problems in GA.worst By using negate instead of (1 /). --- src/GA.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/GA.hs b/src/GA.hs index 801926c..16c1c10 100644 --- a/src/GA.hs +++ b/src/GA.hs @@ -158,8 +158,7 @@ bestsBy k f = The @k@ worst individuals in the population. -} worst :: (Individual i, Monad m) => N -> Population i -> m [i] --- TODO (1 /) might not be stable regarding floating point precision -worst = flip bestsBy (fmap (1 /) . fitness) +worst = flip bestsBy (fmap negate . fitness) {-| The @k@ best individuals in the population.