Exemplo n.º 1
0
def copulate(gen, parent1, parent2):
    """
    Randomly averages values or chooses one of parents (50/50).
    Returns a new solution.
    """
    child = Solution(parent1.data, gen) 
    if parent1 is not parent2:
        copulate_recursive(child.data, parent2.data)

    child.update_hash()
    return child