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 件のコメント

Image Analyst
Image Analyst 2015 年 5 月 21 日
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.

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2015 年 5 月 21 日

0 投票

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.

カテゴリ

ヘルプ センター および File ExchangeAxes Appearance についてさらに検索

タグ

質問済み:

2015 年 5 月 21 日

回答済み:

2015 年 5 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by