0% found this document useful (0 votes)
53 views55 pages

Agent-Based Simulation: Cellular Automata

The document discusses cellular automata (CA), which are discrete computational models used in fields like computer science, mathematics, and biology. It defines CA as regular grids of cells that have a finite number of states, where the state of each cell at a given time is determined by a rule based on the states of neighboring cells at the previous time. Simple examples of CA include Conway's Game of Life and elementary one-dimensional CA like Rule 110. The document also covers properties of CA like parallelism, locality, and homogeneity, as well as more complex classes of CA such as reversible CA.

Uploaded by

tuanngthanh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views55 pages

Agent-Based Simulation: Cellular Automata

The document discusses cellular automata (CA), which are discrete computational models used in fields like computer science, mathematics, and biology. It defines CA as regular grids of cells that have a finite number of states, where the state of each cell at a given time is determined by a rule based on the states of neighboring cells at the previous time. Simple examples of CA include Conway's Game of Life and elementary one-dimensional CA like Rule 110. The document also covers properties of CA like parallelism, locality, and homogeneity, as well as more complex classes of CA such as reversible CA.

Uploaded by

tuanngthanh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 55

Agent-Based Simulation

Agent-Based Simulation
Cellular Automata

Federico Pecora School of Science and Technology rebro University


[email protected]

Federico Pecora Agent-Based Simulation Part 2

1 / 35

Agent-Based Simulation

Outline

Introduction to CA Simple CA (apparently) Other classes of CA Reversible CA Totalistic CA Applications of CA

Federico Pecora Agent-Based Simulation Part 2

2 / 35

Agent-Based Simulation Introduction to CA

Outline

Introduction to CA Simple CA (apparently) Other classes of CA Reversible CA Totalistic CA Applications of CA

Federico Pecora Agent-Based Simulation Part 2

3 / 35

Agent-Based Simulation Introduction to CA

What is a Cellular Automaton?

A discrete computational model Relevant in a number of elds


theoretical computer science mathematics biology physics engineering cryptography ...

Federico Pecora Agent-Based Simulation Part 2

4 / 35

Agent-Based Simulation Introduction to CA

What is a Cellular Automaton?


Regular n-dimensional grid of cells Each cell has nte number of states Each cell has a neighborhood consisting of other cells Time advance function: the state of a cell at time t in function of the state of the cells neighborhood at time t 1 Every cell shares the same time advance function At every tick (instant of discrete time), the rule is applied for all cells in the grid, and a new generation is formed Initial condition: all cells have the same state except for a given set of cells, called conguration

Federico Pecora Agent-Based Simulation Part 2

5 / 35

Agent-Based Simulation Introduction to CA

What is a Cellular Automaton?

states: 2 (full/empty cell) survival: 2 or 3 birth: 2 or 3

Federico Pecora Agent-Based Simulation Part 2

6 / 35

Agent-Based Simulation Introduction to CA

What is a Cellular Automaton?

states: 2 (full/empty cell) survival: 2 or 3 birth: 2 or 3

Federico Pecora Agent-Based Simulation Part 2

6 / 35

Agent-Based Simulation Introduction to CA

What is a Cellular Automaton?


states: 8 (colors in a spectrum)
Generations S23/B23/C8

survival: 2 or 3 birth: 2 or 3 colors: only rst state gives birth, others decay in color until they die

Federico Pecora Agent-Based Simulation Part 2

7 / 35

Agent-Based Simulation Introduction to CA

Rules and periodic bondary conditions

Assume an innite, 2-dimensional grid Assuming 2-state cells, we have for each cell 29 = 512 possible patterns Since we can only represent a nite grid, the cells on the borders are subject to periodic boundary conditions
cell coordinates are mod(N ) (wrap around both vertically and horizontally)

Federico Pecora Agent-Based Simulation Part 2

8 / 35

Agent-Based Simulation Introduction to CA

Properties of CA
Parallelism: individual cell updates are performed independently of each other all of the updates being done at once Locality: when a cell is updated, its new value is based solely on the values of its neighbors (and on the cells history in n-order CA) Homogeneity: each cell is updated according to the same rules CA are good models for physical, biological and sociological phenomena: each person/cell/small region of space updates itself independently (parallelism), based on its immediate surroundings (locality) and on some generally shared laws of change (homogeneity)

Federico Pecora Agent-Based Simulation Part 2

9 / 35

Agent-Based Simulation Introduction to CA

