dumb error in fitness-function
This commit is contained in:
@ -175,14 +175,14 @@ fitness ps = do
|
||||
return $ repeat 1
|
||||
dieRate <- mapM (dieToPredators (zip appearingPredators popDefense)) products -- defeat predators with produced compounds
|
||||
let sumEnzymes = sum . fmap (\(_,q,a) -> fromIntegral q*a) . genome <$> ps -- amount of enzymes * activation = resources "wasted"
|
||||
staticCostOfEnzymes = (\x -> 1 - 0.01*x) <$> sumEnzymes -- static cost of creating enzymes
|
||||
staticCostOfEnzymes = (\x -> 1 - 0.02*x) <$> sumEnzymes -- static cost of creating enzymes
|
||||
nutrientsAvailable <- fmap snd <$> asks soil
|
||||
let nutrientsLeft = (\p -> [p ! i | i <- [0..fromEnum (maxBound :: Nutrient)]]) <$> products
|
||||
nutrientRatio = minimum . zipWith (flip (/)) nutrientsAvailable <$> nutrientsLeft
|
||||
costOfEnzymes = max 0 <$> zipWith (\s n -> s-n*0.01) staticCostOfEnzymes nutrientRatio -- cost to keep enzymes are static costs + amount of nutrient sucked out of the primary cycle
|
||||
costOfEnzymes = max 0 <$> zipWith (\s n -> s-n*0.1) staticCostOfEnzymes nutrientRatio -- cost to keep enzymes are static costs + amount of nutrient sucked out of the primary cycle
|
||||
survivalRate = (1-) <$> dieRate
|
||||
return $ (,) <$> zipWith (*) survivalRate costOfEnzymes
|
||||
<*> products
|
||||
return $ zip (zipWith (*) survivalRate costOfEnzymes)
|
||||
(products)
|
||||
|
||||
produceCompounds :: Plant -> [(Nutrient, Amount)] -> World (Vector Amount)
|
||||
produceCompounds (Plant genes _) substrate = do
|
||||
@ -210,9 +210,10 @@ dieToPredators :: [(Predator, Double)] -> Vector Amount -> World Probability
|
||||
dieToPredators [] _ = return 0 -- if no predator, no dying.
|
||||
dieToPredators appearingPredators compounds = do
|
||||
deters <- forM appearingPredators $ \(p,ahat) -> do
|
||||
myDeter <- dieToPredator p compounds
|
||||
return $ ahat * myDeter -- exp due to assumption that number of attacks are poisson-distributed.
|
||||
return $ product deters
|
||||
myDieRate <- dieToPredator p compounds
|
||||
return $ exp $ -(ahat*numAttacks p) * myDieRate -- exp due to assumption that number of attacks are poisson-distributed.
|
||||
-- myDieRate = 1 - Survival = 1 - S(D) in the paper
|
||||
return $ 1 - product deters
|
||||
|
||||
|
||||
dieToPredator :: Predator -> Vector Amount -> World Double
|
||||
|
Reference in New Issue
Block a user