def make_halt_function(cantus_firmus):

    def halt(population, generation_count):
        """
        Given a population of candidate solutions and generation count (the
        number of epochs the algorithm has run) will return a boolean to
        indicate if an acceptable solution has been found within the
        referenced population.
        """
        fittest = population[0]
        max_fitness = MAX_REWARD
        for i in range(len(fittest.chromosome)):
            # Check for dissonances. Each dissonance should have incremented
            # the fitness because it has been "placed" correctly.
            cantus_firmus_note = cantus_firmus[i / 4]
            melody_note = fittest.chromosome[i]
            interval = melody_note - cantus_firmus_note
            if interval in DISSONANCES:
                max_fitness += REWARD_STEPWISE_MOTION
            else:
                if i > 0 and i < (len(fittest.chromosome) - 2):
                    if is_stepwise_motion(fittest.chromosome, i):
                        max_fitness += REWARD_STEPWISE_MOTION

        return (fittest.fitness >= max_fitness or
            generation_count > DEFAULT_MAX_GENERATION)

    return halt
Convert a job ID to int format.
dataset/ETHPy150Open ntoll/foox/foox/species/third.py/make_halt_function--crossover with--dataset/ETHPy150Open ganeti/ganeti/lib/jstore.py/FormatJobID