我正在尝试开发一个模型来模拟终端区的空中交通流量。由于之前每个人的帮助,我已经取得了一些进展。现在,我想使每架飞机之间保持适当的间隔。随着间隔的减小,将要求飞机先减速以保持间隔。当彼此之间的间隔太小时,将要求飞机离开飞机,直到清理出该区域。根据我目前的进展情况,飞机能够适当减速以保持间隔,但是无法将它们赶出飞机。
在代码中,当间隔小于0.5时,我要求飞机转弯并变红。而且当他周围没有飞机时(半径1.5),飞机将转回原处。现在飞机可以变红了,但是没有任何动作可以朝我指定的方向前进。我怀疑我没有正确设置本地运动,因此该程序将“着陆程序”和“冲突解决方案绕道”混合在一起。有解决这个问题的建议吗?还是实现此功能的更好方法?期待有见地的答复。
to go
ask aircrafts [let blocking-aircrafts other aircrafts in-cone 1 270
let blocking-aircraft min-one-of blocking-aircrafts [ distance myself ]
ask aircrafts [ifelse blocking-aircraft != nobody [ conflict-resolution ] [landing-procedure]]]
end
我要求系统根据间隔来定义首先使用哪个程序。
to landing-procedure
ask aircrafts
[if route02? [face star 2 fd airspeed ]]
end
我设置了route02来定义飞机在常规飞行路线上的移动方式。
to conflict-resolution
conflict-resolution-detour
conflict-resolution-deceleration
end
to conflict-resolution-deceleration
let blocking-aircrafts other aircrafts in-cone 1.2 180
let blocking-aircraft min-one-of blocking-aircrafts [ distance myself ]
ask aircrafts-here [if blocking-aircraft != nobody
[ if route02? [fd airspeed - 0.000000075 if airspeed = [airspeed] of blocking-aircraft [set airspeed [airspeed] of blocking-aircraft]]]]
end
to conflict-resolution-detour
let blocking-aircrafts other aircrafts in-cone 0.5 180
let blocking-aircraft min-one-of blocking-aircrafts [ distance myself ]
let truningback-ornots other aircrafts in-radius 1.2
let truningback-ornot min-one-of truningback-ornots [ distance myself ]
ask aircrafts-here [ if blocking-aircraft != nobody
[ if route02? [ ifelse truningback-ornot != nobody [set heading 45 fd airspeed set color red] [set heading 315 fd airspeed set color black ]]]]
end
我要求飞机继续向外移动,直到周围没有飞机。