假设有一个网格包含两个墙(被阻挡的单元格)以及放置在网格上任何位置的食物.
现在假设我们正在尝试确定将蚁群放置在该网格上的最佳位置,使得蚂蚁必须行进最小距离(在任何方向上往/来自群体的起始点)以获得最大量的食物.
到目前为止,我提出的最佳方法如下:
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
Run Code Online (Sandbox Code Playgroud)
这种方法是否有效?有更有效的解决方案吗?