def fitness_func(individual):
    """Evaluate the fitness of an individual using hamming
    distance to [1,1, ... , 1]. returns value within [0,1]
    """

    # ideal vector
    target = [1] * len(individual)

    # hamming distance to ideal vector
    distance = sum([abs(x - y) for (x,y) in zip(individual, target)]) / float(len(target))

    # invert for fitness
    return 1 - distance