首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >网络标志计算从选定的点到所有方向的距离。

网络标志计算从选定的点到所有方向的距离。
EN

Stack Overflow用户
提问于 2012-11-22 19:20:56
回答 1查看 1K关注 0票数 1

我在这里看过了:示例代码 描述

带有矢量地图数据的NetLogo项目

我使用的是矢量地图,那里是道路。然后我画出道路所在的链接。从图像上看,起点是拉脱维亚的首都(里加)。左边是文斯皮尔斯市,离里加约200公里。第一是拉脱维亚/爱沙尼亚边界,也是大约200公里。底部大约有100公里。

我想要的是计算我需要在哪里放置汽车充电站。平均绿色汽车可以驾驶50公里的全电池。所以。我知道到文斯皮尔斯大约有200公里。我们需要那条路上的4个充电站。

想法1号是刚刚后每50公里从起点的地方充电站的各个方向。(图片上的树符号)。此时此刻,我正在随机放置充电站(树木):

代码语言:javascript
复制
to setup-stacijas
  set-default-shape boats "tree"
  create-boats num-boats [
    set speed 0 ; min-speed + random-float (max-speed - min-speed)
    let l one-of links
    set size 18
    set-next-stacija-link l [end1] of l
  ]
end 

to set-next-stacija-link [l n] ;; boat proc
  set cur-link l
  move-to n
  ifelse n = [end1] of l [set to-node [end2] of l] [set to-node [end1] of l]
  face to-node
end

问题:

我怎么能计算出到四面八方的距离?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-04 21:26:31

代理(补丁或海龟)可以使用距离原语与MOD操作符一起,找到50“英里”以外的其他代理。

我假设在我们的模拟中,1补丁=1英里。

我假设“链接”是连接到海龟的品种“节点”。

我假设START是一个包含“节点”的变量。

代码语言:javascript
复制
;; get all nodes that are multiples of 50 miles from start
let stations no-turtles
ask start [ set stations nodes with [ (floor distance myself) MOD 50 = 0 ]

这并不完美,原因很多。

  • 它假设所有的链接是一个单位或更短的。
  • 在50英里的弧线上行驶或沿着弧线行驶的道路都将被包括在内,因此它们都将设有车站。
  • 还有一些我没想过的奇怪的事情。

其他一些迭代方法也表明了自己:

  1. 在公路上设置“旅行者”,每50英里左右就“放下”充电站。
代码语言:javascript
复制
- At intersections, traveler splits into new travelers to travel each branch
- when traveler meets a traveler, if the total distance from each traveler to its last "station" is more than 50 miles, a station is created. In any case, both travelers die.
- when a traveler finds an existing station, it dies.

这样,在所有的道路上都会放置车站。

  1. 在方圆25英里或更远的范围内,用六角网格填充这些区域。让他们迁徙吧。
代码语言:javascript
复制
- Make the stations not on roads move toward the nearest road.
- One all stations have found a road, make stations move away from stations < 50 miles away, moving along roads (break tie by moving away from center of map).
- stations that hit the edge will "fall off" (die)
- so, stations will space themselves out, and extra staions will fall off the edges of map.

这可能真的能行。

  1. 有车站,然后销毁,直到只有足够的
代码语言:javascript
复制
- Create a station on every mile of road.
- pick one station
- ## ask all other stations in 49 mile radius to die - mark it
- pick one of the stations 50 miles away.
- repeat from ## unil all stations are marked.

这个可能不是最理想的。

  1. 在你的道路上模拟汽车--在它们死亡的地方建立车站。
代码语言:javascript
复制
- Put cars randomly on your roads (starting from cities). Cars can travel about 50 miles before needing recharge (dying)
- there are no stations
- simulate cars driving randomly on the roads.
- when a car hits a station it recharges fully
- if a car runs out of charge, it dies, and the counter for that patch/node/location is increased
- repeat
- when the counter in a patch exceeds some value, put a station there.
- when a station is created, the counters for all patches in a 50 mile radius are reduced--to 0 nearest the station, and by 0 furthest, in a gradular fashion.

最终,电台会在需要的地方突然出现。看这个会很有趣的。

~~詹姆斯

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13518899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档