How do I replace repeated values after crossover?

Hello,
I'm working with a code for Ga and I'm on the crossover step but I have a problem. I figured out how to do the crossover but the children from the parents may have repeated numbers .. so is there a possible code or function that would help me to replace the repeated numbers with non-repeated ones?
For example:
These are the parents:
p1=[7 2 8 6 9 1 4 3 5 10]
p2=[3 8 6 9 5 7 1 2 4 10]
and these are the children:
c1=[7 2 6 9 5 7 1 2 4 10]
c2=[3 8 6 9 5 7 1 2 4 10]
Now in c1 number 7 is repeated, so what I'm asking is if it's possible to replace number 7, the repeated one, with non-repeated number in c1 array, and so on for c2.
ps. These numbers just to clarify my point.
best regards
abdulla aqeel

1 comentario

Image Analyst
Image Analyst el 21 de Mayo de 2015
I don't understand what you want to replace the second 7 in c1 with. Please give the output c1 that you'd like to get.

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 21 de Mayo de 2015

0 votos

Repeated numbers are perfectly legitimate. Keep them. The fitness function will determine whether they remain in your population or are eventually deleted. That is the whole point of genetic algorithms.
Meanwhile, keep the parents in your population, and keep the fittest individuals from each generation in a separate matrix, along with their fitness values. The fittest individual overall may not be the fittest individual in the last generation.

Categorías

Más información sobre Axes Appearance en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 21 de Mayo de 2015

Respondida:

el 21 de Mayo de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by