add parallel computing features not sure if this is a real improvement

This commit is contained in:
Christian Merten
2019-05-19 15:57:06 +02:00
parent c47e82d2e0
commit da217b5196
4 changed files with 28 additions and 9 deletions
+6 -3
View File
@@ -7,6 +7,8 @@ module AI.Rulebased (
mkAIEnv, testds, simplify
) where
import Control.Parallel.Strategies
import Data.Ord
import Data.Monoid ((<>))
import Data.List
@@ -163,6 +165,7 @@ compareGuess (c1, ops1) (c2, ops2)
distributions :: Guess -> (Int, Int, Int, Int) -> [Distribution]
distributions guess nos =
helper (sortBy compareGuess $ M.toList guess) nos
`using` parList rdeepseq
where helper [] _ = []
helper ((c, hs):[]) ns = map fst (distr c hs ns)
helper ((c, hs):gs) ns =
@@ -246,9 +249,9 @@ chooseStatistic = do
2 -> 2
3 -> 3
-- simulate only partially
4 -> 2
5 -> 1
6 -> 1
4 -> 3
5 -> 2
6 -> 2
7 -> 1
8 -> 1
9 -> 1