Flow-Shop-Scheduling icon indicating copy to clipboard operation
Flow-Shop-Scheduling copied to clipboard

An alternative crossover function

Open aycignl opened this issue 7 years ago • 0 comments

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

aycignl avatar May 15 '18 00:05 aycignl