haga/src/Main.hs

27 lines
652 B
Haskell
Raw Normal View History

{-# LANGUAGE FlexibleContexts #-}
2019-05-30 12:40:32 +02:00
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
2019-05-30 12:40:32 +02:00
import Protolude hiding (for)
import Pretty
import WS19
import Pipes
import System.IO
mkPop = population 100 (I prios [])
main :: IO ()
main = do
hSetBuffering stdout NoBuffering
pop <- mkPop
pop' <- runEffect $ for (run 2 1 pop (steps 100)) log
2019-10-18 13:36:59 +02:00
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