wurmen / Genetic-Algorithm-for-Job-Shop-Scheduling-and-NSGA-II

Learning how to implement GA and NSGA-II for job shop scheduling problem in python
298 stars 137 forks source link

"break" in selection section #3

Open CHI-MING-LEE opened 6 years ago

CHI-MING-LEE commented 6 years ago

Hi,

Thank you for your excellent work! However, it seemed that there was a mistake in the selection section.

 if selection_rand[i]<=qk[0]:
            population_list[i][:]=total_chromosome[0][:]
            break  # <- the break was weird
        else:
            for j in range(0,population_size*2-1):
                if selection_rand[i]>qk[j] and selection_rand[i]<=qk[j+1]:
                    population_list[i][:]=total_chromosome[j+1][:]
                    break  # -> should be moved here?
wurmen commented 6 years ago

Oh! There was indeed a mistake. Thanks for your reminder. I have revised the code. Thanks