Need help asking in writing crossover code.

1 次查看(过去 30 天)
I have 2 sample paths right now. In reality, these parents are randomly selected and can have different number of elements each time. The sample is as follows:
Parent 1: [1 11 21 22 23 24 14 4 5 15 16 17 27 37 38 48 58 59 69 68 67 77 78 88 89 90 100]
Parent 2: [1 2 3 4 5 15 16 26 36 37 47 57 67 77 87 88 89 99 100]
How should I write the code such that the crossover occurs everytime 2 identical nodes are found?
eg. Common nodes are 1, 15, 77, 88, 89, 100. So first I need to identify the common nodes.
Then the offspring should thus be: Offspring 1: [1 2 3 4 5 15 --> 16 17 27 37 38 48 58 50 60 68 67 77 --> 87 88 --> 89 90 100] Offspring 2: [1 11 21 22 23 24 14 4 5 15 --> 16 26 36 37 47 57 67 77 --> 78 88 --> 89 99 100]
  1 个评论
Geoff Hayes
Geoff Hayes 2016-3-28
Xi - why are 4 and 5 not considered to be common nodes? Can we always assume that the numbers are in ascending order?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by