Family tree for the Population & Cemetery Simulator

30 views
Skip to first unread message

Andreas Duering

unread,
Mar 11, 2014, 12:15:18 PM3/11/14
to modell...@googlegroups.com
Dear all,

I would like to visualize the maternal line in the Population & Cemetery Simulator by using the Preferential Attachment model (in the NetLogo library).
To position each child in a circle around their mothers I must define the specific mother of the individual as the node.
How could I do that?
a) Each agent has a specific number in the system, however, this number does not give any information about the agent's generation/ancestry.
b) Numbering each female according to her maternal line, generation & number of children creates enormous names after a few generations. Although this might be interesting from an analytical point of view I think that I need another solution.
c) Is there an inbuilt link between reproducing agents and offspring which I could use?

Thank you and all best
Andreas



Ken Kahn

unread,
Mar 12, 2014, 4:00:03 AM3/12/14
to Modelling4All
Hi.

I think c) is the way to go.

In the Linking section of the main library there are two micro-behaviours:

Add a directed link from another.
Add a directed link to another.

You can use which ever is more convenient. The tricky part is to have, for example, the 'Add a directed link to another' behaviour on the mother refer to the newly born agent. Perhaps it is easier for the newly created agent to use 'Add a directed link from another' to refer to the mother that spawned him/her.

Once you have the links in place the 'Lay out a set of agents where the agents repel each other and the links between them act like springs' behaviour can move the agents around to make a nice looking tree.

Give it a try and if you have problems or questions don't hesitate to ask. Or maybe there will be time during the class this afternoon to show you the basic idea.

Best,

-ken


--
You received this message because you are subscribed to the Google Groups "The Modelling4All project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modelling4al...@googlegroups.com.
To post to this group, send email to modell...@googlegroups.com.
Visit this group at http://groups.google.com/group/modelling4all.
For more options, visit https://groups.google.com/d/optout.

Andreas Duering

unread,
Mar 12, 2014, 4:20:19 AM3/12/14
to modell...@googlegroups.com
Dear Ken,

Thank you. I have already played with the add a directed link from/to behaviors. But how do I identify the female that spawned the newly created agent?

See you this afternoon,
Andreas

Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-12 8:00 GMT+00:00 Ken Kahn <toon...@gmail.com>:
Hi.

I think c) is the way to go.

In the Linking section of the main library there are two micro-behaviours:

Add a directed link from another.
Add a directed link to another.

You can use which ever is more convenient. The tricky part is to have, for example, the 'Add a directed link to another' behaviour on the mother refer to the newly born agent. Perhaps it is easier for the newly created agent to use 'Add a directed link from another' to refer to the mother that spawned him/her.

Once you have the links in place the 'Lay out a set of agents where the agents repel each other and the links between them act like springs' behaviour can move the agents around to make a nice looking tree.

Give it a try and if you have problems or questions don't hesitate to ask. Or maybe there will be time during the class this afternoon to show you the basic idea.

Best,

-ken
On 11 March 2014 16:15, Andreas Duering <andreas...@stx.ox.ac.uk> wrote:

--
You received this message because you are subscribed to the Google Groups "The Modelling4All project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modelling4al...@googlegroups.com.
To post to this group, send email to modell...@googlegroups.com.
Visit this group at http://groups.google.com/group/modelling4all.
For more options, visit https://groups.google.com/d/optout.

Ken Kahn

unread,
Mar 12, 2014, 4:22:35 AM3/12/14
to Modelling4All
Hi.

Yes, it is tricky. I experimented with using 'myself' in this example http://m.modelling4all.org/m/?frozen=gHJKoK9GK7wS7Efy0Wqa44&MforAllModel=1

It seems to work. Myself here will refer to the mother. See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#myself

Best,

-ken

Andreas Duering

unread,
Mar 12, 2014, 4:34:24 AM3/12/14
to modell...@googlegroups.com
Dear Ken,

Great! I will try to implement it in the existing model.

Thank you!
Best
Andreas

Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-12 8:22 GMT+00:00 Ken Kahn <toon...@gmail.com>:
Hi.

Yes, it is tricky. I experimented with using 'myself' in this example http://m.modelling4all.org/m/?frozen=gHJKoK9GK7wS7Efy0Wqa44&MforAllModel=1

It seems to work. Myself here will refer to the mother. See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#myself

Best,

-ken
On 12 March 2014 08:20, Andreas Duering <andreasdu...@gmail.com> wrote:

howard...@gmail.com

unread,
Mar 12, 2014, 4:43:24 AM3/12/14
to Ken Kahn, Modelling4All
Hi Andreas, could you seed a population of agents with names/ ids, and then have each agent store values for attributes like mother-of, brother-of...then construct familial links accordingly. I guess there's a data structure that captures all relationship possibilities for ancestry you could use.

Sent from me mobile, aiiiit.

Ken Kahn

unread,
Mar 12, 2014, 4:57:48 AM3/12/14
to howard...@gmail.com, Modelling4All
I generally think it is better to compute relationships when possible. E.g. brother is via parent link to child link that has attribute 'male'.

Note that if this isn't time critical code in NetLogo you can avoid parent links by using objects with [member? self out-links] (or something close to that). Then out-links are all from parent to child.

Best,

-ken

Andreas Duering

unread,
Mar 12, 2014, 5:28:08 AM3/12/14
to modell...@googlegroups.com
Dear Ken & Howard,

generally I managed to implement Ken's suggestions:

http://m.modelling4all.org/m/?frozen=K8EwNeorLIaeqQmfmN_X6h&MforAllModel=1

The next step is to work with the interface, e.g. repel agents from the edges.


The picture already tells me a lot about family structure etc. but the "family tree" is still only a visual thing. To actually analyse it I must store and sort kinship data/computed kinship data.

I also have not decided yet if I only want to draw the living population's links or if the little ghosts should not lose their links.


Thank you for all the suggestions. I will play around with the options now.


Howard, concerning the naming of family trees: 

The actual naming according to kinship is easy in the first few generations. However, after a few generations the names of the children become gigantic.

For example I could create a starter generation of females and give them a random no to represent the original maternal lines.

Then I could give each of their children a number representing the generation (counting up from mother to child to grandchild...).

Then I could number the children per mother (which the code is already recording to calculate average fertility).

But then some brothers and sisters will have exactly the same name after generation no 2.


Best

Andreas


Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-12 8:57 GMT+00:00 Ken Kahn <toon...@gmail.com>:
I generally think it is better to compute relationships when possible. E.g. brother is via parent link to child link that has attribute 'male'.

Note that if this isn't time critical code in NetLogo you can avoid parent links by using objects with [member? self out-links] (or something close to that). Then out-links are all from parent to child.

Best,

-ken

Andreas Duering

unread,
Mar 12, 2014, 7:14:21 AM3/12/14
to modell...@googlegroups.com
Hi,

I have changed a few things and still the agents cluster at the edges.
Why can't I change the world's settings, e.g. to wrap around at the edges, when the model is running the lay out ... behavior?
When I deactivate the lay out springs and just have the agents wander around they wrap around at the edges of the world.

http://m.modelling4all.org/m/?frozen=uRSqSuOQSCXiBjDuWLhA56&MforAllModel=1

Thank you,
Andreas

Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-12 9:28 GMT+00:00 Andreas Duering <andreasdu...@gmail.com>:
Dear Ken & Howard,

generally I managed to implement Ken's suggestions:

http://m.modelling4all.org/m/?frozen=K8EwNeorLIaeqQmfmN_X6h&MforAllModel=1

The next step is to work with the interface, e.g. repel agents from the edges.


The picture already tells me a lot about family structure etc. but the "family tree" is still only a visual thing. To actually analyse it I must store and sort kinship data/computed kinship data.

I also have not decided yet if I only want to draw the living population's links or if the little ghosts should not lose their links.


Thank you for all the suggestions. I will play around with the options now.


Howard, concerning the naming of family trees: 

The actual naming according to kinship is easy in the first few generations. However, after a few generations the names of the children become gigantic.

For example I could create a starter generation of females and give them a random no to represent the original maternal lines.

Then I could give each of their children a number representing the generation (counting up from mother to child to grandchild...).

Then I could number the children per mother (which the code is already recording to calculate average fertility).

But then some brothers and sisters will have exactly the same name after generation no 2.


Best

Andreas


Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-12 8:57 GMT+00:00 Ken Kahn <toon...@gmail.com>:
I generally think it is better to compute relationships when possible. E.g. brother is via parent link to child link that has attribute 'male'.

Note that if this isn't time critical code in NetLogo you can avoid parent links by using objects with [member? self out-links] (or something close to that). Then out-links are all from parent to child.

Best,

-ken