Properties of CA
Parallelism: individual cell updates are performed independently of each other all of the updates being done at once Locality: when a cell is updated, its new value is based solely on the values of its neighbors (and on the cells history in n-order CA) Homogeneity: each cell is updated according to the same rules CA are good models for physical, biological and sociological phenomena: each person/cell/small region of space updates itself independently (parallelism), based on its immediate surroundings (locality) and on some generally shared laws of change (homogeneity)

Federico Pecora Agent-Based Simulation Part 2

9 / 35

Agent-Based Simulation Simple CA (apparently)

Outline

Introduction to CA Simple CA (apparently) Other classes of CA Reversible CA Totalistic CA Applications of CA

Federico Pecora Agent-Based Simulation Part 2

10 / 35

Agent-Based Simulation Simple CA (apparently)

Conways Game of Life


Simple rules can lead to spectacular results! An example: Conways Game of Life A simple CA, with 2 states and the rule (aka S23/B3)
Any live cell with fewer than two live neighbours dies (loneliness) Any live cell with more than three live neighbours dies (overcrowding) Any live cell with two or three live neighbours lives Any dead cell with exactly three live neighbours comes to life

Due to John Horton Conway, british mathematician This is interesting for two reasons. . .

Federico Pecora Agent-Based Simulation Part 2

11 / 35

Agent-Based Simulation Simple CA (apparently)

Properties of Conways Game of Life (1)


There are no initial patterns for which there is a simple proof that the population can grow without limit There exist initial patterns that apparently grow without limit Ther exist simple initial patterns that grow and change for a long time before (a) fading away completely, or (b) going into a stable (static or oscillating) state
Pulsar (3-phase oscillator) Boat (still) Glider (spaceship)

Blinker (2-phase oscillator)

Federico Pecora Agent-Based Simulation Part 2

12 / 35

Agent-Based Simulation Simple CA (apparently)

Properties of Conways Game of Life (2)


In the 1940s, John von Neumann wanted to nd a hypothetical machine that could replicate itself He built a mathematical abstraction of a self-replicating robot (based on Stanisaw Ulams work on crystal growth models)
von Neumann proved that a particular pattern existed which could make endless copies of itself the von Neumann universal constructor

Conway simplied von Neumanns method into the GoL The GoL has the power of a universal Turing machine, i.e., anything that can be computed algorithmically can be computed within Conways GoL

Federico Pecora Agent-Based Simulation Part 2

13 / 35

Agent-Based Simulation Simple CA (apparently)

Properties of Conways Game of Life (2)


In the 1940s, John von Neumann wanted to nd a hypothetical machine that could replicate itself He built a mathematical abstraction of a self-replicating robot (based on Stanisaw Ulams work on crystal growth models)
von Neumann proved that a particular pattern existed which could make endless copies of itself the von Neumann universal constructor

Conway simplied von Neumanns method into the GoL The GoL has the power of a universal Turing machine, i.e., anything that can be computed algorithmically can be computed within Conways GoL

Federico Pecora Agent-Based Simulation Part 2

13 / 35

Agent-Based Simulation Simple CA (apparently)

Complex patterns from simple rules


The GoL (and CA in general) demonstrate how complex patters are obtainiable from very simple rules There exist oscillators of period 4, 8, 14, 15, 30, and a few others have been seen on rare occasions Methuselah patterns: less than 10 initial live cells that take longer than 50 generations to repeat
Acorn Diehard

dies after 130 generations

takes 5206 generations to generate at least 25 gliders and stabilise as many oscillators

Federico Pecora Agent-Based Simulation Part 2

14 / 35

Agent-Based Simulation Simple CA (apparently)

Even simpler CA

The simplest CA are one-dimensional, with two states per cell Neghborhood = two adjacent cells on either side 23 = 8 possibile patterns for a neighborhood 28 = 256 possible rules (256 possible CA) Each possible CA is identied in Wolfram notation as the decimal number which, in binary, gives the rule table
current pattern new state of middle cell 111 0 110 0 101 0 100 1 011 1 010 1 001 1 000 0

Federico Pecora Agent-Based Simulation Part 2

15 / 35

Agent-Based Simulation Simple CA (apparently)

Rule 30 (00011110)
Seed = one cell on

Generates apparent randomness, passes many random tests. . . . . . but there exist an innite number of input patterns that result in repeating patterns (e.g., 00001000111000, discovered by Matthew Cook)
Federico Pecora Agent-Based Simulation Part 2 16 / 35

Generations

Agent-Based Simulation Simple CA (apparently)

Rule 110 (01101110)


Seed = one cell on

