You are on page 1of 15

INTRODUCTION TO

ARTIFICIAL INTELLIGENCE
FOR IT & NON-IT PROFESSIONALS
GENETIC ALGORITHMS AS PARALLEL SEARCH

• Info about the tree traversal was stored in memory in queues


• Thus we know the links that can lead to the goal/s
• However, sometimes we don’t really need to remember the links that
were followed.

2
GENETIC ALGORITHMS AS PARALLEL SEARCH

• Problems where requirements are not clearly defined, we


don’t exactly know the Initial State, Goal State, and
operators etc,
• Interestingly, we can follow a parallel approach to search, in
order to speed up

3
GENETIC ALGORITHMS AS PARALLEL SEARCH

• Suppose we were to climb up a hill.


• Our goal is to reach the top irrespective of how we get there.

4
GENETIC ALGORITHMS

• Genetic Algorithms is a search method in which multiple search paths


are followed in parallel.
GENETIC ALGORITHMS AS PARALLEL
SEARCH
• A very basic GA is stated as follows:
1. Start with a population of randomly generated, (attempted) solutions to
a problem
2. Repeatedly do the following:
3. Evaluate each of the attempted solutions (Tester to check Goal)
4.Keep the “best” solutions
5.Produce next generation of solutions from these solutions (using
“inheritance” and “mutation”)
GENETIC ALGORITHMS AS PARALLEL
SEARCH

5.Produce next generation of solutions from these solutions


(using “inheritance” and “mutation”)
6.Quit when you have a satisfactory solution (or you run out
of time)
GENETIC ALGORITHMS AS PARALLEL
SEARCH
• Solution to a Few Problems using GA
Suppose you are given several 32-bit computer words. Lets call them
“individuals”
• P1:Suppose you are given a number of 32-bit
Genetic Algorithms as Parallel Search
• Here’s how you can do it:
1.Create 100 randomly generated 32-bit computer words
2.Repeatedly do the following:
3.Count the 1 bits in each word
4.Exit if any of these 100 words have all 32 bits set to 1
Otherwise
5.Keep the 10 words that have the most 1’s in them (discard the
rest)
6.From each of the 10 words, generate 9 new words as follows:
Genetic Algorithms as Parallel Search
5.Keep the 10 words that have the most 1’s in them (discard the
rest)
6.From each of the 10 words, generate 9 new words as follows:
7.Pick a random bit in each (of the 9 words) and toggle (change)
it, i.e., change any one bit from 0 to 1, or from 1 to 0
8.Repeat the algo until we
(a) either get our required word that is a 32-bit number with all
ones
(b) or we run out of time.
Genetic Algorithms as Parallel Search
9. If we run out of time, we either present the best possible
solution (the one with most number of 1-bits) as the answer or
that solution not found.
Genetic Algorithms as Parallel Search
• Using Crossover instead of mutation
• Let's repeat the 32-bit word example again but this time using
crossover instead of mutation.
• Suppose there are 32-bit computer words, and you want a word
where all the bits are ones (1’s)
Genetic Algorithms as Parallel Search
Here’s how you can do it:
1.Create 100 randomly generated computer words
2.Repeatedly do the following:
3.Count the 1 bits in each word
• Exit if any of the words have all 32 bits set to 1,
Otherwise
4.Keep the top ten words that have the most 1s (discard the rest)
The simple example again
• Half from one, half from the
other:

A = 0110 1001 0100 1110 1010 1101 1011 0101


B = 1101 0100 0101 1010 1011 0100 1010 0101
-----------------------------------------------------------------
C = 0110 1001 0100 1110 1011 0100 1010 0101

You might also like