I'm using Python to write a simple GA code for the quadratic assignment problem with 12 departments. My solution (chromosome) is a list where the value represent the number of the department and the index represents the location. During crossover, I use (item in list) to see if a certain department already exists in an offspring to avoid duplicating. The code takes a very long time to run, and I'm guessing it's because of the (item in list) lookup time. How can I speed up this process? I know I can't convert the list into a set since I need to preserve the order of the departments! Any ideas?
Asked
Active
Viewed 404 times
1
-
Use OX, OX2, PMX crossover method? – viceriel Oct 18 '17 at 13:21