- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试实现蚁群优化。试图引用这篇论文:Improved ant colony optimization for robot navigation paper .由于我没有得到这些问题的任何答案,所以我在实现过程中卡在了一半。所以我现在问与蚁群有关的具体问题:
到目前为止,我所做的是设置一个二维数组 map , map 周围的边界和障碍物的值为 0
。
通过在该数组中随机 [row,column] 插入 0
来在随机位置生成障碍物。
我已将所有 Ant 开始旅程的来源放在左下角。我已经将目标位置放在右上角。
已编写代码,使用 VB.Net 中的图形函数直观地绘制 map ,效果很好。信息素的颜色渐变显示在 map 上(即白色阴影越多,信息素在 map 上沉积越多,否则阴影越深)
我当前的实现伪代码如下所示:
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
这是我到目前为止所做的截图:
目前,实现卡住了。当我阅读其他论文以及在谷歌中提到时,据说, Ant 起初是随机行走的。但是路径上的信息素浓度会被其他 Ant 用来选择路径。也就是说,如果一只 Ant 找到了目标,它应该返回巢穴而不是终止程序?其他 Ant 如何选择信息素浓度高的路径?不能保证其他 Ant 在正确的路径上移动。
我真的很困惑。我了解简单的现实世界示例。 Ant 最初是随机移动寻找食物,如果找到食物,它会回到巢穴并再次返回,因此该路径上的信息素沉积会更高,其他 Ant 会选择该路径。
但是当我尝试实现时,它变得越来越棘手和令人困惑。我真的很感激一些简单的想法或解释。我不是在寻找代码。这就是为什么我编写伪代码而不是发布我目前完成的实际实现代码的原因。
最佳答案
蚁群优化的作用如下:
在一段时间内,最成功的路径将比不太成功的路径包含更多的信息素。
There is no guarantee that the other ants are moving in the right path!
这就是算法中随机性的要点。如果 Ant 只使用经过试验和测试的路径,那么它永远无法改进路径。使用加权随机性来选择下一个单元格的要点是,一只迷路的 Ant 可能会偶然发现比原始路径更好的路径。
关于algorithm - 蚁群优化—— Ant 的运动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23584460/
这个问题可能不是很清楚,所以让我用一个例子来说明我的意思。说我要复制几个文件夹: ... 但是我需要从如下所示的文本文件中加载它们,而不是在脚本中对这些文件夹
ant 和 ant clean all 的区别? 请任何人都可以清楚地说明何时使用 Ant 和 Ant 清洁所有。 C:> Ant c:> Ant 清理所有 最佳答案 “ant”运行项目的默认目标。
我想转换如下: 到: aoeu 的值可以包含任意数量的逗号分隔元素。 我可以使用 groovy Ant 任务,但不能使用 ant-contrib 中的任何
我看到了 this相关问题,但我的情况不同,所以再次询问。基本上,我必须按特定顺序运行 12 个 ant 文件。对于每个 ant 文件,我选择不同的目标,例如“创建”或“构建并部署全部”。如何创建一个
我可以编写一个在从另一个 ant 任务执行时获取参数的 ant 任务吗? 我通常试图实现的目标是重用现有任务不同的参数。 我不知道的是: ant中有这样的子任务吗? 它可以带参数吗? 如何以及在何处指
给定一个 ant 文件集,我需要对其执行一些类似 sed 的操作,将其压缩为多行字符串(每个文件有效一行),并将结果输出到文本文件。 我在寻找什么 Ant 任务? 最佳答案 Ant script ta
我有一个包含 jars 等绝对路径的属性文件。当使用这些属性时,它们以构建文件中指定的 basedir 为前缀。 我如何获得绝对路径? build.properties: mylib=/lib/myl
我有一个任务: someString someOtherString 如何连接 s
我遇到的情况涉及运行带有可选参数的 ant 构建,这些参数总是被指定但并不总是被定义,就像这样 ant -DBUILD_ENVIRONMENT=test -Dusername_ext= -Dconf.
我正在寻找一种在 Ant 文件中包含 .jar 的方法,以便我可以立即使用它并在我的目标中调用它的方法。 就我而言,它是 ant-contrib-1.0b3.jar . 最佳答案 最好的方法是将 An
我在 ant 方面比较新,在学校我有一个作业来做一个构建文件。我的问题之一是将其名称(或路径)作为 ant 参数的文件复制到“/foldercopy”。我需要做类似的事情: Ant cpfile文件.
亲爱的,我目前在检索foreach循环中设置的属性的值时遇到一些问题。也许你们中的一个可以帮助我... 目的是检查自从生成相应的jar之后,是否已修改文件夹的一个文件。这样,我知道是否必须再次生成ja
我想创建一个宏: 然后使用它: 但是,我想为隐式元素指定一个默认值......类似于: 所以我可以这样使用它:
我想将 ANT、JavaSDK 和 FlexSDK 包含到我的项目目录中。我需要我公司的人能够从源代码编译。 我有一个以以下内容开头的 build.bat 文件: ant blah/blah/blah
我想对目录中的每个文件使用 ant 脚本集只读 但 exec 不允许 filelist: The typ
如果我以 root 身份运行任务,有没有办法检测它是否以 root 身份运行并以不同的用户身份运行某些任务。 我有一些任务需要以 root 身份运行,但其他任务只需要以当前用户身份运行。 最佳答案 如
是否可以通过ant任务使用JUnit 4.6的新MaxCore运行程序? 最佳答案 从4.6开始,不幸的是没有。您需要创建自己的自定义Ant任务才能利用MaxCore功能。 关于ant - Ant J
我有一个关于 Ant 及其对环境变量的处理的问题。 为了说明我有一个小样本。 给定 Ant 构建文件 test.xml:
该文件如下所示: a1,b1 a2,b2 ... 我知道值“a2”。 如何将值“b2”转换为属性值。 我知道如何通过以下方式选择包含“a2”的行: 但是不知道如何将属性值设置为“b2”。 我
Ant 属性可以通过属性文件设置,从属性文件解析其他属性吗? 例如,我可以这样做: 和 prop2 变成“in_test_xml1”。那挺好的。 但在这种情况下,当使用输入属性文件时: prop1
我是一名优秀的程序员,十分优秀!