SLuke
SLuke

Reputation: 115

netlogo Hatched turtles using parent variable value in calculation

I have two breeds (workplaces and workers). I've made 3 workplaces and they each hatch 100 workers. I use hatching to be able to assign some features of the workplace to the workers. Specifically, I want to assign Size-Of-Location, which is different for each of the workplaces, to the workers and then use that in calculating something for each worker. The result will differ across workers even in the same workplace but the common variable is also important to that calculation. So, for example, after setting up two breeds--workplaces and workers, I have tried variations on:

hatch-workers 100 [ move-to one-of patches
  create-size-of-location-to myself
. . . ]

and I've also tried many other variants, including using links instead. The one above is my 20th iteration of the code, and I confess it may look completely brain dead because I am getting more and more confused with each failure.

I can't use proximity to the workplace because the workers are located in residences everywhere, not necessarily close to their workplace. I've read in various places (e.g., Railsback & Grimm) that hatched entities take the characteristics of the parent, but my inspection of my workers doesn't confirm that, and when I try to use the parent variable I only get errors.

I believe the ability to use parents' information in "kids" calculation is a likely common need. Yet, I searched StackOverflow and other netlogo help sites, the netlogo manual, and several books, and if a discussion of this is present I have been unable to find it. Thus, I am stumped at this point. Any helpful suggestions are greatly appreciated!

Thanks! SLuke

Upvotes: 3

Views: 696

Answers (1)

King-Ink
King-Ink

Reputation: 2096

The scheme I use if I need to refer to the parents variables is When creating the children I include.

 set parent myself

then when I need to use a parent variable I use

[name-of-variable] of parent 

for the set of sisters

set sisters turtles with [parent = [parent] of myself]

for the set of children

set children turtles with [parent = myself]

Upvotes: 3

Related Questions