在我的研究中,我正在尝试建立一个代表真实工作环境的模拟,旨在创造有关如何让人们在工作中感觉更好的知识。 特别是,我正在建模一个人们为多个团队工作的场景(你一次只处理一个项目吗?很多人不......)。为此,我正在使用NetLogo。
我遇到了自定义链接龟集的特定代理的ASK问题。关键是有时它会报告一个错误,说“ASK预期输入是一个代理或代理集,但却得到NOBODY”,但它不应该在没有代理存在的情况下到达那个“ASK”!我做错了什么?
该功能如下:
to TeamRecruiting
;; I ask non-complete teams to...
ask teams with [ teamsize != (count membership-neighbors) ]
[
;; ... count how many individuals they have...
let actualteammembers count membership-neighbors
;; ... to save locally how many individuals they can share...
let teamoverlap overlap
;; ... their target size...
let neededsize teamsize
;; ... and their identity.
let teamwho who
;; then I ask those individuals that have not yet more things than they can handle...
ask individuals with [ indMTM != (count membership-neighbors) ]
[
;; ... to save locally who they are...
let indwho who
let createdalink 0
;; ... then if some conditions have been met ...
if(some conditions)
[
;; I create a link (of my specific type) with the team...
create-membership-with team teamwho
;; I do the following because more than one individual could join the team teamwho in the same run of the function
ask team teamwho [ set actualteammembers (actualteammembers + 1) ]
set createdalink 1
]
;; if the association occurred, ...
if(createdalink = 1)
[
;; we ask all other teams to evaluate if the new connection violates their maximum overlap constraint between the team I am considering from the beginning of the function, and all other teams, in other words...
ask teams with [ who != teamwho ]
[
let numpaths 0
let team2who who
;; I count how many individuals say that they are shared by the two teams
ask individuals
[
if((membership-neighbor? team teamwho) and (membership-neighbor? team team2who)) [ set numpaths (numpaths + 1) ]
]
;; ... and if the number of paths is more than the maximum allowed overlap...
if(numpaths > teamoverlap)
[
;; I take the connection away...
ask membership teamwho indwho [ die ]
;; and I reduce the actual number of team members
set actualteammembers (actualteammembers - 1)
]
]
]
]
]
end
感谢您的宝贵帮助!
答案 0 :(得分:0)
我认为这个问题可能与您提到要求死亡的链接有关。 membership
是无向链接,因此代理为end1
且end2
取决于代理的创建顺序。编号较低的编号为end1
,另一编号为end2
。因此,如果团队代理是在单个代理之后创建的,那么该特定链接将是membership indwho teamwho
。一般来说,使用谁的数字是不好的做法,但如果你使用团队和个人代理本身而不是他们的数字,就会出现同样的问题。
在使用无向链接方面有更多经验的人,如果你不知道哪个代理人年龄较大,可能会更好地建议如何轻松引用无向链接,但是
ifelse (indwho < teamwho) [
ask membership indwho teamwho [ die ]
]
[
ask membership teamwho indwho [ die ]
]
应该有效。使用有向链接可以避免此问题,因为创建者代理始终是end1而目标代理是end2。因此,如果会员链接始终由个人创建,那么您将始终知道该个人位于end1。
希望这会有所帮助。 查尔斯