Title: Genetic Algorithms
1Genetic Algorithms
- Motivation and overview
- Efficient and robust search technique in vast and
complex search areas. - Finds optimal or near optimal solutions to
problems. - Based on the mechanics of natural selection and
genetics. ie survival of the fittest. Many of
the terms used come from evolution/genetics. - Rather than working with a single solution to a
problem at a time, a number of solutions are
evaluated simultaneously referred to as a
population - Each solution is evaluated for its fitness. The
better the solution the greater its chance of
survival. - Uses an iterative process, with better solutions
normally evolving over time
2Genetic Algorithms
- Application areas
- Genetic Algorithms are used for optimization
problems. These problems usually involve
maximizing or minimizing some parameters, for
example minimizing cost or time, maximizing
usage or a combination of these. For example -
- Scheduling
- Design
- Financial Management
3Genetic Algorithms
- Problem formulation
- the problem is formulated as a string of binary
digits (sometimes referred to as a chromosome) - a chromosome consists of a series of genes
- both the value of the gene and the position of
the gene in the chromosome are important - the value represents some problem variable
- the position represents some problem variable
4Genetic Algorithms
- Example (1)
- A very simple timetabling problem
- there are four subjects to be timetabled into
eight time slots. - two variables subject four different values,
slot eight different values - one possibility
- gene value -gt a subject
- gene position -gt a time slot
- four different subjects ie four gene values -gt a
2 bit gene
5Genetic Algorithms
- Example (1)
- i.e.
- binary decimal meaning
- 00 0 subject 1
- 01 1 subject 2
- 10 2 subject 3
- 11 3 subject 4
- We require 8 positions one for each time slot,
in other words 8 genes
6Genetic Algorithms
- Example (1)
- An example of a timetable represented in this way
would be - 00 01 01 11 00 11 01 01
- or
- 0001011100110101
- This chromosome is composed of eight two bit
genes - i.e a 16 bit chromosome
- Note as a decimal string it would be
- 0 1 1 3 0 3 1 1
7Genetic Algorithms
- Example (1)
- 00 01 01 11 00 11 01 01
- How might you interpret this?
- subject 1 (00) timetabled into slot 1
- subject 2 (01) timetabled into slot 2
- subject 2 (01) timetabled into slot 3
- subject 4 (11) timetabled into slot 4
- subject 1 (00) timetabled into slot 5
- subject 4 (11) timetabled into slot 6
- subject 2 (01) timetabled into slot 7
- subject 2 (01) timetabled into slot 8
- and subject 3 (10) does not appear at all
8Genetic Algorithms
- Example (1)
- 00 01 01 11 00 11 01 01
- Note at this stage there are no constraints on
these timetables - i.e. no concept of a valid or invalid timetable,
no concept of one time table being better' than
another. - How many possible timetables are there?
- 65 538 (216)
9Genetic Algorithms
- Example (1)
- An alternative formulation?
- use the position to represent the subject and the
gene value to represent the time slot - Now we only have four genes there are only four
subjects, but we need a three bit gene to
generate eight different values, for the time
slots - 000 0 slot 1
- 001 1 slot 2
- 010 2 slot 3
- 011 3 slot 4
- 100 4 slot 5
- 101 5 slot 6
- 110 6 slot 7
- 111 7 slot 8
10Genetic Algorithms
- Example (1)
- An alternative formulation?
- a sample chromosome would be
- 001 001 111 010
- How would you interpret this?
- subject 1 is scheduled in time slot 2 (001)
- subject 2 is scheduled in time slot 2 (001)
- subject 3 is scheduled in time slot 8 (111)
- subject 4 is scheduled in time slot 3 (010)
- Note that there only 4096 (212) possible
timetables
11Genetic Algorithms
- Example (1)
- An alternative formulation?
- Which of the two representations is better?
- Can you see that the second formulation implies
that a subject can only be scheduled once whereas
the first formulation implies that no two
subjects can be scheduled at the same time?
12Genetic Algorithms
- Example (2)
- file storage optimisation
- there are four locations on disc and five files
to be stored - the storage space for each location varies, the
file sizes vary. - two variables
- the location four values
- the file five values
- use gene position to indicate the file
- use gene value to indicate location
- the chromosome will therefore consist of five
two bit genes (10 bits)
13Genetic Algorithms
- Example (2)
- gene value (location)
- binary decimal meaning
- 00 0 location 1
- 01 1 location 2
- 10 2 location 3
- 11 3 location 4
14Genetic Algorithms
A sample chromosome could be
01
00
00
10
11
file A
file B
file C
file D
file E
Interpretation File A is stored in location
2 File B is stored in location 1 File C is stored
in location 1 File D is stored in location 3 File
E is stored in location 4 Note that more than
one file can be stored in a given location there
are 1024 (210) possible configurations
15Genetic Algorithms
- Example (2)
- Are there alternative representations?
- we could use the gene position to represent the
location and the gene value to represent the file - Only need a four gene chromosome there are only
four locations - but we need a gene that can have at least five
values - 3 bit gene max of eight values
- 000 0 file A
- 001 1 file B
- 010 2 file C
- 011 3 file D
- 100 4 file E
- 101 5 invalid file
- 110 6 invalid file
- 111 7 invalid file
- We now have a 12 bit chromosome (i.e four, three
bit genes)
16Genetic Algorithms
- Example (2)
- Are there alternative representations?
-
- for example
001
100
100
111
location 1
location 2
location 3
location 4
i.e 001100100111 or 1 4 4 4 7
this means File B is in location 1 File E is in
location 2 File E is in location 3 ! An invalid
file is in location 4
Clearly this is a very poor problem
formulation. A file could be in different places
at the same time A location can only have one
file in it Some of the files may be invalid
The above chromosome is not a valid solution