1 / 59

Cellular Automata

Cellular Automata. COMP308 Unconventional models and paradigms. Failure and Success of Complex Models. New scientific paradigms bring about new insights:

happy
Download Presentation

Cellular Automata

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. Cellular Automata COMP308 Unconventional models and paradigms

  2. Failure and Success of Complex Models New scientific paradigms bring about new insights: • Research shows that complexity is a prerequisite for success of living systems (Jacobs, Langton, Wolfram, Kaufmann, Fotheringhham, Longley & Batty, Frankhauser & Sadler) • Lessons learned: • Complexity complication

  3. What is a Cellular Automata ? • Concept introduced by Von Neumann, Ulam and Burk in late 1940-ies and 1950-ies; (Self-reproducible mechanical automata) • Conway’s ‘Game of Life’ (Gardner, 1970) Mathematical object defined as: • n-dimensional homogeneous and infinite cellular space, consisting of cells of equal size (2-D CA = torus, not a plane); • Cells in one of a discrete number of states; • Cells change state as the result of a transition rule; • Transition rule is defined in terms of the states of cells that are part of a neighbourhood; • Time progresses in discrete steps. All cells change state simultaneously.

  4. What is a Cellular Automaton? • A one-dimensional cellular automaton (CA) consists of two things: a row of "cells" and a set of "rules". • Each of the cells can be in one of several "states". The number of possible states depends on the automaton. Think of the states as colors. In a two-state automaton, each of the cells can be either black or white. • Over time, the cells can change from state to state. The cellular automaton's rules determine how the states change. • It works like this: When the time comes for the cells to change state, each cell looks around and gathers information on its neighbors' states. (Exactly which cells are considered "neighbors" is also something that depends on the particular CA.) • Based on its own state, its neighbors' states, and the rules of the CA, the cell decides what its new state should be. All the cells change state at the same time.

  5. 3 Black = White • 2 Black = Black • 1 Black = Black • 3 White = White Now make your own CA

  6. 2-Dimensional Automata 2-dimensional cellular automaton consists of an infinite (or finite) grid of cells, each in one of a finite number of states. Time is discrete and the state of a cell at time t is a function of the states of its neighbors at time t-1.

  7. Conway’s Game of Life The universe of the Game of Life is an infinite two-dimensional grid of cells, each of which is either alive or dead. Cells interact with their eight neighbors.

  8. Example of a Cellular Automata: Conway’s Life (Gardner, 1970)

  9. Conway’s Game of Life At each step in time, the following effects occur: • Any live cell with fewer than two neighbors dies, as if by loneliness. • Any live cell with more than three neighbors dies, as if by overcrowding. • Any live cell with two or three neighbors lives, unchanged, to the next generation. • Any dead cell with exactly three neighbors comes to life. • The initial pattern constitutes the first generation of the system. The second generation is created by applying the above rules simultaneously to every cell in the first generation -- births and deaths happen simultaneously. The rules continue to be applied repeatedly to create further generations.

  10. Applications of Cellular Automata • Simulation of Biological Processes • Simulation of Cancer cells growth • Predator – Prey Models • Art • Simulation of Forest Fires • Simulations of Social Movement • …many more.. It’s a very active area of research.

  11. Cellular Automata: Life with Simple Rules Sharks and Fish: Predator/Prey Relationships Based on the work of Bill Madden, Nancy Ricca and Jonathan Rizzo (Montclair State University) 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

  12. Main idea • Model predator/prey relationship by CA • Define set of rules • 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 12

  13. Here’s the number 2 million • Fish: red; sharks: yellow; empty: black 13

  14. 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. 14

  15. 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 Initially cells contain fish, sharks or are empty • Empty cells = 0 (black pixel) • Fish = 1 (red pixel) • Sharks = –1 (yellow pixel) 15

  16. 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, • Fish breeding age >= 2, • 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 shark (age = |-1| at birth) 16

  17. Breeding Rule: Before 17

  18. Breeding Rule: After 18

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

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

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

  22. Shark Random Death: After YES IT IS!!! I LIVE  22

  23. 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 23

  24. 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 24

  25. 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 25

  26. Send Right Boundary Values 26

  27. Receive Left Boundary Values 27

  28. Send Left Boundary Values 28

  29. Receive Right Boundary Values 29

  30. Send Right Boundary Values 30

  31. Receive Left Boundary Values 31

  32. Send Left Boundary Values 32

  33. Receive Right Boundary Values 33

  34. At intervals, update the master CPU has copy of entire array 34

  35. Illustration • Next several screens show behavior over a span of 10,000+ generations (about 25 minutes on a cluster of 20 processors ) 35

  36. Generation: 0 36

  37. Generation: 100 37

  38. Generation: 500 38

  39. Generation: 1,000 39

  40. Generation: 2,000 40

  41. Generation: 4,000 41

  42. Generation: 8,000 42

  43. Generation: 10,500 43

  44. 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 44

  45. Medium-sized population (1/16 of grid) Generation 100 1000 2000 4000 8000 • 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 45

  46. 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 46

  47. 1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 Elementary Cellular Automata As before think of every cell as having a left and right neighbor and so every cell and its two neighbors will be one of the following types Replace a black cell with 1 and a white cell with 0 111 110 101 100 011 010 001 000 Every yellow cell above can be filled out with a 0 or a 1 giving a total of 2 8=256 possible update rules.

  48. 1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 This allows any string of eight 0s and 1’s to represent a distinct update rule Example: Consider the string 0 1 1 0 1 0 1 0 it can be taken to represent the update rule Or equivalently Now think of 01101010 as the binary expansion of the number 0 27+ 1 26+ 1 25+ 0 24+1 23+ 0 22+ 1 21+ 0 20 = 64+32+8+2=106. So the update rule is rule # 106

  49. Rule #45=32+8+4+1 = 0 27+ 0 26+ 1 25+ 0 24+1 23+ 1 22+ 0 21+ 1 20 =0 0 1 0 1 1 0 1 Rule #30=16+8+4+2 = 0 27+ 0 26+ 0 25+ 1 24+1 23+ 1 22+ 1 21+ 0 20 =0 0 0 1 1 1 1 0 This naming convention of the 256 distinct update rules is due to Stephen Wolfram. He is one of the pioneers of Cellular Automata and author of the book a New Kind of Science, which argues that discoveries about cellular automata are not isolated facts but have significance for all disciplines of science. Let’s visualize some of these rules using a Mathematica notebook

  50. Automata generated using Rule 30 appear in nature, on some shells.

More Related