Cellular Automata: Life with Simple Rules - PowerPoint PPT Presentation

About This Presentation
Title:

Cellular Automata: Life with Simple Rules

Description:

Cellular Automata: Life with Simple Rules Sharks and Fish: Predator/Prey Relationships Bill Madden, Nancy Ricca and Jonathan Rizzo Graduate Students, Computer Science ... – PowerPoint PPT presentation

Number of Views:126
Avg rating:3.0/5.0
Slides: 50
Provided by: webCecsP
Learn more at: http://web.cecs.pdx.edu
Category:

less

Transcript and Presenter's Notes

Title: Cellular Automata: Life with Simple Rules


1
Cellular AutomataLife with Simple Rules
  • Sharks and Fish
  • Predator/Prey Relationships
  • Bill Madden, Nancy Ricca and Jonathan Rizzo
  • Graduate Students, Computer Science Department
  • Research Project using Departments 20-CPU
    Cluster

2
Overview
  • Cellular automata can be used to model complex
    systems using simple rules.
  • 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 2nd Edition, NJ, Pearson
Prentice Hall, p189
3
Overview
  • 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)
  • Initially,
  • 50 of the cells are occupied by fish
  • 25 are occupied by sharks
  • 25 are empty

4
Heres the number 2 million
  • Fish red sharks yellow empty black

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

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

7
Do a LOT of computation!
  • 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)
  • 15x faster than a single PC
  • Longest runs still took about 45 minutes
  • GO PARALLEL !!!

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

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

10
Breeding Rule Before
11
Breeding Rule After
12
Rules in Detail Fish Rules
  • If the current cell contains a fish
  • Fish live for 10 generations
  • If gt5 neighbors are sharks, fish dies (shark
    food)
  • If all 8 neighbors are fish, fish dies
    (overpopulation)
  • If a fish does not die, increment age

13
Rules in Detail Shark Rules
  • If the current cell contains a shark
  • Sharks live for 20 generations
  • If gt6 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
  • If a shark does not die, increment age

14
Shark Random Death Before
I Sure Hope that the random number chosen is
gt.031
15
Shark Random Death After
YES IT IS!!! I LIVE ?
16
Programming logic
  • Use 2-dimensional array to represent grid
  • 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

17
Sample Code (C) Breeding
18
Parallelism
  • 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

19
Parallelism
  • 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

20
Send Right Boundary Values
21
Receive Left Boundary Values
22
Send Left Boundary Values
23
Receive Right Boundary Values
24
Send Right Boundary Values
25
Receive Left Boundary Values
26
Send Left Boundary Values
27
Receive Right Boundary Values
28
At intervals, update the master CPU
has copy of entire array
29
MPI Classes
  • 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/18th of the problem to solve!

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

31
Generation 0
32
Generation 100
33
Generation 500
34
Generation 1,000
35
Generation 2,000
36
Generation 4,000
37
Generation 8,000
38
Generation 10,500
39
Long-term trends
  • Borders tended to harden along vertical,
    horizontal and diagonal lines
  • Borders of empty cells form between like species
  • Clumps of fish tend to coalesce and form convex
    shapes or communities

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

41
Medium-sized population (1/16 of grid)
Generation 100
2000
1000
4000
8000
42
Very Small Populations
  • Random placement of very small populations can
    favor one species over another
  • Fish favored sharks die out
  • Sharks favored sharks predominate, but fish
    survive in stable small numbers

43
Very Small Populations
Gen. 100
4000
6000
1500
8000
10,000
12,000
14,000
Ultimate welfare of sharks depends on initial
random placement of fish and sharks
44
Very small populations
  • Fish can live in stable isolated communities as
    small as 20-30
  • A community of less than 200 sharks tends not to
    be viable

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

46
Speed-up
47
Communication Overhead
48
Acknowledgements
  • 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
  • Galaxy 20-CPU cluster in Computer Science
    Department, Montclair State University

49
Parallel Processing Laboratory
  • This presentation is available on-line at
  • http//roman.montclair.edu/Research/Parallel/
  • The web site above also hosts a number of other
    interesting parallel computing projects and is
    the on-line home of the Computer Science
    Departments Parallel Processing Laboratory.
  • GO PARALLEL !!!
Write a Comment
User Comments (0)
About PowerShow.com