蚁群优化 - 蚂蚁的运动

时间:2014-05-10 16:11:19

标签: algorithm mathematical-optimization

我正在尝试实施蚁群优化。试图参考这篇论文:Improved ant colony optimization for robot navigation paper。 由于我没有得到任何问题的答案,所以我在实施中被困在一半。现在我正在询问与蚁群有关的具体问题:

  1. 到目前为止,我已经设置了一个二维数组地图,地图边界和障碍物的边界值为0

  2. 通过在该数组中随机插入0 [row,column],在随机位置生成障碍物。

  3. 我已将所有蚂蚁开始旅程的来源放在左下角。我已将目的地位置放在右上角。

  4. 编写代码,使用VB.Net中的Graphics函数直观地绘制地图,并且工作正常。信息素的颜色梯度显示在地图上显示(即,更多的白色阴影,以便在地图上沉积更多的信息素,否则为深色阴影)

  5. 我当前的实现伪代码如下所示:

    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
    

    这是我到目前为止所做的截图:

    enter image description here

    目前,实施工作陷入困境。当我阅读其他论文以及在谷歌中提到的时候,据说,蚂蚁起初随机走路。但是路径上的信息素浓度被其他蚂蚁用来选择路径。这意味着,如果一只蚂蚁找到了目标,它应该返回巢而不是终止程序?其他蚂蚁如何选择信息素浓度高的路径?无法保证其他蚂蚁正在朝着正确的道路前进。

    我真的很困惑。我理解简单的现实世界的例子。蚂蚁最初随机移动寻找食物,如果找到食物,它会返回巢穴并再次返回,因此该路径中的信息素沉积会更高,其他蚂蚁会选择该路径。

    但是当我试图实施时,它对我来说变得棘手和困惑。 我真的很感激一些简单的想法或解释。我不是在寻找代码。这就是为什么我写了psuedo代码,而不是发布我到目前为止完成的实际实现的代码。

1 个答案:

答案 0 :(得分:2)

以下是蚁群优化的作用:

  1. 发送第一只蚂蚁。因为最初板上没有信息素,第一只蚂蚁只能用随机移动来寻找食物的路径。
  2. 增加形成第一只蚂蚁发现的路径的所有细胞的信息素值。
  3. 发送另一只蚂蚁,这只蚂蚁应该通过选择下一个细胞来找到一条路径,使得具有高信息素值的细胞比具有较低信息素的细胞更可能被选择。由于随机因素,蚂蚁有时会选择较低信息素的路径,偶尔会产生更好/更短的信息。
  4. 如果蚂蚁成功,则增加该路径上的信息素值,以便更有可能选择路径上的细胞。如果蚂蚁不成功,则中止蚂蚁并重新开始。
  5. 有时候,减少整个板上的信息素,这样不那么成功的细胞就会越来越少。
  6. 重复3,直到路径足够好。
  7. 在一段时间内,最成功的路径将包含比不太成功的路径更多的信息素。

      

    无法保证其他蚂蚁正在朝着正确的道路前进!

    这就是算法中随机性的要点。如果蚂蚁只使用过经过试验和测试的路径,那么它就永远无法改善路径。使用加权随机性来选择下一个单元格的点是这样一个流浪蚂蚁可能会在比原始路径更好的路径上偶然发现绊倒。

相关问题