Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/model_population.py
diff options
context:
space:
mode:
authorThomas Jourdan <b.vehikel@googlemail.com>2010-03-25 20:03:15 (GMT)
committer Thomas Jourdan <b.vehikel@googlemail.com>2010-03-25 20:03:15 (GMT)
commitcf8ff965909813ff8a3f49c5c3614b3d1610d8fe (patch)
tree2d1e150ce7e7da6f12ba71c31a458d9c8ac5da8f /model_population.py
parent267e69b6ca86aa040921f04a0fecdc1f2de52148 (diff)
Added a simple ancestors view. The ancestors of newly generated will be displayed in as a tree. This is only a temporary solution and should be replaced later.
Diffstat (limited to 'model_population.py')
-rw-r--r--model_population.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/model_population.py b/model_population.py
index b29fb49..0f2e4e4 100644
--- a/model_population.py
+++ b/model_population.py
@@ -26,6 +26,7 @@ import random
import ka_debug
import model_random
import model_protozoon
+import ka_history
STATE_INIT = 'I'
STATE_RANDOMIZED = 'R'
@@ -190,11 +191,17 @@ class KandidModel(object):
new_one = good[0].crossingover(partner)
new_one.swap_places()
new_one.mutate()
-# ka_debug.info(good[0].get_unique_id() + ' and '
-# + partner.get_unique_id() + ' replaced '
-# + self.protozoans[new_at].get_unique_id())
+ history = ka_history.KandidHistory.instance()
+ history.unlink(self.protozoans[new_at].get_unique_id())
+ ka_debug.info('new offspring ' + new_one.get_unique_id()
+ + ' breeded by ' + good[0].get_unique_id() + ' and '
+ + partner.get_unique_id() + ' replaced '
+ + self.protozoans[new_at].get_unique_id())
self.protozoans[new_at] = new_one
self.fitness[new_at] = 4.0
+ history.rember_parents(new_one.get_unique_id(),
+ good[0].get_unique_id(),
+ partner.get_unique_id())
def find_partner(self, candidates):
"""Find a partner from the candidate list by chance.