蚁群算法 - 蚂蚁运动算法、蚂蚁

2023-09-11 06:58:12 作者:风穿林堂

我想实现蚁群算法。试图将这一文件:Improved蚁群优化机器人导航纸。 因为我没有得到任何回答这些问题,我停留在半部分在我的实现。所以,我要求与现在蚁群具体的问题:

I am trying to implement ant colony optimization. Tried to refer this paper: Improved ant colony optimization for robot navigation paper. Since I didn't got any answers to those questions I am stuck at half part in my implementation. So am asking specific questions related to ant colony now:

我做了什么至今,已经建立了二维数组地图,用 0 值周围的地图边界,以及障碍物。

What I have done so far is, have setup a 2d array map, with 0 value for the boundary around the map as well as for obstacles.

在任意位置产生的障碍,由该阵列插入 0 随意[行,列]。

The obstacles are generated at random position, by inserting the 0 at random [row,column] in that array.

我已经把源,所有的蚂蚁开始的旅程,是从左下角。而且我已经把要上右上角的目标位置。

I have placed the source, where all the ants starts the journey, to be from the left bottom corner. And I have placed the destination location to be on the top right corner.

写了code。使用在VB.Net图形功能绘制地图可视化并能正常工作。渐变色显示的信息素显示在地图上(即更白翳的地图上寻找信息素沉积,否则深色)

Have written code to draw the map visually using Graphics function in VB.Net and it works fine. Color gradient displaying of the pheromones is shown on the map(ie. more white shade for more pheromone deposition on map, otherwise dark shade)

我的当前实现伪code是这样的:

My current implementations pseudo code would look like this:

for each ant from 1 to colonysize
  create an ant and insert it to the ant_array
  set the ant's current position to the starting position in the map
end for

for each rows in map array
  for each column in map array
    if it is first row or first column or last row or last column(these holds the boundary), then...
       assign 0 as value to <row,column> in the map array
    otherwise,
       assign INITIAL_PHEROMONE_FACTOR as value to <row,column> in the map array 
    end if
  end for
end of

for 5 random locations in map(ie. <row, column> )
  insert 0 as value to denote obstacle
end for

for 1 to TOTAL_NUMBER_OF_ITERATIONS
  for 1 to TOTAL_ANTS_IN_COLONY

     find the neighbors of the current ant in top, right, bottom and left positions

     choose randomly a neighboring position from the above 
     check whether that location has an obstacle or is a boundary (ie. if it has 0 as value in array map)
     if so, 
    repeat the above two steps of randomly chosing another neighboring position which was not already considered
     otherwise, continue to the next line..


     set the neighbor position we have selected above as the current position of the ant
     save this position to the ant's local path storage

     if the current position of this ant is the destination location, 
    then end program

  end for

  evaporate pheromones in the map at a constant factor
  deposit pheromones on the current location of all the ants


  draw the visual representationg of the map
end for

下面是我迄今所做的截图:

Here's the screenshot of what I have done so far:

目前,实施被卡住。当我看到其他文件,以及在谷歌简称,它是说,蚂蚁在第一游走。但在路径上的信息素浓度被其他蚂蚁选择路径。这意味着,如果一只蚂蚁找到了目标,它应该返回终止程序的回巢呢?而如何将其他蚂蚁选择具有较高的信息素浓度的路径?谁也不能保证,其他蚂蚁正在朝着正确的道路。

At the moment, the implementation is stuck. When I read other papers as well as referred in google, it is said that, the ants at first walks randomly. But pheromone concentration on a path is used by other ants to choose the path. That means, if an ant had found the goal, it should return back to the nest instead of terminating the program? And how the other ants choose a path with high pheromone concentration? There is no guarantee that the other ants are moving in the right path.

我真的很不少困惑与此有关。我所理解的简单的现实世界的例子。蚂蚁在第一个动作随机寻找食物,并且如果发现食物,它会返回回巢,去回来,因此该路径的信息素沉积将更高,其他蚂蚁也选择了这条道路。

Am really lot of confused with this. I understand the simple real world example. Ants at first moves randomly in search of food, and if an finds food, it would return back to the nest and goes back again and therefore the pheromone deposition in that path would be higher and other ants would chose that path.

但是,当我试图执行,它变得棘手和困惑我。 我真的AP preciate一些简单的想法或解释。不是找code。这就是为什么我写的,而不是张贴我的实际执行情况迄今所做的code中的伪code。

But when I tried to implement, it's getting tricky and confusing for me. I would really appreciate some simple ideas or explanations. Am not looking for code. That's why I wrote the psuedo code instead of posting the code of my actual implementation done so far.

推荐答案

下面就是蚁群优化的功能:

Here's what Ant colony optimization does:

发送的第一个蚂蚁。因为最初的板不具有信息素,第一蚂蚁只能使用随机运动来搜索路径的食物。 增加形成由第一蚂蚁发现了少量的路径上的所有细胞中的信息素值。 发送另一个蚂蚁,蚂蚁此应该找到一个路径通过拾取下一个单元前往在这样一种方式,以高信息素值的小区更可能比具有较低信息素的细胞来进行选择。由于随机因素,蚂蚁有时接低信息素的路径,可以偶尔会产生更好/更短的路径。 如果蚂蚁成功,则增加该路径上的信息素值,因此路径上的细胞更可能被选择。如果蚂蚁不成功,则终止蚂蚁,重新开始。 有时候,减少对整个板,使不太成功的细胞将得到回升越来越少的信息素。 重复3,直到路径是不够好。

过了一段时间,即是最成功的将含有较高量的信息素的比不太成功的路径的路径。

Over a period of time, the path that are most successful will contain higher amount of pheromone than less successful path.

谁也不能保证,其他蚂蚁正在朝着正确的道路!

There is no guarantee that the other ants are moving in the right path!

这是该算法的随机性点。如果蚂蚁只用过久经考验的路径,那么将永远无法改善的路径。在使用加权随机选择下一个单元格的一点是,这样一个流浪的蚂蚁也许能不小心绊倒比原来路径更好的路径。

That's the point of the randomness in the algorithm. If the ant only ever used tried and tested path, then it would never be able to improve the path. The point of the using weighted randomness to choose the next cell is so that a stray ant may be able to accidentally stumble on a better path than the original path.