java 顺序交叉 (OX) - 遗传算法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26518393/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 10:04:15  来源:igfitidea点击:

Order Crossover (OX) - genetic algorithm

javaartificial-intelligence

提问by Silva_PT_SCP

Can someone explain me how Order Crossover works? I will give this example and I want to understand it in a generic way to implement after.

有人能解释一下订单交叉是如何工作的吗?我会给出这个例子,我想以一种通用的方式来理解它,然后再实现。

Parent 1 = 1 2 3 | 4 5 6 7 | 8 9

父 1 = 1 2 3 | 4 5 6 7 | 8 9

Parent 2 = 4 5 2 | 1 8 7 6 | 9 3

父 2 = 4 5 2 | 1 8 7 6 | 9 3

and the solution are two childreen:

解决方案是两个孩子:

Children 1 = 2 1 8 | 4 5 6 7 | 9 3

儿童 1 = 2 1 8 | 4 5 6 7 | 9 3

Children 2 = 3 4 5 | 1 8 7 6 | 9 2

儿童 2 = 3 4 5 | 1 8 7 6 | 9 2

I understand some parts but others not.

我理解某些部分,但其他部分不明白。

Thanks

谢谢

回答by Niko Adrianus Yuwono

Basically, a swath of consecutive alleles from parent 1 drops down, and remaining values are placed in the child in the order which they appear in parent 2.

基本上,来自父代 1 的一系列连续等位基因下降,其余值按照它们在父代 2 中出现的顺序放置在子代中。

enter image description here

在此处输入图片说明

Step 1: Select a random swath of consecutive alleles from parent 1. (underlined)

步骤 1:从亲本 1 中随机选择一组连续的等位基因。(下划线)

Step 2: Drop the swath down to Child 1 and mark out these alleles in Parent 2.

第 2 步:将条带放到 Child 1 并在 Parent 2 中标出这些等位基因。

Step 3: Starting on the right side of the swath, grab alleles from parent 2 and insert them in Child 1 at the right edge of the swath. Since 8 is in that position in Parent 2, it is inserted into Child 1 first at the right edge of the swath. Notice that alleles 1, 2 and 3 are skipped because they are marked out and 4 is inserted into the 2nd spot in Child 1.

第 3 步:从条带的右侧开始,从父项 2 中获取等位基因并将它们插入到条带右侧边缘的子项 1 中。由于 8 在父 2 中的那个位置,它首先被插入到子 1 中的条带的右边缘。请注意,等位基因 1、2 和 3 被跳过,因为它们被标记出来并且 4 被插入到孩子 1 的第二个位置。

Step 4: If you desire a second child from the two parents, flip Parent 1 and Parent 2 and go back to Step 1.

第 4 步:如果您希望从两个父母那里生第二个孩子,请翻转 Parent 1 和 Parent 2 并返回到步骤 1。

回答by Matthew Spencer

One such solution for Ordered Crossover is detailed in this post.

这篇文章详细介绍了一种这样的有序交叉解决方案。

This answer provides some sample java code with documentation detailing the processes used for the Ordered Crossover.

此答案提供了一些示例 java 代码以及详细说明用于有序交叉的过程的文档。

Additionally, this paperfrom Moscato provides a breakdown of the OX Process.

此外,来自 Moscato 的这篇论文提供了 OX 工艺的细分。

Hope this helps!

希望这可以帮助!