Cellular Automata

advertisement
Cellular Automata
Cellular Automata?
• CA are computer simulations that try to emulate
the way the laws of nature are supposed to
work in nature.
• They can help us explore if the reductionist
approach that scientific research has taken is
actually realistic.
Why CA?
• Can we really imagine our fascinating, complex
and seemingly random world as created by a
small set of relatively simple rules?
• rough way nature emulation
• they can give us an idea of how reasonable the
thought of a world governed by simple rules is
Short History
• CA were the invention of
John von Neumann
around 1950 following a
suggestion of Stan Ulam
• von Neumann was looking
for a model of computation
that could act on its own
“matter”
World Before CA
• Before von Neumann’s CA, the
standard model of computation
was the Turing machine
• A Turing machine is a model of
computation named after Alan
Turing, a British mathematician
who helped break the German’s
Secret “Enigma” codes in WWII
Universal Turing Machines
Data
(e.g., resignation letter)
Program
(e.g., Microsoft Word)
Are they really this different?
No, they’re all just 0s and 1s!
Is CA Better than TM?
• TM cannot alter themselves
• TM cannot build other computers although they can
simulate other TMs
• Although TMs are a standard model of computation,
they do not mirror the behavior of complex systems
– Turing Machines do not have feedback mechanisms to alter
their own behavior
• A CA has the capability of altering itself – it does not
have a distinction between structural parts and data,
TM differs program and its data
Stephen Wolfram
•
•
•
•
•
•
•
•
•
Key CA researcher
Born in 1959 in London
First paper at age 15
Ph.D. at 20
Youngest recipient of MacArthur ‘young genius’ award
Worked at Caltech and Princeton
Owner of Mathematica (Wolfram Research)
Fantastic publication record … until …
1988 when he stopped publishing in scientific journals
CA decomposition
• Domain
– 1D: row, ring
– 2D: rectangle, torus, …
– 3D: volume
•
•
•
•
•
•
Cell = domain element
Neighborhood
Cell state
Initial state (condition)
Cell program (rule)
Discrete time evolution
Most Simple CA
• 1D binary row domain
• Neighborhood = cell itself
Line
Rule
Time 0
Time 1
Time 2
The first line is always
given. This is what is
called the ‘initial condition’.
This rule is trivial. It means black remains black and
grey remains grey.
This is how the Cellular
Automaton evolves
1D Binary Cellular Automata
• 2 states
• Neighborhood of 1 cell
– 22 possible programs
– No space dependence  a bit boring
• Neighborhood of 2 cells
– elementary space dependence
– 24 possible programs
• Neighborhood of 3 cells
– mostly used
– Sufficient space dependence
Wolfram’s 1D Binary CA
• Program example
• Neighbourhood combnations
• 28 possible rules (programs)
The Wolfram Nomenclature
• Rule = number  0,255
• Example: rule 90
= 2+8+16+64 = 90
Rule 254
• Rule:
254:
• Initial condition:
• Applying the rule 254:
Rule 254 Evolution
254:
Time 0
Time 1
Time 2
Time 3
Rule 90
• What does this form?
Rule 90:
• Initial condition
Guess the Pattern!
Rule 90 Evolution
9 Time Steps
Rule 90 Ad Infinitum
• Sierpinski Gasket Pattern
Irregular Patterns?
• Rule 30
Rule 30:
Applying Rule 30
30:
Rule 30 Evolution
Rule 30 Ad Infinitum
While one side has
repetitive patterns,
the other side
appears random.
Zoom of the Regular Region
Zoom of the Random Area
Other Rules
Rule Atlas (1)
Rule Atlas (2)
Rule Atlas (3)
• 256 rules
• Same initial condition
2D Cellular Automata
• Torus domain
Right neighbour is left edge cell
Bottom neighbour is
top edge cell
2D Binary CA
• Domain = torus bitmap
• Neighbourhood
– cell and its 4 (Von Neumann) or 8 neighbors (Moore)
– 4-neighborhood used mostly
• Program = 25 binary vector
• 232 possible programs (transition rules)
Well Known Instance:
Conway’s Game of Life
John H. Conway
Life Rules
• Each step: cell lives or dies
• Alive Cell = 1, Dead cell = 0
• Three simple rules
– dies if # of alive neighbour cells =< 2
(loneliness)
– dies if # of alive neighbour cells >= 5 (overcrowding)
– lives is # of alive neighbour cells = 3
(procreation)
Rule Examples
• loneliness
(dies if #alive =< 2)
• overcrowding
(dies if #alive >= 5)
• procreation
(lives if #alive = 3)
Life Patterns
Stable
Periodic
Moving
Majority Rule
• 1 if 5 or more Moore neighbours and self are 1,
• 0 if 5 or more Moore neighbours and self are 0
• Initial state: white noise (~50 % & zeroes)
→
Random Majority Rule
• if 4 neighbours 0 and 4 1, new state random
→
Multistate 2D CA Patterns
The Segregation Model
• Grid 500 by 500
• 1500 agents, 1050 green, 450 red
– 1000 vacant patches
• Each agent has a tolerance
– A green agent is ‘happy’ when the ratio of greens to
reds in its Moore neighbourhood is more than its
tolerance
– and vice versa for reds
Aggregation
• Randomly allocate reds and greens to patches
• With a tolerance of 40%:
– An agent is happy when more than 3/8 ( = 37.5%) of
its neighbours are of the same colour
• Then the average number of neighbours of the
same colour is 58% (about 5)
• And about 18% of the agents are unhappy
Tipping
• Unhappy agents move along a random walk to
a patch where they are happy
• Emergence is a result of ‘tipping’
– If one red enters a neighbourhood with 2 reds
already there, a previously happy green will become
unhappy and move elsewhere, either contributing to
a green cluster or possibly upsetting previously
happy reds and so on…
Emergence
• Values of tolerance above 30%
give clear display of clustering:
‘ghettos’
• Even though agents tolerate 30%
of their neighbours being of the
other colour in their
neighbourhood, the average
percentage of same-colour
neighbours is typically 75 - 80%
after everyone has moved to a
satisfactory location (risen from
58% before relocations)
Dynamic Social Impact
for individual a, impact of ‘supporters’, ias
is
2
j N
S j 
ias    2 
daj 
j 1 
and the same for the impact of
‘opposers’, iao
agent a changes state if iao > ias
Social Impact Patterns
Random starting attitudes,
with 30% white
Final (stable) attitudes,
with 16% white
More from the Game Theory
The Prisoner’s
Dilemma
A co-operates
A defects
(doesn’t confess) (confesses)
Length of
time in
prison
B defects
(confesses)
B co-operates
(doesn’t confess)
3
3
5
0
0
5
1
1
Playing the Game Once
B defects
(confesses)
B co-operates
(doesn’t confess)
A defects
(confesses)
3
3
A co-operates
(doesn’t confess)
• The rational action is to confess,
regardless of the other’s choice
(obtaining a sentence of 3 years rather
than 5, or no prison rather than 1 year).
• Therefore both choose to confess,
going to prison for 3 years, although if
both refused to confess, they would
both be sentenced to only 1 year in
prison.
5
0
0
5
1
1
Iterated Prisoner’s Dilemma
• If the same people repeatedly play the IPD
game, they can learn the other’s strategy.
• What’s the best strategy? Tit-for-Tat
• 1st move: cooperate
• subsequent move: copy opponent’s previous move
– Tit-for-tat is best against other strategies, provided
that there is no noise (perfect communication)
• Note that this assumes that agents can
recognise each other
– Not a trivial requirement
Evolving strategies
• 10002 agents arranged in a grid. At every step, each
agent plays an IPD with a large random sample of other
agents.
• Each agent remembers the last three moves of its IPD
opponent and follows one of the 215 possible different
strategies
• At the end of each step, an agent randomly finds
another and switches to the other agent’s strategy if that
is better (higher total payoff)
• Calculation of difference between payoff is subject to
noise
• New strategies mutate (noisy transmission)
Lattice Gas Cellular Automata
Example : HPP (Hardy, Pomeau, de Pazzis; 1986)
(Historical model: suffers from inconsistensies at a macroscopical
level)
• Dynamics of boolean
quantities on a regular
lattice.
• The evolution is
synchronous and based on
discrete time steps.
Max. 4 particles at each lattice site,
Unitary speed in the particle’s direction
HPP Collision Rules
Time t
Time t+t
Free ballistic motion without
collision.
• Two particles experiencing a headon collision are deflected in a
perpendicular direction
• All other situations: no collision
Evaluation of a LGCA
Discrete particle distribution
Averaged “macroscopical” values
• Realistic macroscopical fluid dynamics are obtained
when the lattice is fine enough.
• Problem : averaging over big lattice domains needed.
From LGCA to LBM
Idea : implement the dynamics directly on the average values.
Advantages :
LGCA: Boolean quantities ni
• One lattice node represents particle
densities: discrete dynamics are replaced by
a smooth flow.
• Less averaging needed, increased
performance.
Disadvantages :
• Higher order correlations between
particles are neglected.
• Numerical instabilities appear.
LBM: Real-valued quantities fi
LGCA Examples
CA Binary Textures
•
•
•
•
•
Texture = visualization of the CA state
NetLogo, StarLogo systems = IDE for CA
General Language for CA?
Raw language = Wolfram’s nomenclature
Most simple
– torus domain
– binary state
– 4-neighborhood
Binary CA Programs
• www.cg.tuwien.ac.at/studentwork/CESCG/CESCG-2000/PBorovsky
• Cell + 4 neigbours = 5-bit neighborhood
• Program = 25 bits
• How many such binary CA program there are?
• 232 (4 294 967 296) possible programs
Random Program Generation
• Program = 32-bit
number
• Random generation
• Initial state = ?
– white noise
(statistical balance)
• Patterns = ?
– Complex images
– e.g. reaction-diffusion
Nice Pattern Recognition
• Nearly 20 % of random programs
 interesting pattern
• Characteristics of these programs = ?
• One possibility = study of convergence
• System = repeating, if it repeats a sequence of
states (after finite evolution)
• Convergent system = 1 state repetition
Convergence Determinition
•
•
•
•
Reverse pattern completing algorithm
Input = program, output = converges / not
Filling the space with the stable rules
Stable rule do not change the neighbourhood
• Filling the space by 0 and 1 (substitution of “?”)
• Initial condition = the final stable pattern
Randomness on any CA?
• Binary automata = 32-bit programs
– CA Interpreter: 32 cases in the neighborhood
• More states for color textures
• 256 states  240-bit programs
– CA Interpreter: too much cases in the neighborhood
– Impossible to interpret the programs in the Wolframs
format
• Other language for CA?
– Simple syntax
– Easy to code
– Easy to generate random programs
CA Language Proposal
• Cell:
– State = floating-point variable (color)
– Multiple states (at least 6 states for reaction-diffusion)
– Ability to read variables from 8 neighbors
• Program
– Set of rules for each variable
– Evolution from time 0
– Variable ‘random’ (e.g. initial state)
• CA extension
– Cell knows its position (x,y), time, …
Texture Language Proposal
TLA Program Example
• Averaged Noise in TLA
•
•
•
•
Uses 1 variable
Rule = conditional
Access of other cells: left[i], right[i],…
Access of own cell: center[i]
TLA Interpreter
• Slightly different conditional than in C/C++
– Never returns from nested branch
• Visualization
– Layers
– Layer i = variable i
– Greyscale adaptive palette
TLA Usage
•
•
•
•
Noises
Reaction-diffusion
Implicit phenomena
Unsuitable
– Explicit objects
– e.g. midpoint diamond
Download