TSP遗传算法-路径表示和相同的游览问题

时间:2018-12-19 10:49:18

标签: algorithm matlab computer-science genetic-algorithm traveling-salesman

我们正在实施路径表示法,以使用遗传算法解决旅行商的问题。但是,我们想知道如何解决我们的个人中可能存在完全相同的旅行,但是路径表示将其识别为不同的个人的问题。一个例子:

Example image

每个人都由一个数组组成,其中的元素是按顺序访问的城市。

Individual 1:
[1 2 3 4 5]

Individual 2:
[4 5 1 2 3]

您可以看到1和2中的游览实际上是相同的,只是“开始”位置不同。

我们看到了解决该问题的一些方法,但是我们想知道哪种方法最好,或者是否有最佳实践可以通过文献/实验/来克服这一问题。...

解决方案1 ​​

Sort each individual to see if the individuals are identical:

 1. pick an individual
 2. shift the elements by 1 element to the right (at the end of the array, elements are placed at the beginning of the array)
 3. check if this shift now matches an individual
 4. if not, repeat steps 3 to 4

解决方案2

1. At the start if the simulations, choose a fixed starting point of the cities.
2. If the fixed starting point would change (mutation, recombination,...) then
3. Shift the array so that chosen starting point is back on first index.

解决方案3

1. Use the adjacency representation to check which individuals are identical. 
2. Pass this information on to the path representation.
3. This is used to "correct" the individuals.

解决方案1和2似乎很耗时,尽管2可能需要更少的计算时间。解决方案3需要不断地从一种表示切换到另一种表示。

然后还有一个问题,在我们的示例中,可以通过两种方式阅读导览:

[1 2 3 4 5]

相同

[5 4 3 2 1]

还是在这里,有什么最佳实践可以解决这个问题?

1 个答案:

答案 0 :(得分:1)

由于您需要访问每个城市并返回原点城市,因此只需确定原点即可。那完全解决了您转移等价游览的问题。

对于另一个不太重要的镜像旅行,您可以从按费用对您的个人进行排序(您可能已经这样做了)开始,然后使用简单的回文检查算法,以相等的费用检查任何一对旅行。