I have a network of turtles connected by links in Netlogo an I'm struggling to find a way to calculate the number of mutual links between turtles (ie if I randomly choose two turtles, how many of each of their links are connecting them to the same turtles?). Has anyone had luck with this?
With undirected links:
count ([link-neighbors] of turtle 0) with [member? turtle 1 link-neighbors]
Related
I am writing a NetLogo model to describe the food exchange interactions between pairs of bees until the food is distributed evenly among all. I have two breeds of "fulls" and "hungries" in my model. Right now I am counting the number of interactions until the model stops, like this:
ask turtles [
set neighborhood other hungries-on neighbors
set target one-of neighborhood with-min [distance myself]
ifelse target != nobody
[ exchange-food
set counter counter + 1]
;if there are no hungry neighbors continue moving and searching for one
[continue ]
]
The counter here, counts all the exchange-food interactions but I am also interested in the number of unique interactions. Does it mean that I have to keep a list of tuples as a turtle-own variable for each turtle! But I don't even need the actual ids, I just want to count the number of unique interaction. How can I keep track of this? Any simpler ideas?
My simulation is of farms. Farmer agents own the farms and farms are created from a random number of patches around the agent that then "belong to" the farmer.
Each patch owns a Rate of Production variable (random number up to 50).
How do I then assign a value to an agent-owned variable that sums the RoP for each patch in the farm and makes that the farmer's total RoP? Something like... ask farm to [ set farm-RoP ... to the sum of all patches RoP in-radius ]. I am unsure of how to create the syntax.
Thank you, in advance, for any help anyone can provide!
I have these agentsets called collectors and bins, collectors visit bins once a day (each tick is equal to one hour). But they will keep visiting the same bin on the other days.
I would like to make them on the next day to visit a random different bin, but I do not know how to ask that. Could someone help me, please.
Here is the command where I ask this command.
to search-bins-to-collect
ask one-of collectors [move-to one-of [ bins in-radius 10] of myself]
collect-waste
end
The number of collectors will vary during the year and I can not tell them the exact number of the turtle.
Thank you in advance.
Hi please could somebody write a snippet of sample code to show how I would use max-n-of nodes to control the number of incident nodes that a node has in a network? Any help would be greatly appreciated as I am new.
That's not what max-n-of does. Rather, it gives you a list of turtles (or in your case, nodes) that has the highest number of whatever reporter block you pass as parameter. The documentation for max-n-of is here.
If you want limit the number of nodes that are connected to other nodes, you will probably want to use count my-links and then not create links between nodes that have more than whatever maximum number of connected nodes you want. So ask your nodes to do something like:
to connect-nodes ;; turtle/node procedure
let potential-connections other turtles with [count my-links < the-max-connections]
if count my-links < the-max-connections and any? potential-connections [
create-link-with one-of potential-connections
]
end
I'm trying to implement a monitor in the user interface that displays the average value of a variable shared by a breed of turtles (turtles own). Does anyone know of a method of collecting all the values, adding them together and dividing by the quantity of turtles to get the value or know of an easier method?
If the variable that each turtle has is shell-size, for example, then:
print mean [shell-size] of turtles
will do it. It might be useful to know how to do this by hand, so that you can do other calculations if you want. Here's one way:
print (sum [shell-size] of turtles) / (count turtles)
Here's another
let total 0
ask turtles [set total total + shell-size]
print total / (count turtles)
Obviously, you'll want to replace the print statements with whatever suits your needs. For a monitor, you should be able to enter this code directly into the interface, or wrap it up in reporter and then use that in the monitor.