我正在尝试模拟一个简单生物体的分化模式。这就是我希望我的品种和变量发挥作用的方式:
品种:植物体和异形体。
植物体可以分裂,异形体不能。植物体可以变成异形体。理想情况下,异形体一旦形成,植物离它越近,它反过来成为异形体的可能性就越小。
变量:
age
:每蜱+ 1,- 1 对于新孵化的海龟
bump
:一种将位于新孵化海龟'前方'的所有海龟移开的方法,这样它们就不会重叠。我想象这个系统有点像牛顿摇篮
pro
:发起人。部分随机累积。一旦达到一定值('浓度'),植物体就会改变品种,成为异形体。价值减少了inh
。
proL
:值 pro
的标签,带有舍入值。
inh
:抑制剂。理想情况下,这个值应该形成一个“梯度”(在异形体附近的海龟中最高,在远处最低)。
我看到的明显问题是我得到了很多连续的异形体。这正是我一直试图避免的。但我看不出出了什么问题......请帮忙?
to setup
clear-all
setup-turtles
reset-ticks
ask turtles [ set size 1 ]
end
to setup-turtles
create-vegetatives 1
ask turtles [
setxy random-xcor random-ycor
set shape "circle"
set color 65]
end
to go
divide
add-age
move
differentiate
tick
end
turtles-own [age
bump
inh
pro
proL]
breed [vegetatives vegetative]
breed [heterocysts heterocyst]
to add-age
ask turtles [
set age age + 1
ifelse show-age?
[ set label age ]
[ set label "" ]
]
end
to divide
ask vegetatives [
if random 100 < 2 [
hatch 1[
set bump 1
set age age - 1
set inh 0
]
]]
end
;;Trying to get only one turtle per patch, making the others move
to move
ask turtles[
while [bump = 1] [
ifelse not any? turtles-on patch-right-and-ahead 180 1[
rt 180
fd 1
set bump 0
if any? other turtles-here[
ask other turtles-here
[set bump 1]
]
]
[fd 1
set bump 0
if any? other turtles-here[
ask other turtles-here[
set bump 1]
]
]
]]
end
to differentiate
ask turtles[
set pro (pro - inh + (random 2))
set proL round pro
ifelse show-proL?
[ set label proL ]
[ set label "" ]
create-links-with other turtles-on patch-ahead 1
create-links-with other turtles-on patch-right-and-ahead 180 1
if breed = vegetatives [
if any? link-neighbors[
ifelse any? link-neighbors with [breed = heterocysts]
[]
[set inh mean [inh] of link-neighbors]
]
if any? vegetatives with [pro > 50]
[ask vegetatives with [pro > 50]
[set breed heterocysts
set color brown
set shape "circle"
if any? link-neighbors[
ask link-neighbors with [breed != heterocysts]
[set inh 2]]
]]
]]
clear-links
end
问:
“(...)出了什么问题...”(?)
代码很快创建了一对
heterocysts
,其 pro
值远高于 '浓度'-treshold,如快照所示:
使用手动检查,与预期行为明显不一致,我们将进一步讨论。
怎么回事,尽管编码程序
[ bump = 1 ]
包含to-move
的指令,仍然有231个特工有ask turtles [ while ( bump = 1 ) [ ... ] ... ]
?
我们在这里 - ABM 模拟有时被声称是并行工作的,而在这里我们却陷入了残酷的反模式。由于接下来的命令会修改
others
的状态(即不仅明确地修改自身状态,还修改邻居状态),我们不能认为这是并行的(因为依赖关系、相互依赖关系存在,代理不再相互独立,因此并发,如果不并行,操作会陷入与并发相关的冲突,并让许多代理设置 [ bump = 1 ]
,作为并发(而不是并行)相关相互依赖性证据的自我表现。
重复运行证明,问题在于依赖基于
while [ bump = 1 ]
的逻辑的概念,该概念在实际的、同时相互修改的生态系统中并不成立,正如编码那样 - 因为仍然有超过 771 个代理仍然保留着 [ bump = 1 ]
通过稍微调整逻辑,我们最终确实继续移动所有代理,直到没有标记
[ bump = 1 ]
保持在原位,如 observer 报告零所示:
然而,该实验的总体目标是在运动逻辑方面得到进一步磨练,而可修复的间隙现在已发挥作用。
breed [ vegetatives vegetative ]
breed [ heterocysts heterocyst ]
globals[show-age? show-proL?] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; a head-less fix
turtles-own [ age
bump
inh
pro
proL
]
to setup
clear-all
set show-age? true ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; a head-less fix
set show-proL? true ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; a head-less fix
setup-turtles
reset-ticks
ask turtles
[ set size 1 ]
end
to setup-turtles
create-vegetatives 1
ask turtles
[ setxy random-xcor random-ycor
set shape "circle"
set color 65
]
end
to go
divide
add-age
move
differentiate
tick
end
to divide
ask vegetatives
[ if random 100 < 2
[ hatch 1 [ set bump 1
set age ( age - 1 )
set inh 0
]
]
]
end
to add-age
ask turtles
[ set age ( age + 1 )
set label report-state
]
end
;;; Trying to get only one turtle per patch,
to move ;;; making the others move
while [ any? turtles with [ bump = 1 ] ]
[ ask turtles with [ bump = 1 ]
[ ifelse not any? turtles-on patch-right-and-ahead 180 1
[ rt 180
fd 1
set bump 0
if any? other turtles-here
[ ask other turtles-here
[ set bump 1 ]
]
]
[ fd 1
set bump 0
if any? other turtles-here
[ ask other turtles-here
[ set bump 1 ]
]
]
]
]
end
to differentiate
ask turtles
[ set pro ( pro - inh + ( random 2 ) )
set proL round pro
set label report-state
create-links-with other turtles-on patch-ahead 1
create-links-with other turtles-on patch-right-and-ahead 180 1
if breed = vegetatives
[ if any? link-neighbors
[ ifelse any? link-neighbors with [ breed = heterocysts ] ;;; if not any? ... [ cmds ... ]
[ ]
[ set inh mean [ inh ] of link-neighbors ]
]
if any? vegetatives with [ pro > 50 ]
[ ask vegetatives with [ pro > 50 ]
[ set breed heterocysts
set color brown
set shape "circle"
if any? link-neighbors
[ ask link-neighbors with [ breed != heterocysts ]
[ set inh 2 ]
]
]
]
]
]
clear-links
end
to-report
report-state
report ( sentence report-age
report-proL )
end
to-report
report-age
ifelse show-age?
[ report sentence "A: " age ]
[ report "" ]
end
to-report
report-proL
ifelse show-proL?
[ report sentence "P: " proL ]
[ report "" ]
end