Flow-Shop-Scheduling
Flow-Shop-Scheduling copied to clipboard
An alternative crossover function
Hi Burak. Many thnx for your implementation✌🏼 With my friend Cagla Yaman, we implement an alternative two-point crossover function using your code environment. I hope this will be helpful for other people👍🏼 Best.
def crossover(parents):
parent1 = parents[0]
parent2 = parents[1]
length_of_parent = len(parent1)
first_point = int(length_of_parent / 2 - length_of_parent / 4)
second_point = int(length_of_parent - first_point)
intersect = parent1[first_point:second_point]
child = []
index = 0
for pos2 in range(len(parent2)):
if first_point <= index < second_point:
child.extend(intersect)
index = second_point
if parent2[pos2] not in intersect:
child.append(parent2[pos2])
index += 1
return child