27
Cellular Automaton, Genetic Algorithms, and Neural Networks Catherine Beauchemin, Department of Physics, University of Alberta January 30, 2004

Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Cellular Automaton, GeneticAlgorithms, and Neural Networks

Catherine Beauchemin,Department of Physics,University of Alberta

January 30, 2004

Page 2: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Overview

Cellular Automaton• What is a cellular automaton?• A simple cellular automaton: Wolfram’s 1-D cellular automaton• A more complex cellular automaton: a viral infection model• MASyV: a cellular automaton visualization tool

Genetic Algorithms• What are genetic algorithms?• A simple genetic algorithm• Other applications for genetic algorithms

Artificial Neural Networks• What are artificial neural networks?• Applications for artificial neural networks

Page 3: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

What is a cellular automaton ?

• Cellular automata (CA) were originally introduced by John von Neu-mann and Stanislas Ulam under the name of “cellular spaces” as pos-sible idealization of biological systems.

• A typical CA consists of a regular lattice. The lattice contains a dis-crete variable or “cell” at each site, that can assumem possible dis-crete values.

• The state of a CA is completely specified by the values of the vari-ables at each site. The CA evolves in discrete time steps, with thevalue of a variable at a given site being affected by the values ofvariables at sites in its “neighborhood” on the previous time step.

• At a new time step, the variables at all sites are updated simultane-ously, based on the values of the variables and their defined “neigh-borhood” at the preceding time step, and according to a definite setof local rules.

Page 4: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

A simple CA: Wolfram’s 1-D CAWolfram concentrated most of his work on 1-D CA with only two pos-sible state at each site: dead or alive (0 or 1). The neighborhood wascomposed of the cell itself plus its two immediate neighbours. Rules canbe expressed as 8 digit binary numbers in the following manner:

111 110 101 100 011 010 001 0000 1 0 1 1 0 1 0

The above rule is Rule 90. Recall that a binary number can be expressedin base 10 in the following manner:

01011010 = 0·27+1·26+0·25+1·24+1·23+0·22+1·21+0·20 = 90

Of the 256 possible rules, only 32 rules are considered “legal”. Thebiological origins of the CA impose certain restrictions

• The rule must be symetrical (110 and 011 must yield the same thing)

• Only life can generate life (000 must yield 0)

Page 5: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Evolution of various rules in timeWhen initially seeded with only one non-zero seed, the behaviour of the32 legal rules can be divided into 4 types (disapear with time, merelycopies the non-zero cell forever, yields a completely uniform type of rowor pairs of rows, develop nontrivial patterns). Each pattern below is theresult of rules 128 (10000000), 36 (00100100), 250 (11111010), and 90(01011010) respectively.

Page 6: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

A more complex CA: a viral infection modelA model I developed to explore whether spatial inhomogeneities such aslocalized populations of dead cells might adversely affect the spread ofinfection, similar to the manner in which a counter-fire can stop a forestfire from spreading

• The model considers 2 species: epithelial cells, which are the targetof the viral infection, and immune cells which fight the infection

• The CA is run on a two-dimensional square lattice where each siterepresents one epithelial cell

• Immune cells are mobile, moving from one lattice site to another, andtheir population size is not constant: the CA lattice is therefore likea tissue of immobile cells which is patrolled by the mobile immunecells

• The CA is updated synchronously and the boundary conditions forboth the epithelial and immune cells are toroidal

• The virus particles are not explicitly considered, rather the infectionis modelled as spreading directly from one epithelial cell to another

Page 7: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

The CA model: the epithelial cells

An epithelial cell can be in any of five states: healthy, infected, express-ing, infectious, or dead. Transitions between epithelial cell states occuras follows:

• Epithelial cells of all states become dead when they are older thanCELL LIFESPAN.

• A healthy epithelial cell becomes infected with probabilityINFECT RATE/(8 nearest neighbours) for each infectious nearestneighbour.

