【发布时间】:2026-02-02 09:20:16
【问题描述】:
我正在尝试实现蚁群优化。试图参考这篇论文:Improved ant colony optimization for robot navigation paper。 由于我没有得到这些问题的任何答案,因此我在实施过程中陷入了一半的困境。所以我现在问与蚁群有关的具体问题:
到目前为止,我所做的是,设置了一个二维数组地图,地图周围的边界和障碍物都有
0值。障碍物是在随机位置生成的,方法是在该数组中随机插入
0[row,column]。我已将所有蚂蚁开始旅程的来源放置在左下角。我已将目标位置放在右上角。
已编写代码以使用 VB.Net 中的 Graphics 函数直观地绘制地图,并且工作正常。信息素的颜色渐变显示在地图上(即,更多的白色阴影,更多的信息素在地图上沉积,否则为深色)
我当前的实现伪代码如下所示:
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
这是我到目前为止所做的截图:
目前,实施陷入困境。当我阅读其他论文以及在谷歌中引用时,据说蚂蚁起初是随机行走的。但是其他蚂蚁使用路径上的信息素浓度来选择路径。这意味着,如果一只蚂蚁找到了目标,它应该返回巢穴而不是终止程序?以及其他蚂蚁如何选择信息素浓度高的路径?无法保证其他蚂蚁在正确的路径上移动。
我真的很困惑。我了解简单的现实世界示例。蚂蚁起初随机移动寻找食物,如果找到食物,它会返回巢穴并再次返回,因此该路径中的信息素沉积会更高,其他蚂蚁会选择该路径。
但是当我尝试实施时,它变得棘手和困惑。 我真的很感激一些简单的想法或解释。我不是在寻找代码。这就是为什么我编写了伪代码而不是发布到目前为止我实际实现的代码。
【问题讨论】:
-
您可能需要查看antme 以获得视觉表示。
标签: algorithm mathematical-optimization