NetLogo rnd:weighted-n-of by turtle 变量
NetLogo rnd:weighted-n-of by turtle variable
我正在尝试创建一个生成器,该生成器使用(已更正的)Barabasi-Albert 算法来生成 NetLogo 中的优先连接网络。有两个参数:(最终)节点数和每个节点添加的边数。网络扩展有一个版本,但仅限于每个节点添加1条边的情况。
简化的完整模型:
extensions [rnd]
to makeNW-BA
clear-all
let new-edges 4
let popn 25
create-turtles new-edges [ setxy random-xcor random-ycor ]
ask turtles [ create-links-with other turtles with [not link-neighbor? myself] ]
repeat popn - count turtles
[ let targets rnd:weighted-n-of new-edges turtles [ count my-links ]
create-turtles 1
[ setxy random-xcor random-ycor
create-links-with targets
]
]
end
行 let targets rnd:weighted-n-of degree turtles [ count my-links ]
正在创建一个 java 错误 (ClassCastException) while observer running _asm_proceduremakenwba_setprocedurevariable_11
。这是我第一次使用 rnd
扩展,所以我不知道问题是我的编码问题,还是实际上有一个错误导致 java 错误。
更新
我现在已经为度数设置了一个海龟自己的变量(即计算我的链接)并尝试做 let targets rnd:weighted-n-of new-edges turtles [ degree ]
。这让我得到了一个 NetLogo 错误,即 the observer can't access a turtle variable without specifying which turtle
。但是,尝试添加 of self
没有帮助。
这会产生所需的网络吗?
let targets rnd:weighted-n-of new-edges turtles [ [count my-links] of ? ]
new-eges 设置为 4 时,我很难注意到它。当我将它设置为 1 时,它似乎是一个优先附件网络。
看起来(让上帝的声音不同意我)[rnd:weighted-n-of] 被设计为与列表一起工作,并且其中有一个隐藏的 foreach 或 map 导致它在给定代理集时在转换时出错。
我正在尝试创建一个生成器,该生成器使用(已更正的)Barabasi-Albert 算法来生成 NetLogo 中的优先连接网络。有两个参数:(最终)节点数和每个节点添加的边数。网络扩展有一个版本,但仅限于每个节点添加1条边的情况。
简化的完整模型:
extensions [rnd]
to makeNW-BA
clear-all
let new-edges 4
let popn 25
create-turtles new-edges [ setxy random-xcor random-ycor ]
ask turtles [ create-links-with other turtles with [not link-neighbor? myself] ]
repeat popn - count turtles
[ let targets rnd:weighted-n-of new-edges turtles [ count my-links ]
create-turtles 1
[ setxy random-xcor random-ycor
create-links-with targets
]
]
end
行 let targets rnd:weighted-n-of degree turtles [ count my-links ]
正在创建一个 java 错误 (ClassCastException) while observer running _asm_proceduremakenwba_setprocedurevariable_11
。这是我第一次使用 rnd
扩展,所以我不知道问题是我的编码问题,还是实际上有一个错误导致 java 错误。
更新
我现在已经为度数设置了一个海龟自己的变量(即计算我的链接)并尝试做 let targets rnd:weighted-n-of new-edges turtles [ degree ]
。这让我得到了一个 NetLogo 错误,即 the observer can't access a turtle variable without specifying which turtle
。但是,尝试添加 of self
没有帮助。
这会产生所需的网络吗?
let targets rnd:weighted-n-of new-edges turtles [ [count my-links] of ? ]
new-eges 设置为 4 时,我很难注意到它。当我将它设置为 1 时,它似乎是一个优先附件网络。 看起来(让上帝的声音不同意我)[rnd:weighted-n-of] 被设计为与列表一起工作,并且其中有一个隐藏的 foreach 或 map 导致它在给定代理集时在转换时出错。