Very simple structure, but difcult to obtain desired behaviors Of the 256 simple" CA, Rule 110 is the only one known to be Turing complete

Generations
Federico Pecora Agent-Based Simulation Part 2

17 / 35

Agent-Based Simulation Simple CA (apparently)

Rule 110 (01101110)


Like the GoL, Rule 110 is capable of universal computation

This has been used to suggest that many of the properties of many natural systems (e.g., patterns on some seashells) are undecidable
Federico Pecora Agent-Based Simulation Part 2 18 / 35

Agent-Based Simulation Other classes of CA

Outline

Introduction to CA Simple CA (apparently) Other classes of CA Reversible CA Totalistic CA Applications of CA

Federico Pecora Agent-Based Simulation Part 2

19 / 35

Agent-Based Simulation Other classes of CA Reversible CA

Reversible CA
A CA is reversible if its update function is bijective
the current conguration is obtainable by exactly one previous conguration

an irreversible CA is one for which there exist patterns for which there are no previous states these patterns are called Garden of Eden patterns

(Garden of Eden pattern for GoL)

Federico Pecora Agent-Based Simulation Part 2

20 / 35

Agent-Based Simulation Other classes of CA Reversible CA

Reversible CA
Any one-dimensional CA can be proved to be either reversible or irreversible For n-dimensional CA (n 2), reversability is undecidable i.e., there exist n-dimensional rules for which the complexity of
describing its inverse vastly exceeds the complexity of the rule itself i.e., the only way of proving it is to simulate!

There exist, however, methods to build a reversible CA from an existing rule


second-order technique vaious partitioning techniques, e.g., Margolus neighborhood

. . . although the properties of the original rule are lost

Federico Pecora Agent-Based Simulation Part 2

21 / 35

Agent-Based Simulation Other classes of CA Reversible CA

Reversible CA

Wait a minute. . . doesnt the opposite rule give the inverse CA?
111 0 111 1 110 0 110 1 101 0 101 1 100 1 100 0 011 1 011 0 010 1 010 0 001 1 001 0 000 0 000 1

Rule 30

Rule 225

Federico Pecora Agent-Based Simulation Part 2

22 / 35

Agent-Based Simulation Other classes of CA Reversible CA

Reversible CA

Wait a minute. . . doesnt the opposite rule give the inverse CA?

. . . the reverse step is not deterministic!

Federico Pecora Agent-Based Simulation Part 2

22 / 35

Agent-Based Simulation Other classes of CA Reversible CA

Second order technique


State at time t + 1 is function of neighborhood at time t and state of cell at time t 1

s(t + 1) = f (n(t)) s(t 1) s(t 1) = f (n(t)) s(t + 1)

Rule 30

111 0

110 0

101 0

100 1

011 1

010 1

001 1

000 0

Rule 30R
1 111 1 0 111 0 1 110 1 0 110 0 1 101 1 0 101 0 1 100 0 0 100 1 1 011 0 0 011 1 1 010 0 0 010 1 1 001 0 0 001 1 1 000 1 0 000 0

(t 1) t (t + 1) (t 1) t (t + 1)

Federico Pecora Agent-Based Simulation Part 2

23 / 35

Agent-Based Simulation Other classes of CA Reversible CA

Second order technique


State at time t + 1 is function of neighborhood at time t and state of cell at time t 1

s(t + 1) = f (n(t)) s(t 1) s(t 1) = f (n(t)) s(t + 1)

Rule 30

111 0

110 0

101 0

100 1

011 1

010 1

001 1

000 0

Rule 30R
1 111 1 0 111 0 1 110 1 0 110 0 1 101 1 0 101 0 1 100 0 0 100 1 1 011 0 0 011 1 1 010 0 0 010 1 1 001 0 0 001 1 1 000 1 0 000 0

(t 1) t (t + 1) (t 1) t (t + 1)

Federico Pecora Agent-Based Simulation Part 2

23 / 35

Agent-Based Simulation Other classes of CA Reversible CA

Rule 30R

Federico Pecora Agent-Based Simulation Part 2

24 / 35

Agent-Based Simulation Other classes of CA Totalistic CA

Totalistic CA
The state of each cell is represented by a number State at time t depends only on the sum of the values of the cells in its neighborhood at time t 1
outer totalistic CA: neighborhood does not contain the cell itself totalistic CA: neighborhood does contains the cell itself

GoL is an outer totalistic CA with values 0 and 1


Generations S0235678/B3468/C9

Federico Pecora Agent-Based Simulation Part 2

