Presentation is loading. Please wait.

Presentation is loading. Please wait.

Cellular Automata: Life with Simple Rules Sharks and Fish: Predator/Prey Relationships Bill Madden, Nancy Ricca and Jonathan Rizzo Graduate Students,

Similar presentations


Presentation on theme: "Cellular Automata: Life with Simple Rules Sharks and Fish: Predator/Prey Relationships Bill Madden, Nancy Ricca and Jonathan Rizzo Graduate Students,"— Presentation transcript:

1

2 Cellular Automata: Life with Simple Rules Sharks and Fish: Predator/Prey Relationships Bill Madden, Nancy Ricca and Jonathan Rizzo Graduate Students, Computer Science Department Research Project using Department’s 20-CPU Cluster

3 2 Overview Cellular automata can be used to model complex systems using simple rules. Cellular automata can be used to model complex systems using simple rules. Key features* Key features*  divide problem space into cells  each cell can be in one of several finite states  cells are affected by neighbors according to rules  all cells are affected simultaneously in a generation  rules are reapplied over many generations *Adapted from: Wilkinson,B and M. Allen (1999): Parallel Programming 2 nd Edition, NJ, Pearson Prentice Hall, p189

4 3 Overview This project models a predator/prey relationship This project models a predator/prey relationship Begins with a randomly distributed population of fish, sharks, and empty cells in a 1000x2000 cell grid (2 million cells) Begins with a randomly distributed population of fish, sharks, and empty cells in a 1000x2000 cell grid (2 million cells) Initially, Initially,  50% of the cells are occupied by fish  25% are occupied by sharks  25% are empty

5 4 Here’s the number 2 million Fish: red; sharks: yellow; empty: black Fish: red; sharks: yellow; empty: black

6 5 Rules A dozen or so rules describe life in each cell: birth, longevity and death of a fish or shark birth, longevity and death of a fish or shark breeding of fish and sharks breeding of fish and sharks over- and under-population over- and under-population fish/shark interaction fish/shark interaction Important: what happens in each cell is determined only by rules that apply locally, yet which Important: what happens in each cell is determined only by rules that apply locally, yet which often yield long-term large-scale patterns.

7 6 Do a LOT of computation! Apply a dozen rules to each cell Apply a dozen rules to each cell Do this for 2 million cells in the grid Do this for 2 million cells in the grid Do this for 20,000 generations Do this for 20,000 generations Well over a trillion calculations per run! Well over a trillion calculations per run! Do this as quickly as you can Do this as quickly as you can

8 7 Do a LOT of computation! We used a 20-CPU cluster in the Computer Science Department (Galaxy) We used a 20-CPU cluster in the Computer Science Department (Galaxy) ‘Gal’ is the smaller of two clusters run by the Department (larger one has 64 CPUs) ‘Gal’ is the smaller of two clusters run by the Department (larger one has 64 CPUs) 15x faster than a single PC 15x faster than a single PC Longest runs still took about 45 minutes Longest runs still took about 45 minutes GO PARALLEL !!! GO PARALLEL !!!

9 8 Rules in detail: Initial Conditions Initially cells contain fish, sharks or are empty Empty cells = 0 (black pixel) Empty cells = 0 (black pixel) Fish = 1 (red pixel) Fish = 1 (red pixel) Sharks = –1 (yellow pixel) Sharks = –1 (yellow pixel)

10 9 Rules in detail: Breeding Rule Breeding rule: if the current cell is empty If there are >= 4 neighbors of one species, and >= 3 of them are of breeding age, If there are >= 4 neighbors of one species, and >= 3 of them are of breeding age, Fish breeding age >= 2,Fish breeding age >= 2, Shark breeding age >=3,Shark breeding age >=3, and there are <4 of the other species: then create a species of that type +1= baby fish (age = 1 at birth)+1= baby fish (age = 1 at birth) -1 = baby shark (age = |-1| at birth)-1 = baby shark (age = |-1| at birth)

11 10 Breeding Rule: Before EMPTY

12 11 Breeding Rule: After

13 12 Rules in Detail: Fish Rules If the current cell contains a fish: Fish live for 10 generations Fish live for 10 generations If >=5 neighbors are sharks, fish dies (shark food) If >=5 neighbors are sharks, fish dies (shark food) If all 8 neighbors are fish, fish dies (overpopulation) If all 8 neighbors are fish, fish dies (overpopulation) If a fish does not die, increment age If a fish does not die, increment age

14 13 Rules in Detail: Shark Rules If the current cell contains a shark: Sharks live for 20 generations Sharks live for 20 generations If >=6 neighbors are sharks and fish neighbors =0, the shark dies (starvation) If >=6 neighbors are sharks and fish neighbors =0, the shark dies (starvation) A shark has a 1/32 (.031) chance of dying due to random causes A shark has a 1/32 (.031) chance of dying due to random causes If a shark does not die, increment age If a shark does not die, increment age

15 14 Shark Random Death: Before I Sure Hope that the random number chosen is >.031

16 15 Shark Random Death: After YES IT IS!!! I LIVE