• An infected cell becomes expressing, i.e. begins expressing the viralpeptide, after having been infected forEXPRESSDELAY.

• An expressing cell becomes infectious after having been infected forINFECT DELAY> EXPRESSDELAY.

• Infected, expressing, and infectious cells become dead after havingbeen infected forINFECT LIFESPAN.

Page 8: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

The CA model: the epithelial cells

Continued...

• Expressing and infectious cells become dead when “recognized” byan immune cell. See below for the meaning of “recognition.”

• A dead cell is revived at a rateDIVISION TIME−1 ×# healthy/# dead. When revived, a dead cell be-comes a healthy cell or an infected cell with probabilityINFECT RATE/(8 nearest neighbours) for each infectious near-est neighbour.

A simulation is initialized with each epithelial cell being assigned arandom age between 0 andCELL LIFESPAN inclusively. All epithe-lial cells start in the healthy state with the exception of a fractionIN-FECT INIT of the total number of epithelial cells which, chosen at ran-dom, are set to the infected state.

Page 9: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

The CA model: the immune cells

An immune cell can be in any of two states: virgin or mature. A virgincell is an immune cell that has no specificity. A mature cell is an im-mune cell that has either already encoutered an infected cell or has beenrecruited by another mature immune cell.

• Immune cells move randomly on the CA lattice at a speed of onelattice site per time step.

• An immune cell is removed if it is older thanIMM LIFESPAN.

• An encounter between an immune cell and an expressing or infec-tious epithelial cell requires the immune cell to be in the same site asthe expressing or infectious cell.

• A virgin immune cell becomes a mature immune cell if the latticesite it is occupying is in the expressing or infectious states.

Page 10: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

The CA model: the immune cells

Continued ...

• A mature immune cell occupying an expressing or infectious latticesite “recognizes” the epithelial cell and causes it to become dead.

• Each recognition event causesRECRUITMENTmature immune cellsto be added at random sites on the CA lattice after a delay ofRE-CRUIT DELAY.

• Virgin immune cells are added at random lattice sites as needed tomaintain a minimum density ofBASEIMM CELL virgin immunecells.

A simulation is initialzed with a density ofBASEIMM CELL virgin im-mune cells at random locations on the CA lattice, each with a randomage.

Page 11: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Viral infection model: quantitative results

0 24 48 72 96 120 144 168 192 216 240 264 288time (h)

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1%

tota

l cel

ls

Page 12: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

MASyV: a visualization toolMASyVstands for Multi-Agent System Visualization. It is a powerfulgeneral purpose user interface accompanied by a message passing li-brary. It enables one to write cellular automaton simulations programsand visualize them with very little additional time and effort. The sim-ulation (client) and the user interface (server) interact via UNIX domainsockets using the message passing library. Simulation runs can be savedas movies through the use oftranscode .

MASyVrequires:

• GTK+ 2.0 or higher

• anOpenGLcompatible library

• as well asGtkGLExt , anOpenGLwidget forGTK+.

MASyVcomes with a few client modules which stand as good examplesof how to write a client module and how to use the message passinglibrary.

