little changes, some first simulation-results

This commit is contained in:
Stefan Dresselhaus
2018-06-08 12:10:28 +02:00
parent e77cd02c21
commit 6d702f6b2f
8 changed files with 2024 additions and 22 deletions

View File

@ -107,12 +107,16 @@ loop loopAmount ps env = loop' loopAmount 0 ps env
spc = meanAndVar `from` sumProducedCompounds $ cs
ndc = meanAndVar `from` numDistinctCompounds $ cs
fns = meanAndVar `from` id $ fs
cstats = meanAndVar `from` id <$> byProducts cs
cstats' = meanAndVar `from` id $ snd <$> cstats
when (curLoop `mod` printEvery == 0) $ liftIO $ do
printPopulation stringe (zip3 plants fs cs)
putStrLn $ "Population statistics (mean,variance):"
putStrLn $ "Amount of Components produced = " ++ (padded 50 . show $ spc)
putStrLn $ "Number of distinct Components = " ++ (padded 50 . show $ ndc)
putStrLn $ "Fitness = " ++ (padded 50 . show $ fns)
putStrLn $ show cstats
putStrLn $ show cstats'
hFlush stdout
threadDelay $ 10*1000 -- sleep x*1000ns (=x ~ ms)
tell $ show curLoop
@ -143,9 +147,12 @@ main = do
ds <- randoms <$> newStdGen
--probs <- randomRs (0.2,0.7) <$> newStdGen
let poisonedTree = poisonTree ds randomCompounds
poisonCompounds = foldMap (\(a,b) -> [(b,a) | a > 0.5]) poisonedTree
predators <- generatePredators 0.5 poisonedTree
--let env = exampleEnvironment (getTreeSize randomCompounds) (generateEnzymeFromTree randomCompounds) (zip predators probs) poisonCompounds
poisonCompounds = foldMap (\(a,b) -> [(b,a) | a > 0]) poisonedTree
predators <- generatePredators 0.0 poisonedTree
let poisonCompounds' = pruneCompounds poisonCompounds predators
pruneCompounds cs ps = filter ((`elem` usedPoisons) . fst) cs
where usedPoisons = concat $ irresistance <$> ps
--let env = exampleEnvironment (getTreeSize randomCompounds) (generateEnzymeFromTree randomCompounds) (zip predators probs) poisonCompounds'
(Just env) <- decodeStrict' <$> BS.readFile "environment2.json"
let emptyPlants = replicate (numPlants . settings $ env) emptyPlant
enzs <- randomRs (0,length (possibleEnzymes env) - 1) <$> newStdGen