def generate_crossover_pairs(n): for i in range(n): LEN = random.randint(MINLEN, MAXLEN) g = [random.randint(0, MAXV-1) for i in range(LEN)] gind = IndividualWithSemantics(g) if gind[phenotype_idx] is None: continue LEN = random.randint(MINLEN, MAXLEN) h = [random.randint(0, MAXV-1) for i in range(LEN)] hind = IndividualWithSemantics(h) if hind[phenotype_idx] is None: continue children = xover(gind, hind) cind0 = IndividualWithSemantics(children[0]) cind1 = IndividualWithSemantics(children[1]) if cind0[phenotype_idx] is not None: yield (gind, cind0) yield (hind, cind0) if cind1[phenotype_idx] is not None: yield (gind, cind1) yield (hind, cind1)
def generate_crossover_pairs(n): for i in range(n): LEN = random.randint(MINLEN, MAXLEN) g = [random.randint(0, MAXV-1) for i in range(LEN)] gind = make_individual(g) if gind.phenotype is None: continue LEN = random.randint(MINLEN, MAXLEN) h = [random.randint(0, MAXV-1) for i in range(LEN)] hind = make_individual(h) if hind.phenotype is None: continue children = xover(gind, hind) cind0 = make_individual(children[0]) cind1 = make_individual(children[1]) if cind0.phenotype is not None: yield (gind, cind0) yield (hind, cind0) if cind1.phenotype is not None: yield (gind, cind1) yield (hind, cind1)