Artificial Intelligence Genetic Algorithms and Applications of Genetic Algorithms in Compilers Prasad A. Kulkarni
Dec 21, 2015
Artificial Intelligence
Genetic Algorithms and Applications of Genetic Algorithms in Compilers
Prasad A. Kulkarni
Artificial Intelligence2
Search Strategies in AI
Searching is a very important application area of artificial intelligence.
Common search strategies– depth first search– breadth first search– best first search– hill climbing– simulated annealing– genetic algorithms
Artificial Intelligence3
Outline
Introduction and historical background Biological background Stages in a genetic algorithm Phase ordering problem in compilers Applying GA to address phase ordering Other GA applications Conclusions
Artificial Intelligence4
Introduction and Historical Background
GAs are part of evolutionary computing introduced by I. Rechenberg in the 1960s.
GAs were invented by John Holland in 1975. GAs are based on Darwin’s principle of
evolution and survival of the fittest. GA is a biased sampling search technique.
Artificial Intelligence5
Outline
Introduction and historical background Biological background Stages in a genetic algorithm Phase ordering problem in compilers Applying GA to address phase ordering Other GA applications Conclusions
Artificial Intelligence6
Biological Background
Artificial Intelligence7
Biological Background (cont...)
Crossover, mutation
Artificial Intelligence8
Outline
Introduction and historical background Biological background Stages in a genetic algorithm Phase ordering problem in compilers Applying GA to address phase ordering Other GA applications Conclusions
Artificial Intelligence9
GA Stage 1 – Initialization
Randomly initialize some number of individual solutions to form an initial population
Create initialCreate initialpopulation of population of chromosomeschromosomes
Evaluate fitness ofEvaluate fitness ofeach chromosomeeach chromosomein the populationin the population
Terminate Terminate cond. ?cond. ?
Output the Output the bestbest
solution solution foundfound
Perform crossover/Perform crossover/mutation to createmutation to create
new generationnew generation
YY
NN
Artificial Intelligence10
GA Stage 2 – Evaluation and Selection
Evaluate the fitness value of each chromosome.
Create initialCreate initialpopulation of population of chromosomeschromosomes
Evaluate fitness ofEvaluate fitness ofeach chromosomeeach chromosomein the populationin the population
Terminate Terminate cond. ?cond. ?
Output the Output the bestbest
solution solution foundfound
Perform crossover/Perform crossover/mutation to createmutation to create
new generationnew generation
YY
NN
Artificial Intelligence11
GA Stage 3 – Check Termination
The algorithm terminates when some pre-determined termination condition is reached.
Create initialCreate initialpopulation of population of chromosomeschromosomes
Evaluate fitness ofEvaluate fitness ofeach chromosomeeach chromosomein the populationin the population
Terminate Terminate cond. ?cond. ?
Output the Output the bestbest
solutionsolutionfoundfound
Perform crossover/Perform crossover/mutation to createmutation to create
new generationnew generation
YY
NN
Artificial Intelligence12
GA Stage 4 – Reproduction
Perform crossover and mutation to generate a new population from the current chromosomes.
Create initialCreate initialpopulation ofpopulation ofchromosomeschromosomes
Evaluate fitness ofEvaluate fitness ofeach chromosomeeach chromosomein the populationin the population
Terminate Terminate cond. ?cond. ?
Output the Output the bestbest
solution solution foundfound
Perform crossover/Perform crossover/mutation to createmutation to create
new generationnew generation
YY
NN
Artificial Intelligence13
GA Stage 5 – Output Solution
Output the best solution found during the algorithm.
Create initialCreate initialpopulation ofpopulation ofchromosomeschromosomes
Evaluate fitness ofEvaluate fitness ofeach chromosomeeach chromosomein the populationin the population
Terminate Terminate cond. ?cond. ?
Output the Output the bestbest
solution solution foundfound
Perform crossover/Perform crossover/mutation to createmutation to create
new generationnew generation
YY
NN
Artificial Intelligence14
Outline
Introduction and historical background Biological background Stages in a genetic algorithm Phase ordering problem in compilers Applying GA to address phase ordering Other GA applications Conclusions
Artificial Intelligence15
Phase Ordering Problem
Optimizing compilers apply several optimization phases to improve the performance of applications.
Optimization phases interact with each other. Determining the best order of applying
optimization phases has been a long standing problem in compilers.
Artificial Intelligence16
Addressing the Phase Ordering Problem
Most researchers consider exhaustive enumeration infeasible– largest optimization sequence length in our
experiments was 32– 15 phases for an optimization sequence length of
32 would result in 1532 evaluations! Heuristics are used to search only a small
portion of the optimization phase order space– random search, genetic algorithms etc.
Artificial Intelligence17
Outline
Introduction and historical background Biological background Stages in a genetic algorithm Phase ordering problem in compilers Applying GA to address phase ordering Other GA applications Conclusions
Artificial Intelligence18
GA Stage 1 – Initialization
a
b
c
d
e
f
e
c
f
a
a
c
a
d
e
c
f
e
population1
Artificial Intelligence19
GA Stage 2 – Evaluation and Selection
a
b
c
d
e
f
e
c
f
a
a
c
a
d
e
c
f
e
population1
88 20 95
Artificial Intelligence20
GA Stage 3 – Check Termination
Terminating conditions– the desired performance is reached– specified number of generations have elapsed– time constraint for genetic algorithm exceeded
Artificial Intelligence21
GA Stage 4 – Reproduction
Crossover - 20% sequences in each generation replaced
Mutation - phases in each sequence replaced with a low probability
Artificial Intelligence22
Outline
Introduction and historical background Biological background Stages in a genetic algorithm Phase ordering problem in compilers Applying GA to address phase ordering Other GA applications Conclusions
Artificial Intelligence23
Other GA Applications
Designing electronic circuits Designing of aircrafts Routing in circuit switched telecommunication
networks Genetic algorithm applied to robot trajectory
design and many more....
Artificial Intelligence24
Conclusion
Genetic algorithm are a class of heuristic biased sampling approach to searching large spaces.
Described steps during a genetic algorithm Presented detailed application of genetic
algorithm to phase ordering problem in compilers.