Howard Noble

unread,
Mar 12, 2014, 10:04:01 AM3/12/14
to modell...@googlegroups.com
Hi Andreas, you can change the wrapping of the world by adding "Change the world geometry" behaviour.
see you in a bit

Andreas Duering

unread,
Mar 12, 2014, 10:24:19 AM3/12/14
to modell...@googlegroups.com
Yes, I know. But that does not do anything when the lay out linked agents behaviour is activated. Then there will be an edge and the world does not wrap even if the geometry is changed.

Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-12 14:04 GMT+00:00 Howard Noble <howard...@gmail.com>:
Hi Andreas, you can change the wrapping of the world by adding "Change the world geometry" behaviour.
see you in a bit
On Wed, Mar 12, 2014 at 11:14 AM, Andreas Duering <andreasdu...@gmail.com> wrote:

Howard Noble

unread,
Mar 12, 2014, 10:33:11 AM3/12/14
to modell...@googlegroups.com
ok i think I know what you mean. i tried a simple model where mothers create children each tick and let that network grow.

i think wrapping might be on but it looks like it is off because the agents at the edge of the screen try to space themselves away from the agents at the opposite edge...so they bunch up, and make it look like wrapping isn't working.

it might be easier to solve this in the classroom...

Andreas Duering

unread,
Mar 13, 2014, 5:30:44 AM3/13/14
to modell...@googlegroups.com
Dear Ken & Howard,

I hope you liked my talk yesterday. Thank you for all the info and suggestions.
My first task for today is to resize the world/links of the spring according to the number of agents in the system.

I first tried to just adjust the initial size of the patches /the world according to the sqrt ( count turtles ). But as the world can only be changed once before setup this is not a solution.

Then I took the code of the Preferential Attachment model and copy pasted it into a behaviour (Resize world). It did not work.
So I changed "turtles" into the count of males and females in the system etc. But still it is not resizing the springs etc.
What is the missing link? Is it not recognising the actual springs and links in the model?

http://m.modelling4all.org/m/?frozen=iPApP0KN-ghbycR_W2qC4e&MforAllModel=1

I am sorry to bother you with all these questions!

Best
Andreas

Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-12 14:33 GMT+00:00 Howard Noble <howard...@gmail.com>:
ok i think I know what you mean. i tried a simple model where mothers create children each tick and let that network grow.

i think wrapping might be on but it looks like it is off because the agents at the edge of the screen try to space themselves away from the agents at the opposite edge...so they bunch up, and make it look like wrapping isn't working.

it might be easier to solve this in the classroom...
On Wed, Mar 12, 2014 at 2:24 PM, Andreas Duering <andreasdu...@gmail.com> wrote:

Andreas Duering

unread,
Mar 13, 2014, 6:41:41 AM3/13/14
to modell...@googlegroups.com
Dear Ken&Howard,

I have now just created a world that is big enough to provide enough space for most of the populations of a size between 20 and 50.
http://m.modelling4all.org/m/?frozen=qj4NseRdW80vWec8bFKQ4e&MforAllModel=1

The links show the maternal kinship links of all individuals alive per tick in time.

Best
Andreas

Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-13 9:30 GMT+00:00 Andreas Duering <andreasdu...@gmail.com>:
Dear Ken & Howard,

I hope you liked my talk yesterday. Thank you for all the info and suggestions.
My first task for today is to resize the world/links of the spring according to the number of agents in the system.

I first tried to just adjust the initial size of the patches /the world according to the sqrt ( count turtles ). But as the world can only be changed once before setup this is not a solution.

Then I took the code of the Preferential Attachment model and copy pasted it into a behaviour (Resize world). It did not work.
So I changed "turtles" into the count of males and females in the system etc. But still it is not resizing the springs etc.
What is the missing link? Is it not recognising the actual springs and links in the model?

http://m.modelling4all.org/m/?frozen=iPApP0KN-ghbycR_W2qC4e&MforAllModel=1

I am sorry to bother you with all these questions!

Best
Andreas

Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-12 14:33 GMT+00:00 Howard Noble <howard...@gmail.com>:
ok i think I know what you mean. i tried a simple model where mothers create children each tick and let that network grow.

i think wrapping might be on but it looks like it is off because the agents at the edge of the screen try to space themselves away from the agents at the opposite edge...so they bunch up, and make it look like wrapping isn't working.

