1 / 15

Andy Evans Living god

/** * Starts the model going and builds an initial tribe. * * @author <A href ="http://www.geog.leeds.ac.uk/people/a.evans/">Andrew Evans</A> * @version 0.1 */ public class EarlyModernHumansBuilder extends DefaultContext implements ContextBuilder { private Context context ;

melosa
Download Presentation

Andy Evans Living god

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. /** * Starts the model going and builds an initial tribe. * * @author <A href="http://www.geog.leeds.ac.uk/people/a.evans/">Andrew Evans</A> * @version 0.1 */ public class EarlyModernHumansBuilder extends DefaultContext implements ContextBuilder { private Context context; private GridValueLayer geography; private Grid <Human> encounterGrid; private ContinuousSpace <Human> space; private Network <Human> tribalNetwork; private Parameters params; private double seaValue = 0.0; ** * Builds the spaces and an initial tribe. Each tribe has its own network, but shares continuous and grid space. */ Andy EvansLiving god

  2. Like rats /** * Represents a generic Human. * This could be <I>Homo sapiens sapiens</I>, <I>Homo neanderthalensis / Homo sapiens neanderthalensis</I>, or, infact, most other hominids. * @ToDo Might be better named Hominid.java. * * @author <A href="http://www.geog.leeds.ac.uk/people/a.evans/">Andrew Evans</A> * @version 0.1 */ public class Human {

  3. /** * Makes a new tribe taking in members and a leader. * The leader should be located in space and not present in the members ArrayList. * The leader will be added to the members and the members will be distributed * around the leader in space. * @param members * @param leader */ ublicvoid makeTribe(ArrayList<Human> members, Human leader) { members.add(leader); tribes.add(members); leader.setLeader(true); leaders.add(leader); // Move the tribe. Human tempHuman; NdPointtempPoint; for (int i = 1; i < members.size(); i++) { // Setup the Human. tempHuman= members.get(i); tempPoint= getLocationCentredOnTerritory(members, 0, getTerritoryRadius(members)); space.moveTo(tempHuman, tempPoint.getX(), tempPoint.getY()); encounterGrid.moveTo(tempHuman,(int)tempPoint.getX(), (int)tempPoint.getY()); tribeNetwork.addEdge(leader, tempHuman); } } Stroll along the Prom, Prom, Prom…

  4. /** * Constructor. * * @param context - the primary context. * @param builder - the primary contextbuilder. * @param space - the global continuous space. * @paramencounterGrid - the global grid space. * @paramtribeNetwork - the globally developed tribal network. * @paraminitialPopulationNumber - starting population. */ public Tribes (Context context, EarlyModernHumansBuilder builder, GridValueLayer geography, ContinuousSpace <Human> space, Grid <Human> encounterGrid, Network <Human> tribeNetwork ) { this.context = context; this.builder = builder; this.geography = geography; this.space = space; this.encounterGrid = encounterGrid; this.tribeNetwork = tribeNetwork; leaders = new ArrayList<Human>(); tribes = new ArrayList<ArrayList<Human>>(); originX = geography.getDimensions().getOrigin(0); originY = geography.getDimensions().getOrigin(1); width = geography.getDimensions().getWidth() - 1; height = geography.getDimensions().getHeight() - 1; ageSpecificFertilityRates = generateDistribution("fertility"); ageSpecificDeathRates = generateDistribution("deaths"); respectDistribution = generateDistribution("respect"); leadershipDesireDistribution = generateDistribution("leadership"); } Tribe

  5. /** * Takes in an x value (age) and returns a y value (age specific fertility * rates). Distribution generated is based on a 5th order polynomial curve * from Fig.4. of: Hawkes, K. (2010) How grandmother effects plus individual * variation in frailty shape fertility and mortality: Guidance from * human–chimpanzee comparisons PNAS May 11, 2010 vol. 107 no. Supplement 2 * 8977-8984 DOI: 10.1073/pnas.0914627107 * http://www.pnas.org/content/107/suppl.2/8977.figures-only * * @param x * @return y */ double fertilityFunction(double x) { // Code generated by http://www.arachnoid.com/polysolve/index.html if ((x >= 13) || (x <= 47.5)) { double answer = 1.424485017186e+00 + -3.633942763485e-01 * x + 3.224862325580e-02 * Math.pow(x, 2) + -1.229367715766e-03 * Math.pow(x, 3) + 2.140384615644e-05 * Math.pow(x, 4) + -1.410256410430e-07 * Math.pow(x, 5); if (answer < 0) answer = 0; return answer; } else { return 0; } } Shopping and…

  6. /** * Takes in an x value (age) and returns a y value (age specific death * rates). Distribution generated is based on a 5th order polynomial curve * from Fig.10. of: Gurven, M and Kaplan, H. (2007) Longevity among * hunter-gatherers: a cross-cultural examination. Population and * Development Review 33(2):321-365. * http://www.anth.ucsb.edu/faculty/gurven/papers/GurvenKaplan2007pdr.pdf * * @param x * @return y */ oubledeathsFunction(double x) { // Code generated by http://www.arachnoid.com/polysolve/index.html double answer = 1.120897832817e-01 + -1.728930697785e-02 * x + 8.870107962213e-04 * Math.pow(x, 2) + -1.794524489958e-05 * Math.pow(x, 3) + 1.359053742955e-07 * Math.pow(x, 4) + -1.516234023974e-10 * Math.pow(x, 5); if (answer < 0) answer = 0; return answer; } I have become DeathDestroyer of Worlds

  7. /** * Makes a new tribe taking in members and a leader. * The leader should be located in space and not present in the members ArrayList. * The leader will be added to the members and the members will be distributed * around the leader in space. * @param members * @param leader */ public void makeTribe(ArrayList<Human> members, Human leader) { members.add(leader); tribes.add(members); leader.setLeader(true); leaders.add(leader); // Set up the members in space. Human tempHuman; NdPointtempPoint; for (inti = 0; i < members.size() - 1; i++) { // NB last member is now leader. // Setup the Human. tempHuman = members.get(i); tempPoint = getLocationCentredOnTerritory(members, 0, getTerritoryRadius(members.size())); space.moveTo(tempHuman, tempPoint.getX(), tempPoint.getY()); encounterGrid.moveTo(tempHuman,(int)tempPoint.getX(), (int)tempPoint.getY()); tribeNetwork.addEdge(leader, tempHuman); } } Two Tribes

  8. private EarlyModernHumansBuilder builder; private Context context; private GridValueLayer geography; private Grid <Human> encounterGrid; private ContinuousSpace <Human> space; private Network <Human> tribeNetwork; private double originX; private double originY; private double width; private double height; private double[] ageSpecificFertilityRates; private double[] ageSpecificDeathRates; private int[] femaleAgeGroups; private int[] ageGroups; private intfertileAge = 13; private intinfertileAge = 48; private intageAllDieAt = 81; private intminimumLeaderAge = 20; private double f2mSexRatio = 0.47; // Based on sex ratio of 106M/100F private double territoryAreaConstant = 70.0; // See getTerritoryRadius(intpopulationSize) private double territoryAreaExponent = 0.70; // See getTerritoryRadius(intpopulationSize) private double seaValue = 0.0; private double pixelSize = 10.0; private intmaximumMembership = 100; private int traitors = 50; Parameterisation Max tribal size = 100 Random distribution around leader Traitors = 50 Fertile age = 13; Infertile age = 48; Age all die at = 81; Minimum leader age = 20;

  9. /** * Generates a person excluded to a space. * At the moment we don't exclude current leaders. * @param tribe * @return A Human set up in space. Not (yet) set as a leader. */ public Human excludeHuman(ArrayList<Human> tribe) { SimUtilities.shuffle(tribe,RandomHelper.getUniform()); Object[] members = tribe.toArray(); Human excludee = null; Human currentLeader = leaders.get(tribes.indexOf(tribe)); // Find someone not a current leader. for (int i = 0; i < members.length; i++) { excludee = (Human) members[i]; if ((excludee != currentLeader) && (excludee.getAge() >= minimumLeaderAge)) { if (Math.random() < leadershipDesireDistribution[excludee.getAge()]) { break; } } } // Exclude the Human and set them up in a space away from the tribe. tribe.remove(excludee); tribeNetwork.removeEdge(tribeNetwork.getEdge(currentLeader, excludee)); // Find new home. booleannewHomeFound = false; intminDistance = 2; intmaxDistance = 3; double maximumTribeRadius = getTerritoryRadius(maximumMembership); GridPointpt; NdPointnewHome; NdPointcurrentCenter = space.getLocation(leaders.get(tribes.indexOf(tribe))); And crawling, on the planet's face

  10. /** * Generates a person excluded to a space. * At the moment we don't exclude current leaders. * @param tribe * @return A Human set up in space. Not (yet) set as a leader. */ public Human excludeHuman(ArrayList<Human> tribe) { SimUtilities.shuffle(tribe,RandomHelper.getUniform()); Object[] members = tribe.toArray(); Human excludee = null; Human currentLeader = leaders.get(tribes.indexOf(tribe)); // Find someone not a current leader. for (int i = 0; i < members.length; i++) { excludee = (Human) members[i]; if ((excludee != currentLeader) && (excludee.getAge() >= minimumLeaderAge)) { if (Math.random() < leadershipDesireDistribution[excludee.getAge()]) { break; } } } // Exclude the Human and set them up in a space away from the tribe. tribe.remove(excludee); tribeNetwork.removeEdge(tribeNetwork.getEdge(currentLeader, excludee)); // Find new home. booleannewHomeFound = false; intminDistance = 2; intmaxDistance = 3; double maximumTribeRadius = getTerritoryRadius(maximumMembership); GridPointpt; NdPointnewHome; NdPointcurrentCenter = space.getLocation(leaders.get(tribes.indexOf(tribe))); some insects, called the human race.

  11. /** * Generates a person excluded to a space. * At the moment we don't exclude current leaders. * @param tribe * @return A Human set up in space. Not (yet) set as a leader. */ public Human excludeHuman(ArrayList<Human> tribe) { SimUtilities.shuffle(tribe,RandomHelper.getUniform()); Object[] members = tribe.toArray(); Human excludee = null; Human currentLeader = leaders.get(tribes.indexOf(tribe)); // Find someone not a current leader. for (int i = 0; i < members.length; i++) { excludee = (Human) members[i]; if ((excludee != currentLeader) && (excludee.getAge() >= minimumLeaderAge)) { if (Math.random() < leadershipDesireDistribution[excludee.getAge()]) { break; } } } // Exclude the Human and set them up in a space away from the tribe. tribe.remove(excludee); tribeNetwork.removeEdge(tribeNetwork.getEdge(currentLeader, excludee)); // Find new home. booleannewHomeFound = false; intminDistance = 2; intmaxDistance = 3; double maximumTribeRadius = getTerritoryRadius(maximumMembership); GridPointpt; NdPointnewHome; NdPointcurrentCenter = space.getLocation(leaders.get(tribes.indexOf(tribe))); Lost in time, and lost in space...

  12. public void printDemographics () { double numberOfBirths = 0; for (int age = fertileAge; age < infertileAge; age++) { numberOfBirths= numberOfBirths + ageSpecificFertilityRates[age] * femaleAgeGroups[age]; } System.out.println("Births = " + numberOfBirths); // Calculate the number of deaths in each age group. double[] numberOfDeaths = new double[ageAllDieAt + 1]; for (int age = 0; age < ageAllDieAt; age++) { numberOfDeaths[age] = ageSpecificDeathRates[age] * ageGroups[age]; } // Kill off everyone in the last age group. numberOfDeaths[ageAllDieAt] = ageGroups[ageAllDieAt]; for (int i = 0; i < ageGroups.length; i++) { System.out.println(" Age : " + i + " All : " + ageGroups[i] + " Female : " + femaleAgeGroups[i] + " Deaths : " + numberOfDeaths[i]) } } Bad god Spreading fast if people But tribes die out below max size

  13. Et alia // Note that we keep a tribe-level reference the leader for // convenience, so we don't have to loop through whole tribe to find them, // but also keep a record of whether they are leaders inside each Human // so we can display them differently (see HumanStyle.java). ArrayList<Human> tribe = new ArrayList<Human>(); tribes.add(tribe); The ontological status of predictions as private information

  14. Ship of Fool /** * Initialises the Human. Note that the spaces do not include tribal spaces, which are coped with * through the Tribe subcontext. Nevertheless, we record whether the Human * is a leader to allow HumanStyle to distinguish leaders. * @param space * @paramencounterGrid */public Human (GridValueLayer geography, ContinuousSpace <Human> space, Grid <Human> encounterGrid) { this.geography= geography; this.space= space; this.encounterGrid= encounterGrid; } www.geog.leeds.ac.uk/people/a.evans/ /** * Represents a generic Human. * This could be <I>Homo sapiens sapiens</I>, <I>Homo neanderthalensis / Homo sapiens neanderthalensis</I>, or, infact, most other hominids. * @ToDo Might be better named Hominid.java. * * @author <A href="http://www.geog.leeds.ac.uk/people/a.evans/">Andrew Evans</A> * @version 0.1 */

More Related