I'm working on a simulation of social behavior in an emergency situation, using anonymized data from an actual event. Below is the section of code I'm using to create the 'people' turtles.
to read-people-from-file [filename]
let rows bf csv:from-file filename
foreach rows
[[row] ->
create-people 1
[
set size .46
setxy (item 0 row) (item 1 row)
set age (item 2 row)
set gender (item 3 row)
set visited? (item 4 row)
set group-number (item 6 row)
set group-type (item 7 row)
if group-number < 300 and ((person group-number) = (other group-number))) [create-links-with other person]
]
]
end
Everything works except for the group-number based links. I've tried a few different variations of it, with no luck except where I attempted if group-number <300 [create-links-with other people
which worked creating links but was functionally useless. What I'm trying to do is set it so that every person who came together (who has the same group number) has a link with other group members. It's specifically less than 300 because numbers 300 and above are for people who came alone or other designations.
I could theoretically create the links by hand after the turtles are created, but that seems both like a waste of time (I have a dataset of over 400) and like something that makes the code significantly less applicable to other scenarios.
How do I make Netlogo create links between members of the same group, based on what's in the CSV?
Actually, the dream answer: how do I make Netlogo create different breeds of links (based on group-type) between members of the same group-number, based on what's in the CSV?
Edit: In the end, I had to separate creating links from the initial agent setup. This was what worked:
to soclink ;;groups that came together have links based type of relationship
ask people [if group-number < 300
[
if group-type = 1 [ask other people with [group-number = [group-number] of myself] [create-coworker-with myself]]
if group-type = 2 [ask other people with [group-number = [group-number] of myself] [create-friend-with myself]]
if group-type = 3 [ask other people with [group-number = [group-number] of myself] [create-partner-with myself]]
if group-type = 4 [ask other people with [group-number = [group-number] of myself] [create-family-with myself]]
if group-type = 5 [ask other people with [group-number = [group-number] of myself] [create-multiple-with myself]]
show count links]]
end