DomWorld

DomWorld preview image

1 collaborator

Default-person Meng Hao (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.1.0 • Viewed 289 times • Downloaded 16 times • Run 0 times
Download the 'DomWorld' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


## WHAT IS IT?

This is a replication of Hemelrijk's DomWorld. It was written by Hagen Lehmann based on an earlier, less-complete replication by Jing Jing Wang. It is particularly replicating Hemelrijk's 2002 model of apparent sexual favors extended to females when they are fertile. This model is slightly modified from one published in 2007, among other things it runs in NetLogo 4.X (see below).

## HOW IT WORKS

Hemelrijk's theory is that different social structures (e.g. despotic and egalitarian) are a consequence of the level of violence expressed when agents fight. The apparent favoritism showed to females when they are fertile is actually just a consequence of the fact males are attracted to them, so they get in more fights, so some of them wind up being higher ranking.

## HOW TO USE IT

To run a single experiment, push the Setup button first, then push Go.

To change the conditions of your experiment, you can do the following.

Change the violence level by changing "intensity of aggression". Hemelrijk uses a value of 1 for despotic species, and .1 for egalitarian ones.

Change whether males are attracted to females by turning the "attraction" switch on or off.

Change the number of individuals in the troop by changing "population". This is really only half the population -- if you choose 4 (like we did for the paper below) then you will have 4 males and 4 females.

## THINGS TO NOTICE

Please see the papers listed below.

"girls beating boys" is a bit of a misleading name -- it is really the sum over all females of the number of males that each female outranks, so this number may be a lot larger than the total number of males. For example, if there were four males and four females and all the females outranked all the males, this number would be 16.

## HOW TO GET THE RESULTS IN OUR PAPER

There are two different ways of obtaining data from the model. In the model code itself

are commented lines which need to be uncommented in order to save the data into a file. The lines are clearly marked ("uncomment to save data"). After having done this, the model will produce a data file (.csv). The file will in the first three lines contain information about the experimental setup and 11 data columns. The first column contains the number of measurement points. The 2nd - 5th column represent the dominance value for each of the females for each measurement point. The 6th - 9th column represent the dominance values for the male agents. The 10th column is the domiance variation coefficient and the 11th column represents the number of female initiated dominance interactions. These are the variables we used to analyse the simulation.

In case the user wants to be more flexible about the variables she wants to measure and has experience with NetLogo, there is a second way to extract the data from the model. NetLogo has an inbuild data recording tool. It is called BehaviorSpace and can be found under "Tools". Please see the Netlogo User Manual for a good explanation how it works.

## ANALYSIS

Our analysis showed this is not a very good model of primate social behavior. First, females only became more dominant some of the time they were attractive, and then because they fought more, and they stayed dominant after they were no longer attractive. In real primates, females are subject to *less* aggression when they are fertile, and return to their original rank immediately afterwards.

This "original rank" is another large problem with this model. In most primate species, a female's rank is determined entirely by her mother's rank and her own birth order. On very rare occassions an entire matrilinial line will change order, but this is really an exceptional event. This may be a better model of species like chimpanzees, but for macaques (a widely-used model genus for studying primate social order) it is not realistic.

## RELATED MODELS

The DomWorld model was originally called MIRROR, and created under the direction of Hemelrijk's PhD supervisor, Paulien Hogeweg, who used it to study bee social organisation.

Yasushi Ando also created a replication of Hemelrijk which is featured in our 2007 paper, it is written in SmallTalk, not NetLogo. See http://www.cs.bath.ac.uk/~jjb/web/primates/DomWorld.html for a copy.

Hagen Lehmann also has his own models of primate social organisation, most of which are in NetLogo. See his web page http://www.cs.bath.ac.uk/hl/ under "publications".

Ellen Evers is working on new primate models. See her web page http://www.bio.uu.nl/behaviour/Evers/main.html

Joanna Bryson has other models of primate behavior, see http://www.cs.bath.ac.uk/~jjb/web/primates/primate-learning.html

## CREDITS AND REFERENCES

This code was started by JingJing Wang at Bath for her MSc in 2003. Hagen Lehmann also of Bath improved the model in 2005, and then adopted it for NetLogo 4 in 2007. Ellen Evers of Utrecht checked the code and found & corrected some minor errors in 2008. These errors didn't affect the gross DomWorld dynamics. See code for details.

This research was funded by The Engineering and Physical Sciences Research Council (EPSRC), Grant GR/S79299/01 (AIBACS); JJ Bryson PI (Bath).

The analysis was helped greatly by a research visit funded by the British Council Alliance: Franco-British Partnership Programme , ``Origins of Egalitarianism: Improving our understanding primate society through modelling two organizational norms for various species of Macaque'', with Bernard Thierry, Centre d'Ecologie, Physiologie & Ethologie).

Our papers below are available from http://www.cs.bath.ac.uk/~jjb/web/primates/DomWorld.html

Joanna J. Bryson, Yasushi Ando and Hagen Lehmann ``Agent-based modelling as scientific method: a case study analysing primate social behaviour'', Philosophical Transactions of the Royal Society, B -- Biology, 362(1485):1685-1698, September 2007.

Hagen Lehmann, JingJing Wang and Joanna J. Bryson, ``Tolerance and Sexual Attraction in Despotic Societies: A Replication and Analysis of Hemelrijk (2002)'', in Modelling Natural Action Selection: Proceedings of an International Workshop, J. J. Bryson, T. J. Prescott and A. K. Seth, eds., pp. 135-142, AISB, Sussex UK, 2005.

Hemelrijk, C. K. 2002a Despotic societies, sexual attraction and the emergence of male `tolerance': an agent-based model. Behaviour 139, 729-747

Hogeweg, P. & Hesper, B. 1983 The ontogeny of the interaction structure in bumble bee colonies: a MIRROR model. Behav. Ecol. Sociobiol. 12, 271-283.

## LICENSE

This is free, open-source software distributed under the terms of the MIT License, http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2007 Hagen Lehmann

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in

all copies or substantial portions of the Software.

## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;; This research funded by The Engineering and Physical Sciences Research Council (EPSRC),
;;;; Grant GR/S79299/01 (AIBACS),
;;;; ``The Impact of Durative Variable state on the Design and Control of Action Selection''.
;;;   Code written originally by Jing Jing Wang at university of Bath (Wang 2003).
;;;   Corrected & extended by Hagen Lehmann for Lehman, Wang & Bryson (2005) and Bryson, Ando & Lehman (2007).
;;;   Updated again in 2008 for NetLogo 4, with some simplifications from original code.
;;;   All work conducted at the University of Bath, United Kingdom.
;;;;;;;;;;;;
;;;;;;;;;;;; current version of the code is reviewed and corrected by Ellen Evers at The University of Utrecht, Netherlands.
;;;;;;;;;;;; corrections at lines 22 and 80 [fleeD, chaseD], 226 ["wiggle-angle" while fleeing], 251 [search angle]

;;;  version updated to run with NetLogo 4.1 on 5 March 2011 by Joanna Bryson
;;;  version updated to run with NetLogo 5.1 (largely just by opening it) 6 March 2015 and recommented 8 March by Joanna Bryson
;;;  version updated to fix issues with BehaviourSpace referencing invalid variables on 10 March 2015 by Zack Lyons
;;;  version updated to fix overlapping agents causing errors at runtime on 12 March 2015 by Zack Lyons

;;;;;;;;;;;;;;;; globale Variablen ;;;;;;;;;;;;;;;

globals[
   ; note that all vision is restricted not only by distance but by which way the animal is headed and its field of view (vision-angle)
   PerSpace        ;personal space -- within this you have conflict
   NearView        ; -- within this but outside perspace you have business as usual
   MaxView         ; the farthest you can see
   time-units      ;monitor to show the number of goes
   male            ;monitor to show the number of times of male interaction carried on
   female          ;monitor to show the number of times of female interaction carried on
   aggmale         ;aggressive interactions by males
   aggfemale       ;aggressive inteactions by females
   vision-angle    ;how wide the field of view for the agent is
   search-angle    ;how far the agent rotates when it's "lost" (can't see any other agents)

   ;;;;; EE: define chaseD and fleeD as global variables (is much safer and more logical, as these values never change or differ)
   chaseD	         ;winner's chasing distance
   fleeD           ;loser's fleeing distance, normally twice the chasing distance

   min-dom         ;minimum dominance value, they never go before this value even if they lose another fight
   randomrunnum    ;crappy hack to get unique filenames for each run in behaviourspace experiments
   filename        ;place for aforementioned filename
]


;;;;;;;;;;;;;;;;;; breeds ;;;;;;;;;;;;;;;;;;;;;;;;;

breed [ males ]
breed [ females ]



;;;;;;;;;;;;;;; monkey variablen ;;;;;;;;;;;;;;;;;;;

turtles-own [

    attraction           ;sexual attraction (boolean)
    StepDom              ;intensity of aggression
    dom-value            ;hierarchy variablen (real-valued dominance)
    w                    ;win variable (stores outcome of battle)
    diff                 ;the actual vision angle between two agents
    opponent             ;direkter Gegner
    distanceP            ;the distance zu Gegner
    waitcount            ;waiting position counter (this timer was the hardest part of the replication; apparently Hemelrijk only mentions it in one paper.
    ;  motion isn't continuous in domworld; rather the animals sit around for a random period after they've had a move.  This seriously changes the dynamics.
    ]



;;;;;;;;;;;;;;; setup-procedure ;;;;;;;;;;;;;;;;;;;

to setup

  clear-all
  setup-globals
  setup-patches
  setup-turtles
;  setup-file  ; uncomment to save data
  reset-ticks
end 



;;;;;;;;;;;;;;;; creates background ;;;;;;;;;;;;;;

to setup-patches
   ask patches  [set pcolor green]    ;sets background green
end 

to setup-globals  ; these all come out of Hemelrijk / DomWorld. note there are other "globals" implicit in setup code below
               set PerSpace 2
               set NearView 24
               set MaxView  50
	
	       ;; EE: set values of chase veriables
	       set chaseD 1
       	 set fleeD  2

	       set vision-angle 120
               set search-angle  90
               set min-dom 0.1
               set randomrunnum random 999999
end 


;;;;;;;;;;;;;;;; creates male and female monkeys ;;;;;;;;;;;;;;;;;;

to setup-turtles
 create-males population
     [set color black
      set dom-value 16.0]
 create-females population
     [set color red
      set dom-value 8.0]
  ask turtles [set heading random 360
               set shape "arrow"
               setxy ((random (30 + 0.0)) - (30 / 2)) ((random (30 + 0.0)) - (30 / 2))
                 ]
end 

;;;;;;;;;;;;;;;  initialize the data file (only used if you are doing analysis, for dominance & centrality) ;;;;;;;;;;

to setup-file

  set filename (word "ReplicationDomWorld" intensity-of-aggression  attraction?  randomrunnum ".csv")
  file-open filename
  file-print (word "intensity of aggresion:" intensity-of-aggression)
  file-print (word "population: " population)
  file-print (word "attraction: " attraction?)
end 

;;;;;;;;;;;;;;;;; vision ;;;;;;;;;;;;;;;;;;;

to-report substract-headings [h1 h2]
    ifelse abs (h1 - h2) <= 180
    [ report h1 - h2 ]
    [ ifelse h1 > h2
    [ report h1 - h2 - 360 ]
    [ report h1 - h2 + 360 ] ]
end 

;;;;;;;;;;;;;;;;;;;;;; reports vision variables ;;;;;;;;;;;;;;;;;;;;;;

; This code returns 0 for agents trying to find a heading to their own position
To-report away [ agent ]
  let myPos ""
  let agentPos ""
  ask agent [set agentPos word xcor ycor]
  ask myself [set myPos word xcor ycor]
  ifelse myPos = agentPos
    [report 0]
    [report  ( 180 + towards agent )]
end 

to-report seen-by-myself? [ agent ]
    let myPos ""
  let agentPos ""
  ask agent [set agentPos word xcor ycor]
  ask myself [set myPos word xcor ycor]
  ifelse myPos = agentPos
    [report false]
    [report (abs (subtract-headings ([towards agent] of myself) ([heading] of myself))) <= (([vision-angle] of myself) / 2)]
end 

to-report other-turtles
   report turtles with [self != myself]
end 

to-report visible-turtles [ViewSight angle]
    report other-turtles in-radius ViewSight with [seen-by-myself? self]
end 

to-report visible-females [ViewSight angle]
    report other-turtles in-radius ViewSight with [seen-by-myself? self and breed = females]
end 

to-report nearest [agentset]
  report min-one-of agentset [distance myself]          ;;find nearest agent in a group
end 


;;;;;;;;;;;;;;;;;;;;;; interaction procedure ;;;;;;;;;;;;;;;;;;;;;;;;

; note that I simplified in lecture -- there is a "mental battle" to decide whether to attack, so this reduces the chance a weak animal attacks a strong one
; you can see this in the papers. -- JJB

to interact
   let winner 0
  let loser 0
  let mentalV 0
  let yyy 0



       set opponent (nearest visible-turtles PerSpace vision-angle)     ;opponent always exists because of conditional before calling this function (in "integrate")
       set heading towards opponent
       if distance opponent <= PerSpace
          [
	  ; increment interaction records
	  if (breed = males)   [set male male + 1]
    if (breed = females) [ set female female + 1]
	              set mentalV ([dom-value] of self)/([dom-value] of self + [dom-value] of opponent)
                ifelse (mentalV > random-float 1.00)
                   [
                     set winner self
                     set loser opponent
                     ]
                   [
                     set winner opponent
                     set loser self
                     ]
	  	          if (winner = self)  [ fight ]
    ]
end 
;;;;;;;;;;;;;;;;;;;;;;;; fighting ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to fight
  let winner 0
  let loser 0
  let relativeV 0
  let yyy 0



	; increment aggressive interaction
	if (breed = males) and ([breed] of opponent = females) [set aggmale aggmale + 1]
  if (breed = females) and ([breed] of opponent = males) [ set aggfemale aggfemale + 1]
  set relativeV ([dom-value] of self)/([dom-value] of self + [dom-value] of opponent)
  ifelse (relativeV > random-float 1.00)  [
    set w 1
    set winner self
    set loser opponent
  ]
  [
    set w 0
    set winner opponent
    set loser self
  ]

            ; intensity of aggression is set by a slider, so might change between interactions. Maybe this should be moved to setup turtles procedure for efficiency.
            if breed = males [set StepDom 1 * intensity-of-aggression
                             set male male + 1]
            if breed = females [set StepDom 0.8 * intensity-of-aggression
                                set female female + 1]


            set dom-value ([dom-value] of self)+(w - relativeV) * StepDom
            ask opponent [set dom-value ([dom-value] of self)-(w - relativeV) * StepDom]
            ask loser [set dom-value max (list min-dom [dom-value] of self )]            ;;ensure dominance values of agents are above 0.01

            ask winner [set heading towards loser fd chaseD]                        ;; the winner moves one unit towards its opponent, loser makes a 180 degree turn

            ;; EE: changed "set heading away winner + random 45", which results in right-biased fleeing to: random angle that could range from -45 to +45
            ask loser [set heading away winner - 45 + random 90 fd fleeD]               ;; and flees away two untis under a small random angle 45 degree

            ;reduce waitcount for turtles that have seen this interaction in their NearSpace

            ask turtles in-radius NearView [ if (myself != winner) [if (seen-by-myself? winner) [ set waitcount waitcount - 1]]]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;; grouping procedure ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to group
    ifelse any? visible-turtles NearView vision-angle
           [ifelse attraction? [
                                ifelse (breed = males)
                                      [if (any? visible-females NearView vision-angle)
                                      [set heading towards nearest visible-females NearView vision-angle fd 1]]
                                      [ fd 1 ]]
                               [
                                fd 1 ]
                               ]
           [ifelse any? visible-turtles MaxView vision-angle
                   [set heading towards nearest visible-turtles MaxView vision-angle
                    fd 1]

                   ;; EE: changed "rt search-angle / 2 lt search-angle" (which in fact equals "lt search-angle / 2") to "rt search-angle"
                   [ifelse (random-float 1.0) > 0.5 [rt search-angle fd 1]                 ;; if agent does not perceive other agents within MaxView
                                                    [lt search-angle fd 1]                 ;; it turns a Search angle at random to the right or left
                   ]
           ]
end 


;;;;;;;;;;;;;;;;; integration procedure ;;;;;;;;;;;;;;;;;;;;;;;

; this isn't the best name for this, but you can see it's at the centre of the Hemelrijk flow chart... JJB

to integrate
      ifelse any? visible-turtles PerSpace vision-angle
                                    [interact]
                                    [group]
end 


;;;;;;;;;;;;;;;; go procedure ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; personally, I always put "go" towards the beginning, right after the setup, but I can see the logic of the setup flowing
; into the perception so I haven't changed this here -- JJB

to go

    ask turtles [
                 ifelse (waitcount <= 0)
                   [integrate
                   set waitcount random 10]
                 [set waitcount waitcount - 1]

                 ]

      set time-units time-units + 1
      if remainder time-units 160 = 0
        [
          do-plot1 do-plot2
 ;         print-data ; uncomment for data file
        ]
      if time-units >= 42800
        [
;          file-close          ; uncomment for data file
          stop
        ]
end 

to print-data
let mytime time-units / 160

file-type (word mytime  ", ")
    ask females
      [

        file-type precision [dom-value] of self 3
        file-type ", "
      ]
    ask males
      [

        file-type precision [dom-value] of self 3
        file-type ", "
      ]

file-type (word differentiation ", ")

file-type (word aggfemale ",")

file-print " "
end 

;;;;;;;;;; report centrality ;;;;;;;;;;;;

;; we do vector addition of unit vectors by
    ; having a child turtle
    ; move one step in the direction of each other turtle (from the parent),
    ; report its distance from the parent, then
    ; die.

to report-centrality
  let vectors 0


  ask turtles [
    set vectors [towards myself] of other-turtles
    hatch 1 [ measure-vectors vectors report-distance die ]
    ]
end 

; recursive function -- go 1 in each direction until none left

to measure-vectors [vectors]
   if (vectors != [])                      ;if finished list, all done
     [ set heading (first vectors)         ;otherwise, go 1 in direction of first element in list
       forward 1
       measure-vectors (butfirst vectors)  ;then do this to the rest of the elements
     ]
end 

; write it to the file, associate with parent's ID

to report-distance
  ask myself [file-type precision distance myself 3 file-type ", "]
end 

;;;;;;;;;;;;;;;;;;;;;; plots ;;;;;;;;;;;;;;;;;;;;;

to do-plot1
   set-current-plot "Males\\Females"
   set-current-plot-pen "males"
   plot report-boys
   set-current-plot-pen "females"
   plot report-girls
end 

to-report differentiation
  let mean-dom-value 0
  let sd-dom-value 0

   set mean-dom-value mean [dom-value] of turtles
   set sd-dom-value standard-deviation [dom-value] of turtles
   report precision (sd-dom-value / mean-dom-value) 3
end 

to-report report-boys
   report precision mean [ dom-value ] of males 3
end 

to-report report-girls
   report precision mean [ dom-value ] of females 3
end 

to-report girls-beating-boys
let total-beat-boys 0
  let girl-power 0


set total-beat-boys 0

; note horrible hack to get list from agent set -- found in netlogo mailing list JJB
foreach ([self] of females) [
  set girl-power [dom-value] of ?1
  foreach ([self] of males) [
    if ( [dom-value] of ?1  <  girl-power)
      [ set total-beat-boys total-beat-boys + 1 ]
    ]]
report total-beat-boys
end 

to do-plot2
   set-current-plot "differentiation of dominance"
   plot differentiation
end 

; this is called by BehaviourSpace at the end of the experiment
; determines what is in the output csv

to print-final-report
  file-open "final-reports.csv"
  file-type randomrunnum
  file-type ", "
  file-type male
  file-type ", "
  file-type female
  file-type ", "
  file-type aggmale
  file-type ", "
  file-type aggfemale
  file-type ", "
  file-type intensity-of-aggression
  file-type ", "
  file-print attraction?
end 

There is only one version of this model, created about 6 years ago by Meng Hao.

Attached files

File Type Description Last updated
DomWorld.png preview Preview for 'DomWorld' about 6 years ago, by Meng Hao Download

This model does not have any ancestors.

This model does not have any descendants.