Determining the radius of turtle clusters and numb

2019-07-27 04:40发布

If I have a situation in which about a 1000 black turtles disperse at random angles and steps throughout the netlogo world for a given duration of ticks. Each turtle is assigned a random probability at each timestep during dispersal, and if this number exceeds a given threshold for any given turtle it changes it's color to red and stops moving. Additionally, black turtles (still moving) that happen to move within a patch of red turtles (stopped/settled), change their color to grey and settle (stop moving) as well. Finally, other black turtles (still moving) that happen to be move within a patch of either grey or red turtles (stopped/settled), also change their color to grey and settle (stop moving)

My question is a post-processing question for when the simulation duration is reached. How do I determine the number of clusters of red-grey turtles in the sea of black turtles? Also, how do I determine the size (radial extent) of each cluster? And finally, how do I determine the number of turtles in each cluster?

标签: netlogo
1条回答
劫难
2楼-- · 2019-07-27 05:05

Jen is right: you need a clear idea of what constitutes a cluster before being able to truly answer that question.

That being said, one possible option is to use a clustering algorithm. I'd suggest taking a look at Christopher Frantz's dbscan extension.

Here is a quickly thrown together example:

extensions [ dbscan ]

to setup
  clear-all
  ask patches [ set pcolor white ]
  create-turtles 1000 [
    set color black
    set label-color blue
    setxy random-xcor random-ycor
  ]
  ask n-of 5 turtles [
    ask turtles in-radius 3 [
      set color one-of [red grey]
    ]
  ]
end

to find-clusters
  let red-grey-turtles turtles with [ member? color [red grey] ]
  let clusters dbscan:cluster-by-location red-grey-turtles 3 3
  (foreach clusters range length clusters [ [c i] ->
    foreach c [ t ->
      ask t [ set label i ]
    ]
  ])
end

Sorry for the lack of further explanations: I have a plane to catch...

查看更多
登录 后发表回答