diff --git a/hamazaki1990/main.py b/hamazaki1990/main.py index 3f1d5eb..44ae805 100644 --- a/hamazaki1990/main.py +++ b/hamazaki1990/main.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import random -from individual import Individual from population import Population @@ -16,16 +14,45 @@ def get_heterogeneity(Population): def simulate_fixwf(Population): - cnt = 1 + cnt = 0 while get_heterogeneity(Population): - Population = Population.next_genwf() + Population.next_genwf() + Population.print_ids() cnt += 1 - print(Population._inds) else: print(cnt) +def simulate_fixmo(Population): + cnt = 0 + while get_heterogeneity(Population): + Population.next_genmo() + Population.print_ids() + cnt += 1 + else: + print(cnt) + + +p = Population(5) +p.print_ids() +print(get_heterogeneity(p)) +cnt = 1 +while get_heterogeneity(p): + p.next_genwf() + p.print_ids() + print(get_heterogeneity(p)) + print(cnt) + cnt += 1 +winner = p._inds[0] +print(winner.get_id()) + p1 = Population(5) p1.print_ids() print(get_heterogeneity(p1)) simulate_fixwf(p1) + + +p2 = Population(5) +p2.print_ids() +print(get_heterogeneity(p2)) +simulate_fixmo(p2)