17 16 Programming logic Use 2-dimensional array to represent grid Use 2-dimensional array to represent grid At any one (x, y) position, value is: At any one (x, y) position, value is:  Positive integer (fish present)  Negative integer (shark present)  Zero (empty cell)  Absolute value of cell is age

18 17 Sample Code (C++): Breeding

19 18 Parallelism A single CPU has to do it all: A single CPU has to do it all:  Applies rules to first cell in array  Repeats rules for each successive cell in array  After 2 millionth cell is processed, array is updated  One generation has passed  Repeat this process for many generations  Every 100 generations or so, convert array to red, yellow and black pixels and send results to screen

20 19 Parallelism How to split the work among 20 CPUs How to split the work among 20 CPUs  1 CPU acts as Master (has copy of whole array)  18 CPUs act as Slaves (handle parts of the array)  1 CPU takes care of screen updates Problem: communication issue concerning cells along array boundaries among slaves Problem: communication issue concerning cells along array boundaries among slaves

21 20 Send Right Boundary Values

22 21 Receive Left Boundary Values

23 22 Send Left Boundary Values

24 23 Receive Right Boundary Values

25 24 Send Right Boundary Values

26 25 Receive Left Boundary Values

27 26 Send Left Boundary Values

28 27 Receive Right Boundary Values

29 28 At intervals, update the master CPU has copy of entire array

30 29 MPI Classes ‘Gal’ (the 20-CPU cluster we used) has special enhancements to C++, called MPI Classes, which handle such boundary communication issues ‘Gal’ (the 20-CPU cluster we used) has special enhancements to C++, called MPI Classes, which handle such boundary communication issues Other than that, each slave processes its portion of the array much as a single CPU would process the whole array except, of course, they each have only 1/18 th of the problem to solve! Other than that, each slave processes its portion of the array much as a single CPU would process the whole array except, of course, they each have only 1/18 th of the problem to solve!

31 30 Results Next several screens show behavior over a span of 10,000+ generations (about 25 minutes on Gal) Next several screens show behavior over a span of 10,000+ generations (about 25 minutes on Gal)

32 31 Generation: 0

33 32 Generation: 100

34 33 Generation: 500

35 34 Generation: 1,000

36 35 Generation: 2,000

37 36 Generation: 4,000

38 37 Generation: 8,000

39 38 Generation: 10,500

40 39 Long-term trends Borders tended to ‘harden’ along vertical, horizontal and diagonal lines Borders tended to ‘harden’ along vertical, horizontal and diagonal lines Borders of empty cells form between like species Borders of empty cells form between like species Clumps of fish tend to coalesce and form convex shapes or ‘communities’ Clumps of fish tend to coalesce and form convex shapes or ‘communities’

41 40 Variations of Initial Conditions Still using randomly distributed populations: Still using randomly distributed populations:  Medium-sized population. Fish/sharks occupy: 1/16 th of total grid Fish: 62,703; Sharks: 31,301  Very small population. Fish/sharks occupy: 1/800 th of total grid Initial population: Fish: 1,298; Sharks: 609

42 41 Generation Medium-sized population (1/16 of grid)

43 42 Very Small Populations Random placement of very small populations can favor one species over another Random placement of very small populations can favor one species over another Fish favored: sharks die out Fish favored: sharks die out Sharks favored: sharks predominate, but fish survive in stable small numbers Sharks favored: sharks predominate, but fish survive in stable small numbers

44 43 Gen ,00012,00014,000 Ultimate welfare of sharks depends on initial random placement of fish and sharks Very Small Populations

45 44 Very small populations Fish can live in stable isolated communities as small as Fish can live in stable isolated communities as small as A community of less than 200 sharks tends not to be viable A community of less than 200 sharks tends not to be viable

46 45 Parallel Performance Parallel processing suggests speedup of close to 18 is possible Parallel processing suggests speedup of close to 18 is possible Our results: 15x speedup Our results: 15x speedup Reason: communication overhead among slaves and between slaves and master Reason: communication overhead among slaves and between slaves and master Communication overhead becomes much worse if results are communicated more often Communication overhead becomes much worse if results are communicated more often

47 46 Speed-up

48 47 Communication Overhead

49 48 Acknowledgements Bill Madden, Nancy Ricca and Jonathan Rizzo, Graduate Students, Computer Science Department, Montclair State University Bill Madden, Nancy Ricca and Jonathan Rizzo, Graduate Students, Computer Science Department, Montclair State University Dr. Roman Zaritski, Professor, Computer Science Department, Montclair State University Dr. Roman Zaritski, Professor, Computer Science Department, Montclair State University Galaxy: 20-CPU cluster in Computer Science Department, Montclair State University Galaxy: 20-CPU cluster in Computer Science Department, Montclair State University

50 49 Parallel Processing Laboratory This presentation is available on-line at: The web site above also hosts a number of other interesting parallel computing projects and is the on-line “home” of the Computer Science Department’s Parallel Processing Laboratory. GO PARALLEL !!!


Download ppt "Cellular Automata: Life with Simple Rules Sharks and Fish: Predator/Prey Relationships Bill Madden, Nancy Ricca and Jonathan Rizzo Graduate Students,"

Similar presentations


Ads by Google