最优蚁群定位算法

时间:2015-02-07 06:21:45

标签: algorithm shortest-path path-finding

假设有一个网格包含两个墙(被阻挡的单元格)以及放置在网格上任何位置的食物。

Image of example grid

现在假设我们正在尝试确定在该网格上放置蚁群的最佳位置,以便蚂蚁必须行进最小距离(在任何方向上往/来自群体的起始点)以获得最大值食物量。

到目前为止,我提出的最佳方法如下:

for each square on the grid
    use a shortest path algorithm to find the distance to/from each food source from this square
    sum these distances to find a number and put the number in that square
select the square with the smallest number

这种方法是否有效?有更有效的解决方案吗?

2 个答案:

答案 0 :(得分:2)

是的,您的算法有效,但您可以根据[食物包数量]<< [网格中的正方形]。例如。在上图中。

distances = new int[ROWS][COLS];

for each food-packet on the grid
    use a shortest path algorithm to find the distance to/from each square from this food-packet
    accumulate the distances for each square in the 'distances' array

最后,距离数组将包含一个蚁群必须做的工作量来捕获网格上的所有食物包。将蚁群放在最小值的正方形上。

但请注意,此方法的渐近复杂性与您在问题中给出的算法保持一致。


P.S taoufiq在评论中给出了对算法的另一个明显优化。即。停止计算超过迄今为止发现的最短距离的任何最短路径总和。

希望这很有用。

答案 1 :(得分:0)

基于蛮力方法的一些优化:

  • 跟踪最短距离,并停止计算超出

    的任何sum of shortest paths
  • 如果曼哈顿距离(delta(x) + delta(y))长于有记录的短距离,请停止计算

  • 结合曼哈顿距离优化:从食物包的中心或食物包中心开始,自己从里到外工作。最佳位置更可能位于中间

  • 将您的搜索范围缩小到食品包之间的区域(即来自[1,1] to [6,7],而不是[0,0] to [7,7]

  • Nikunj的优化

此外,如果您的电路板非常庞大,optimisation solver可能会减少计算次数。但是,你的问题似乎是一个非凸问题,许多求解器都有解决这些问题的问题。