如何在NetLogo中同时运行几个程序? [英] How to run several procedures simultaneously in NetLogo?

查看:177
本文介绍了如何在NetLogo中同时运行几个程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的模型中有不同颜色的海龟,每个海龟都在不同的规则下运行。我希望管理一只乌龟(例如,红乌龟)运动的程序与控制不同颜色的乌龟运动的其他程序同时运行。

There are different colored turtles in my model each operating under different rules. I want procedures governing the movement of one turtle(say, red turtle) to run simultaneously with other procedures governing the movement of different colored turtles.

推荐答案

假设您有两个乌龟程序 do-red do-blue 您要在红色和蓝色乌龟上运行。然后,您可以询问海龟[做某事] 并根据颜色进行调节。假设您没有更改颜色:

Suppose you have two turtle procedures do-red and do-blue that you want to run on red and blue turtles. Then you can just ask turtles [do-something] and condition on the color. Assuming you are not changing the colors:

to do-something  ;; turtle proc
  if (color = red) [do-red]
  if (color = blue) [do-blue]
end

编辑:

这并不能提供真正的并发性,但是严重的是,代理行为多长时间才能真正并发?例如,如果 do-red 影响其他乌龟(红色或蓝色),则 turtle 0 乌龟1 都影响乌龟2 ,它们只对个人的影响做出反应。再举一个例子,如果您希望每只乌龟都选择一个空置的斑块移动,而两只选择相同的斑块,谁会获胜呢?这就是为什么 update-state 解决方案不能解决一般的并发问题的原因。当然,对于某些问题它仍然至关重要。 (例如,加利福尼亚州)。

This does not provide true concurrency, but seriously, how often can agent behavior be truly concurrent? For example, if do-red affects other turtles (red or blue), what is the "concurrent" outcome when turtle 0 and turtle 1 both influence turtle 2, who responds only to individual influences. To give another example, if you want every turtle to choose an unoccupied patch to move to, and two choose the same patch, who wins? The is why update-state solutions cannot address the general problem of concurrency. Of course, it is still crucial for some problems. (E.g., CA.)

这篇关于如何在NetLogo中同时运行几个程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