MASyV is distributed under the GNU General Public License and ishosted on SourceForge (http://masyv.sourceforge.net ).

Page 13: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Visualizing a few simulations• The simple Wolfram 1-D CA

• A simple model of gas diffusion

• The viral infection CA model

• Ants moving around depositing pheromone trails

Page 14: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Applications of CA

When to use a CA?• ODEs are better when simple enough to be analytically solved such

that the parameters space can be explored theoretically.• With a CA, adding complexity such as delays, nonlinearities, and

stage-classes does not introduce greater difficulty in solving it as isthe case with ODE but the parameter space has to be explored bybrute force.

• A CA offers a natural description of the physical system. There isgood correspondance between the CA’s parameters and measurablequantities.

Why would a Medical Physics student want to use a CA ?

• To model the dynamics of a particular disease where spatial inhomo-geneities are important (e.g. Cancer)

• Where non-linearities and age classes would make a differentialequation model too “messy”

Page 15: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

What is a genetic algorithm ?Genetic algorithms (GA) were invented by John Holland in the 1960s inorder to:

• formally study the phenomenon of adaptation as it occurs in nature

• develop ways in which the mechanisms of natural adaptation mightbe imported into computer systems.

Now, GAs have evoluved into a class of algorithms typically used tosolve optimization problems.

Biological terms are used in GA research in the spirit of analogy with thereal biological system. A population consists ofchromosomeswhichare strings ofgeneseach of which can take on different values calledalleles. Each gene is located at a particularlocus(position or site) on thechromosome and the particular sequence of genes of a chromosome iscalled agenotype. Chromosome from a population are selected for thefitnessof their genotype to a particular problem and the most fit pair ofindividuals get to reproduce. Each pair of individuals will produce a pairof offspring and the process can involvecrossoversor mutations.

Page 16: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

A simple genetic algorithm1. Start with a randomly generated population ofn l-bit chromosomes.

2. Calculate the fitness of each chromosome in the population.

3. Repeat the following untiln chromosomes have been created:

(a) Select a pair of parent chromosome from the population (withreplacement) with the probability of selection being an increasingfunction of fitness.

(b) With a probabilitypC, cross over the pair at a randomly chosenlocus. If no crossover occurs, the offspring will be exact copiesof the parents.

(c) Mutate the 2 offsprings at each locus with probabilitypM andplace the resulting offspring in the new population

4. If n is odd, one new population member is discarded at random.

5. Replace the current population with the new population.

6. Go back to step 2.

Each iteration of this process is called agenerationand the entire set ofgenerations is called arun .

Page 17: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

A simple GA exampleLet us consider a population ofn = 4 chromosomes made up ofl = 8genes, each of which have2 alleles: 0 and 1. With a goal to evolve thechromosome11111111, let us define the fitness function as being thenumber of 1s in the chromosome.

Chromosome label Chromosome string FitnessA 00000110 2B 11101110 6C 00100000 1D 00110100 3

A common selection method isfitness-proportionate selectionwhere theprobability that a chromosome will reproduce is equal to its fitness di-vided by the average fitness of the population.

Let’s say the pair (B,D) and (B,C) were selected. Say parents B andD cross over after the 1st bit to yield offsprings E=10110100 andF=01101110 and parents B and C do not.

Page 18: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

A simple GA example (continued)Next mutation is applied, E=10110100 is mutated at the 6th locus toyield E′=10110000, B=11101110 is mutated at the 1st locus to yieldB′=01101110, and F=01101110 and C=00100000 are not mutated. Thenew generation is

Chromosome label Chromosome string FitnessE′ 10110000 3F 01101110 5C 00100000 1B′ 01101110 5

Although the best string was lost (B=11101110), the average fitness rosefrom 12/4 to 14/4. Repeating the procedure will eventually result in astring with all 1s.

Page 19: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Common GA terminology(Hamming) DistanceThe distance between two chromosomes is de-

fined as the number of loci at which the chromosome’s genotypesdiffer. When the chromosomes are composed of bits, this distance isrefered to as the Hamming distance. E.g. Chromosomes 10000 and00001 have a Hamming distance of 2.

Fitness LandscapeOriginally defined by the biologist Sewell Wright(1931) in the context of population genetics, a fitness landscape is arepresentation of the space of all possible genotypes along with theirfitness. In other word, a fitness landscape forl-gene chromosomeswould be anl+1-dimensional plot in which each genotype is a pointin l dimensions and its fitness is plotted along the (l + 1)st axis. TheGA provides the way in which to patrol this fitness landscape to findlocal minima.

Page 20: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Applications of GAs

When to use a GA?

• When you want to take advantage of evolutionary rules to evolve asolution to an optimization problem

• When you want to model the process of evolution of a system

• Preferably when your problem can be expressed in terms of a char-acter string (although aparently, even this problem can be overcome)

Why would a Medical Physics student want to use a GA?

• To find a sequence of amino acid that would fold to a desired three-dimensional protein structure

• To model the phenomenon of escape mutants with a given pathogenin order to determine the mutation parameterspC andpM specific tothat pathogen

Page 21: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

What are artificial neural networks ?Artificial neural networks (ANNs) are inspired by the way biologicalnervous systems, such as the brain, process information.

• Like the brain an ANN is composed of a large number of highlyinterconnected processing elements (neurones) working in unison tosolve specific problems.

• ANNs like people, learn by example. There are two types of train-ing used in ANNs, with different types of networks using differenttypes of training. These aresupervisedandunsupervisedtraining,of which supervised is the most common.

• An ANN is configured for a specific application, such as patternrecognition or data classification, through a learning process.

• Just like biological systems, learning in ANNs involves adjustmentsto the synaptic connections that exist between the neurones.

Page 22: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Real neurons VS artificial neurons

TerminalSynaptic

Dendrites

SomaAxon

u(w x , w x , ... , w x )x2

x 1

xn

W2

W1

Wn

f

f(u)1 1 2 2 n n

u

summation function transfer function

Page 23: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

A simple ANN example: the OR gateLet’s say we want our ANN to learn to emulate an OR gate:

x1 x2 d (desired output)0 0 00 1 11 0 11 1 1

Let’s pick our summation and transfer (or activation) functions to be

u =

2∑i=1

wixi,

f (u) =

{0 u < θ

1 u ≥ θ

respectively. Let us pick a correction function that adds (or subtracts)0.1to wi whenf (u) is smaller (or greater) thand, wheneverxi is non-zero.

Page 24: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Linear separation in single node networksSince the critical condition for classification occurs when the result ofthe summation equals the threshold of the transfer function, let us put thesummation equal to the threshold, this means

∑2i=1 wixi = θ. In the 2-D

case we are consideringw1x1 + w2x2 = θ so that

x2 = −(

w1

w2

)x1 +

w2

).

Yielding

x 1

x 2

θw1

θw2

(0,0)

(0,1) (1,1)

(1,0)

Page 25: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

More complex separationsFor more complex separations, one needs a more complex ANN

L2

L4 L3

L1

X1 X2

P1 P2

P3

1 hidden layer

P1

Y

P3P2

L4L3L2L1

Y

X2X1

2 hidden layers

Page 26: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Applications of ANNs

When to use ANNs ?

• When you know (or strongly suspect) that there is a relationship be-tween the proposed known inputs and unknown outputs. This rela-tionship may be noisy but it must exist.

• When you don’t know the exact nature of the relationship betweeninputs and outputs. Otherwise, you should model it directly.

• When you don’t care how it works and you just want it to work.

Why would a Medical Physics student want to use an ANN?

• Data mining, i.e. classifying large databases of protein sequencesbased on various criterion

• Recognition of patterns in X-Rays or MRI scans to enhance key in-formation from apparently fuzzy images or to formulate diagnosis

• Recognition of complex combinations of changes in health indices(e.g. heart rate, levels of various substances in the blood) could allowone to predict the onset of a particular medical condition

Page 27: Cellular Automaton, Genetic Algorithms, and Neural Networkscbeau/docs/medphys-04.pdf · Overview Cellular Automaton • What is a cellular automaton? • A simple cellular automaton:

Where to find information and links:

On cellular automaton

Cellular automaton and statistical mechanics, online athttp://www.phys.ualberta.ca/ ∼cbeau/docs/statmech.pdf

MASyV on Sourceforge and movie files from maimmune

http://masyv.sourceforge.net

On genetic algorithms

M. Mitchell. An introduction to genetic algorithms, TheMIT Press, Cambridge, Massachusetts, 1996.

A good introduction to immunology for physicists

A.S. Perelson, G. Weisbuch.Immunology for physicists,Reviews of Modern Physics, 69(4):1219-1267, 1997.