it might be easier to solve this in the classroom...
On Wed, Mar 12, 2014 at 2:24 PM, Andreas Duering <andreasdu...@gmail.com> wrote:

Ken Kahn

unread,
Mar 13, 2014, 10:05:52 AM3/13/14
to Modelling4All
Hi.

The comment in the Preferential Attachment model is confusing. It says ';; don't bump the edges of the world' but it should say something like ';; keep the average position of all turtles near the centre". In models where the agents are mostly in one area then this does reduce bumping by bringing them towards the centre where there is more room. But doesn't help in the models we've been looking at.

Regarding your version of layout the problem is that you define the version borrowed from Preferential Attachment but don't call it. The 'lay out linked males' and 'lay out linked females' continue to call layout-spring instead of the new layout.

But you can use their way of computing the factor to determine the spring parameters as I did in the following:


But it does look like the best solution is your second link -- use a bigger world with smaller patches and agents.

Best,

-ken


Andreas Duering

unread,
Mar 13, 2014, 10:44:51 AM3/13/14
to modell...@googlegroups.com
Dear Ken,

Thank you for checking that.
I have just implemented the spring parameters according to your suggestion and compared the results. The bigger world looks far better and does not slow down the model. The clusters at the edges are still annoying but I will just experiment with it until I find the best solution.

Best
Andreas


Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-13 14:05 GMT+00:00 Ken Kahn <toon...@gmail.com>:
Hi.

The comment in the Preferential Attachment model is confusing. It says ';; don't bump the edges of the world' but it should say something like ';; keep the average position of all turtles near the centre". In models where the agents are mostly in one area then this does reduce bumping by bringing them towards the centre where there is more room. But doesn't help in the models we've been looking at.

Regarding your version of layout the problem is that you define the version borrowed from Preferential Attachment but don't call it. The 'lay out linked males' and 'lay out linked females' continue to call layout-spring instead of the new layout.

But you can use their way of computing the factor to determine the spring parameters as I did in the following:


But it does look like the best solution is your second link -- use a bigger world with smaller patches and agents.

Best,

-ken


Howard Noble

unread,
Mar 13, 2014, 11:04:40 AM3/13/14
to modell...@googlegroups.com
unfortunately you can't resize the View as the model evolves...so you have to shrink the link spacing and agents.

people are asking for more control of the interface but that'll have to wait for https://github.com/NetLogo/NetLogo/wiki/Tortoise I guess

Richard Taylor

unread,
Mar 18, 2014, 6:34:08 AM3/18/14
to modell...@googlegroups.com
Hi Andreas
I just saw this paper in which there is a part about coding family lineages which might be interesting for you, if you haven't seen it already
Richard
Stockholm Environment Institute Oxford Centre
266 Banbury Road, Suite 193
Oxford OX2 7DL
Tel/Fax: +44 (0)1865 426316 / 355603
Direct Tel: +44 (0)1865 355608
http://sei-international.org/
http://weadapt.org/

Ken Kahn

unread,
Mar 18, 2014, 6:37:52 AM3/18/14
to Modelling4All
And speaking of demography models there is

http://www.openabm.org/model/2905/version/1/view (the NetLogo world view is buried under some text areas and the downloaded files have TXT extensions but the code expects DAT -- but otherwise works fine).

Also http://jasss.soc.surrey.ac.uk/16/4/9.html is both a survey of ABM and demography and describes their model.

Best,

-ken

Andreas Duering

unread,
Mar 18, 2014, 6:52:16 AM3/18/14
to modell...@googlegroups.com
Dear Richard and Howard,

Great links you have sent me! Thank you!

Best
Andreas


Andreas Duering, M.A., M.St.
Clarendon Scholar
D.Phil. student in Archaeology
School of Archaeology
University of Oxford
St Cross College
andreas...@stx.ox.ac.uk
andreasdu...@gmail.com


2014-03-18 10:37 GMT+00:00 Ken Kahn <toon...@gmail.com>:
And speaking of demography models there is

http://www.openabm.org/model/2905/version/1/view (the NetLogo world view is buried under some text areas and the downloaded files have TXT extensions but the code expects DAT -- but otherwise works fine).

Also http://jasss.soc.surrey.ac.uk/16/4/9.html is both a survey of ABM and demography and describes their model.

Best,

-ken
On 18 March 2014 10:34, Richard Taylor <richard...@sei-international.org> wrote:
Reply all
Reply to author
Forward
0 new messages