Fix floating point precision problems in GA.worst

By using negate instead of (1 /).
This commit is contained in:
David Pätzel 2019-10-22 07:08:37 +02:00
parent 939502e511
commit 3c45c206fc

View File

@ -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.