2019-10-18 09:57:43 +02:00
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
2019-05-30 12:40:32 +02:00
|
|
|
{-# LANGUAGE NoImplicitPrelude #-}
|
2019-10-18 09:10:11 +02:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2019-05-30 12:40:32 +02:00
|
|
|
|
2019-10-18 09:57:43 +02:00
|
|
|
import Protolude hiding (for)
|
|
|
|
import Pretty
|
2019-10-18 09:10:11 +02:00
|
|
|
import WS19
|
2019-10-18 09:57:43 +02:00
|
|
|
import Pipes
|
|
|
|
import System.IO
|
2019-10-17 19:50:19 +02:00
|
|
|
|
2019-10-18 09:57:43 +02:00
|
|
|
mkPop = population 100 (I prios [])
|
|
|
|
|
|
|
|
main :: IO ()
|
2019-10-17 19:50:19 +02:00
|
|
|
main = do
|
2019-10-18 09:57:43 +02:00
|
|
|
hSetBuffering stdout NoBuffering
|
2019-10-17 19:50:19 +02:00
|
|
|
pop <- mkPop
|
2019-10-18 09:57:43 +02:00
|
|
|
pop' <- runEffect $ for (run 2 1 pop (steps 100)) log
|
|
|
|
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
|
|
|
|
log = putText . csv
|
|
|
|
csv (t, f) = show t <> " " <> maybe "inf" show f
|