Netlogo:在netlogo的两个不同时刻比较一只乌龟的变量

时间:2016-06-24 08:29:47

标签: netlogo

我在Netlogo中编写模拟,我需要在两个不同的时刻t和(t-1)比较变量值(特定乌龟),你能给我一个建议吗?

2 个答案:

答案 0 :(得分:2)

您需要存储滞后值(例如,在turtle属性中)。例如,

turtles-own [x xlag]

to setup
  ca
  crt 1 [set x random-float 1.0]
end

to go
  ask turtles [set xlag x]  
  ask turtles [set x random-float 1.0]
  ask turtle 0 [show x - xlag]
end

答案 1 :(得分:0)

@Alan:感谢您的建议,我不确定我理解您的答案,我试图模拟公司招聘或不招聘一些员工的决定;以下是我使用您的建议制作的代码:

firms-own [ 
  number-emplyed-now  number-employed-previously
  salary-offers
  ]

households-own[
  desired-salary]

to setup
  create-firms 1
  set [ number-emplyed-now floor( turnover / salary-offers) ]
end

to go
  ask firms [ set number-employed-previously number-emplyed-now ]
  ask firms [ set number-emplyed-now floor( turnover / salary-offers)]
  ask firms [
    If number-emplyed-previously < number-employed-now
    [ask households with desired-salary < salary-offers 
      n-of (number-employed-now - number-emplyed-previously)
      set color red ]
  ]
end