Introduction To Artificial Intelligence
Introduction To Artificial Intelligence
wCD
Hopfield Memories
• Setting the weights:
– A pattern is a setting of on or off for each unit
– Weights are adjusted so they strengthen connections to
other units that are turned on at the same time,
weakened if they are turned off at the same time
• Demo
– http://www.cbu.edu/~pong/ai/hopfield/hopfield
applet.html
Evolution in Computers
• Genetic Algorithms – most widely known
work by John Holland
• Form of machine learning
• Based on Darwinian Evolution
– In a competitive environment, strongest, “most
fit” of a species survive, weak die
– Survivors pass their good genes on to offspring
– Occasional mutation
Evolution in Computers
• Same idea in computers
– Population of computer program / solution
treated like the critters above, typically encoded
as a bit string
– Survival Instinct – have computer programs
compete with one another in some
environment, evolve with mutation and sexual
recombination
GA’s for Computer Problems
Population of critters Population of computer solutions
Surviving in environment Solving computer problem
Fitness measure in nature Fitness measure solving computer
problem
Fit individuals life, poor die Play God and kill computer solutions
that do poorly, keep those that do well.
i.e. “breed” the best solutions typically
Fitness Proportionate Reduction
Pass genes along via mating Pass genes along through
computer mating
Repeat process, getting more and more fit individuals
in each generation.
Usually represent computer solutions as bit strings.
The Simple Genetic Algorithm
1. Generate an initial random population of M
individuals (i.e. programs or solutions)
2. Repeat for N generations
1. Calculate a numeric fitness for each individual
2. Repeat until there are M individuals in the new
population
1. Choose two parents from the current population
probabilistically based on fitness (i.e. those with a higher
fitness are more likely to be selected)
2. Cross them over at random points, i.e. generate children based
on parents (note external copy routine)
3. Mutate with some small probability
4. Put offspring into the new population
Crossover
Typically use bit strings, but could use other structures
Bit Strings: Genotype representing some phenotype
Individual 1: 001010001 Individual 2: 100110110
New child : 100110001 has characteristics of
both parents, hopefully
better than before
Bit string can represent whatever we want for our particular
problem; solution to a complex equation, logic problem,
classification of some data, aesthetic art, music, etc.
Example : Traveling Salesman Problem
• 29 Node Traveling Salesperson
Problem
• 29! = 8.8 trillion billion billion
possible asymmetric routes.
• ASCI White, an IBM
supercomputer being used by
Lawrence Livermore National
Labs to model nuclear explosions,
is capable of 12 trillion operations
per second (TeraFLOPS) peak
throughput
• Assuming symmetric routes,
ASCI White would take 11.7
billion years to exhaustively
search the solution space
• A genetic algorithm approach
– Randomly generate a population of solutions
• Each solution represents an entire solution, i.e. a random
ordering of nodes representing a loop
– Given nodes 1-6, we might generate 423651 to represent the
loop of visiting 4 first, then 2, then 3, then 6, then 5, then 1,
then back to 4
– Assign each solution a fitness value
• Fitness is just the sum of the distance for edges in the
loop; lower is more fit
– Evolve a new, hopefully better, generation of the
same number of agents
• Select two parents randomly, but higher probability of
selection if better fitness
• New generation formed by crossover and mutation
• Crossover
– Must combine parents in a way that preserves valid
loops
– Typical cross method, but invalid for this problem
Parent 1 = 423651 Parent 2 = 156234
Child 1 = 423234 Child 2 = 156651
– Use a form of order-preserving crossover:
Parent 1 = 423651 Parent 2 = 156234
Child 1 = 123654
• Copy positions over directly from one parent, fill in from
left to right from other parent if not already in the child
• Mutation
– Randomly swap nodes (may or may not be
neighbors)
• Traveling Salesman Applet:
• Smart Rockets
– http://www.blprnt.com/smartrockets/