25 / 35

Agent-Based Simulation Applications of CA

Outline

Introduction to CA Simple CA (apparently) Other classes of CA Reversible CA Totalistic CA Applications of CA

Federico Pecora Agent-Based Simulation Part 2

26 / 35

Agent-Based Simulation Applications of CA

CA-based encryption

Low speed of encryption and/or decryption causes big problems for practical implementations CA are inherently parallel
easy to implement on distributed processing platforms

Some CA exhibit strong irregularities


e.g., Wolframs rule 30

Reversible CA can be used as backdoor functions


computing f () is easy, computing f 1 () is difcult

Federico Pecora Agent-Based Simulation Part 2

27 / 35

Agent-Based Simulation Applications of CA

Stream ciphers with Rule 30


Cryptotext
28 / 35

Clear text

Stream cipher: a symmetric key cipher where plain text is combined with PRNG bitstream Wolframs Rule 30 does not repeat for any short period and has no obvious structure The central column of Rule 30 has been subject to many randomness tests, and has passed every one so far Cryptotext: combination (e.g., XOR) of clear stream with a column from Rule 30

XOR

Federico Pecora Agent-Based Simulation Part 2

Rule 30 column

Agent-Based Simulation Applications of CA

Encryption with reversible CA


Asymmetric cipher: the key used to encrypt a message differs from the key used to decrypt
e.g., public key cryptography

It is undecidable if a 2D CA is invertible it can be very difcult to invert a 2D CA Use the message to encrypt as initial conguration for a reversible CA A Cryptotext: conguration of A at generation n (n xed or depending on size of message) Keys: A is public key, A 1 is private key
it seems possible to obtain such difcult to invert CA by combining several simply invertible CA

Federico Pecora Agent-Based Simulation Part 2

29 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses

Reversible CA can be employed to simulate gasses Homogeneity: every molecule follows one rule Locality: each molecule affects its neighbors only, not others far away from it Reversibility: all information the motion of molecules is backward traceable In gasses, heat entails the motion of molecules As in CA, the randomness (entropy) of the system increases . . . gasses look like reversible CA!

Federico Pecora Agent-Based Simulation Part 2

30 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 1

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 1

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 2

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 2

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 3

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 3

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 4

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 4

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 5

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 5

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 6

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 6

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 7

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


Hardy, de Pozzis, Pomeau (HPP) gas model Rules are based on Margulos Neighbourhood: 2 2 partitioning of the lattice which alternates at every time step Rules Step 7

Federico Pecora Agent-Based Simulation Part 2

31 / 35

Agent-Based Simulation Applications of CA

Reversible CA for gasses


HPP gas model already comes close to Navier-Stokes equation
realistic simulation of gasses

More precise models allow movements in more than four directions


e.g., FHP (Fritsch, Hasslacher, Pomeau) model, allows movements of particles in six directions used to simulate aerodynamics
Solute around obstacles Poiseiulle ow

Federico Pecora Agent-Based Simulation Part 2

32 / 35

Agent-Based Simulation Applications of CA

CA simulation of epidemics
Cells have 3 states: susceptible, infected, immune A susceptible cell with neighboring infected cell
becomes infected with probability
SIR Epidemic model

p
becomes immune with probability

1p Rate of spread depends on susceptibility to virus p


denition of neighborhood

Equivalent to forest re model

Federico Pecora Agent-Based Simulation Part 2

33 / 35

Agent-Based Simulation Applications of CA

CA simulation of epidemics
Cells have 3 states: susceptible, infected, immune A susceptible cell with neighboring infected cell
becomes infected with probability
SIR Epidemic model

p
becomes immune with probability

1p Rate of spread depends on susceptibility to virus p


denition of neighborhood

Equivalent to forest re model

Federico Pecora Agent-Based Simulation Part 2

33 / 35

Agent-Based Simulation Applications of CA

CA simulation of trafc ow
Dynamics of vehicles represented in coarse-grained way Space and time are discretized One dimensional toroid grid Emergence of stop-and-go behavior from injection of simple non-determinism
slowdown probability slow-to-start rules
Nagel-Schreckenberg model

An interesting example of agent-like CA

Federico Pecora Agent-Based Simulation Part 2

34 / 35

Agent-Based Simulation Applications of CA

Cellular Automata

Thank you!

Federico Pecora Agent-Based Simulation Part 2

35 / 35

Agent-Based Simulation References

References

Federico Pecora Agent-Based Simulation Part 2

35 / 35

You might also like