In the file human.jar, we make available a Human-Science-based extension for NetLogo simulations. The current version is 1.2.3.
This extension may require NetLogo with Java 7 (but should work with NetLogo with bundled Java 6 – if there are problems, use NetLogo with no bundled Java VM instead). All software is copyright © Anthony H. Dekker, 2013, but the current version may be freely used (under the GNU GPL) as long as it is properly attributed. The extension currently provides the following functions:
GridPlannerobject), which will find the shortest path around an arbitrary number of obstacles. The picture below shows the result of several agents travelling to a shared goal patch, avoiding three rectangular obstacles. NetLogo usage is:
human:init-grid-planner world-width world-height min-pxcor min-pycor— create (and return) a
GridPlannerobject, based on the world dimensions
human:grid-planner-add-obstacle grid-planner x y width height— add a rectangular obstacle, specified by lower left coordinate, plus width and height in patches (command)
human:grid-planner-next-heading grid-planner pxcor pycor goal-x goal-y— given the coordinates of the current patch and the goal patch, compute a path. The heading (from 0 to 360) to the next patch is returned. An appropriate action is to set this heading, move forward one patch, and then recompute (repeating these steps until the goal patch is reached). The major calculations will be done only once, and retained in the
GridPlannerobject. Negative headings are returned if no path exists, or if the goal has already been reached.
SleepStateextension objects. NetLogo usage is:
human:init-sleep asleep? ticks-per-day— create a
SleepStateobject, starting at midnight
human:tick-sleep sleep-state— do one tick, allowing the person to fall asleep if need be (command)
human:force-wake-tick sleep-state— do one tick, forcing the person to stay awake (command)
human:is-asleep? sleep-state— is the person now asleep?
human:changed-sleep? sleep-state— did the person just wake up, or just fall asleep?
human:nice-time t ticks-per-day— utility function to convert a tick count
tto a displayable time
human:aust-mf-prob male?— probability that a member of the population is male (0.4944) or female (0.5056)
human:aust-random-age (random-float 1)— given a random number between 0 and 1, a random person’s age (an offset of 1,000 is added for females)
human:aust-male-birth— probablity that a new baby is male (0.513)
human:aust-death-prob age male?— using a boolean to specify whether the person is male
human:rank-std rank— conversion into standard form, e.g. “E-8” or “O-6”
human:rank-kind rank— conversion into type, i.e. “E,” “W,” or “O”
human:rank-level rank— conversion into level within type (1–10)
human:rank-int rank— conversion into level with offsets: 1–9 for “E,” 11–15 for “W,” and 21–30 for “O”
human:rank-desc rank— conversion into description, e.g. “Senior Chief Petty Officer”
human:property-names— return a list of property names
human:property-mean name— mean for the property
human:property-sd name— standard deviation for the property
human:property-unit name— unit for the property (e.g. “cm”)
human:property-info name— description of the property
|US-height-male||175.514||7.112||cm||Heights for US adult males, 18–74 years, for 1976–1980. See here|
|US-height-female||161.798||6.604||cm||Heights for US adult females, 18–74 years, for 1976–1980. See here|
|Swedish-gestation||281.0||13.0||days||Durations of human singleton pregnancies, from this Swedish study|
|Walking-speed||1.34||0.37||m/s||Walking speed, from this Dutch study|
|IQ||100.0||15.0||–||Intelligence quotient, by definition|
|Extraversion||4.395||1.087||–||Personality trait scores from this study|
|Agreeableness||5.403||0.888||–||Personality trait scores from this study|
|Conscientiousness||5.152||1.005||–||Personality trait scores from this study|
|Emotional-stability||5.195||1.047||–||Personality trait scores from this study|
|Openness-to-experience||4.237||1.052||–||Personality trait scores from this study|
human:about— reports software version number
human:biased-random-choice (random-float 1) power value-list— implements biased random choice. The numbers in
value-listare raised to
power, and then the random number (assumed to be in the range 0 to 1) is used to chose an element, with probabilities proportional to the modified values. A list index (starting from 0) is returned.
Place the jar file in a folder called “human” in your NetLogo extensions folder, and put
extensions [human] at the top of your NetLogo code.
The following NetLogo code computes, for an agent with
male? attributes, whether it should die
in the course of a one-year timestep:
The following NetLogo code allows the generation of normally distributed random numbers from the specified distributions:
to do-age let death-prob human:aust-death-prob age male? if-else (random-float 1 < death-prob) [ die ] [ set age 1 + age ] end
to-report n-random-properties [n name] report n-values n [ random-normal (human:property-mean name) (human:property-sd name) ] end to-report random-property [name] report random-normal (human:property-mean name) (human:property-sd name) end to-report n-random-heights [n male?] if-else (male?) [ report n-random-properties n "US-height-male" ] [ report n-random-properties n "US-height-female" ] end to-report random-height [male?] if-else (male?) [ report random-property "US-height-male" ] [ report random-property "US-height-female" ] end to print-properties print "Properties:" foreach human:property-names [ type "\"" type ? type "\" : mean = " type human:property-mean ? type " " type human:property-unit ? type ", sd = " type human:property-sd ? type " " type human:property-unit ? type " (" type human:property-info ? print ")" ] end
This page maintained by Anthony Dekker: last updated 23 Oct 2013.