【问题标题】:Netlogo: calculate time using distance traveled and speedNetlogo:使用行驶距离和速度计算时间
【发布时间】:2016-03-16 18:37:42
【问题描述】:

我有一个模型,我想测量乌龟以给定速度从一个点移动到另一个点所需的时间,使用地图的比例和速度/fd 移动来量化经过的实时时间。

我将所有船只的速度设置为一个随机数(UI 上的全局变量输入),并为每个海龟设置一个带有路径坐标的列表。我使用 time = distance / speed 的公式,但无法弄清楚如何准确计算时间。

速度设置为 30 左右的数字,我想将其用作 km/h。地图的比例是每个补丁 1000 米 x 1000 米,所以我尝试使用 1000 的因子来修复计算无济于事。以下是我对时间的计算。

        to move
          tick
          ask ships with [length current-path != 0] 
              [ 
                let x1 xcor
                let x2 [pxcor] of first current-path 
                let y1 ycor
                let y2 [pycor] of first current-path 
                let distance-traveled sqrt ((x2 - x1)^ 2 + (y2 - y1)^ 2)

                set time ((distance-traveled * meters-per-patch) / (speed) 
                set timelist lput time timelist
                set totaltime sum timelist
                go-to-next-patch-in-current-path 
              ] 
          end

这种药水调用运动。我正在划分速度/1000,因为速度的数字是 10,我希望海龟每个刻度移动的距离远少于 1 个补丁,以使其直接降落在列表中的补丁坐标上。

to go-to-next-patch-in-current-path  

      face first current-path
      ifelse distance first current-path < .1
        [
          move-to first current-path
          set current-path remove-item 0 current-path
        ]
        [
          fd speed / 1000
          set heading towards first current-path
        ]


    end

任何帮助将不胜感激,非常感谢。

【问题讨论】:

    标签: time netlogo agent


    【解决方案1】:

    无论如何。如果你想让某人从 x1,y1 移动到 x2,y2。您需要计算到 x2 y2 的距离。假设您希望从 x1,y1 移动到 x2,y2 需要 4 秒

    对于乌龟:

    在您设置或到达 x1,y1 时

    let t 3
    let d distancexy x2 y2
    let velocity d / t
    facexy x2 y2
    

    当你不在 x2,y2 时

    fd velocity
    

    我认为您的问题在于每次迭代都在重新计算速度。你是说如果你在 5 米之外,想要花 5 秒钟,移动 1 米。然后在下一个时间单元中,你将在 4 米外,想要花 5 秒,移动 0.8 米。等等

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-04
      • 1970-01-01
      • 1970-01-01
      • 2015-05-11
      相关资源
      最近更新 更多