This document provides an overview of evolutionary computing technology and genetic algorithms. It discusses the history and components of evolutionary algorithms, including representation, evaluation functions, selection mechanisms, crossover and mutation operators. It also compares implementing genetic algorithms on CPU versus GPU, noting that GPUs are better suited for highly parallel problems due to their greater number of weaker cores. The document concludes with references on evolutionary computing and genetic algorithms.
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
Genetic Algorithm Implementation on CPU and GPU
1. Evolutionary Computing Technology
Sina Mohammadi, Mohammad Pourmojdeh, Alireza Bahremand, Hojjat allah Rezapour
IAU-Rasht Branch
Supervisor: Aref Safari Ph.D.
Spring 2019
Implementing The Genetic Algorithm in CPU and GPU
2. Table of Content
• Introduction to Evolutionary Computing
• Definition of Evolutionary Algorithms
• Components of Evolutionary Algorithms
• Review of Genetic Algorithm
• Implementation and Evaluation
• References
3. • Evolutionary Computing is a research area within computer science that transforms
computers into automatic optimization and design tools, utilizing the power of the
natural selection mechanisms.
• The contemporary terminology denotes the whole field by EC and the algorithms
involved are termed Evolutionary Algorithms.
Evolutionary Computing (EC)
3
6. • Algorithms that perform optimization or learning tasks with the ability to evolve.
• There are many different variants of evolutionary algorithms but the common
underlying idea behind all these techniques is the same.
3 main characteristics:
• Population-based • Fitness-oriented • Variation-driven
Evolutionary Algorithms (EA)
6
7. • GA came from the research of John Holland, in the University of Michigan.
• Main purpose is to be used to solve problems where deterministic algorithms are too costly.
• Travelling salesman problem or the knapsack problem fit the description.
Genetic Algorithm (GA)
7
8. Genetic Algorithm (GA)
8
INITIALISE population with random candidate solutions;
EVALUATE each candidate;
REPEAT UNTIL ( TERMINATION CONDITION is satisfied ) DO
I. SELECT parents;
II. RECOMBINE pairs of parents;
III. MUTATE the resulting offspring;
IV. EVALUATE new candidates;
V. SELECT individuals for the next generation;
END
9. • The first step is to decide how possible solutions should be specified and stored in
a way that can be manipulated by a computer.
• Objects forming possible solutions within the original problem context are referred
to as phenotypes and their encoding that is the individuals within the EA, are called
genotypes.
Representation
9
10. • The role of the evaluation function is to represent the requirements the population
should adapt to meet.
• More accurately, it defines what improvement means.
• Fitness Function is not a constant mathematical formula but changes with the
context of the problem.
Evaluation Function (Fitness Func.)
10
11. • The role of parent selection or mate selection is to distinguish among individuals
based on their quality and in particular to allow the better individuals to become
parents of the next generation.
• Roulette Wheel has one of the most uses in the genetic algorithm.
Parent Selection Mechanism
11
12. • This operator merges information from two parent genotypes into one or two
offspring genotypes.
• The role of recombination differs between EC dialects, For instance in genetic
programming it is often the only variation operator whereas in evolutionary
programming it is never used.
• Single Point • Multi Point • Uniform
Crossover
12
13. 0 1 2 3 4 5 6 7 8 9
5 8 9 4 2 3 5 7 5 8
0 1 2 3 4 3 5 7 5 8
5 8 9 4 2 5 6 7 8 9
Selection Point could be anywhere in genotype
Recombination – Single Point
13
Parent A
Parent B
Offspring A
Offspring B
14. 0 1 2 3 4 5 6 7 8 9
5 8 9 4 2 3 5 7 5 8
0 1 2 4 2 3 6 7 8 9
5 8 9 3 4 5 5 7 5 8
Selection Points could be anywhere in genotype
Recombination – Multi Point
14
Parent A
Parent B
Offspring A
Offspring B
16. • In simple terms, mutation may be defined as a small random tweak in the
chromosome, to get a new solution.
• Mutation is usually applied with a low probability because if the probability is very
high, the GA gets reduced to a random search.
0 0 1 1 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0
Mutation
16
17. • Similar to parent selection, the role of survivor selection or environmental selection is to
distinguish among individuals based on their quality, but In contrast to parent selection
which is typically stochastic, survivor selection is often deterministic.
• For example, two common methods are the fitness-based method of ranking the unified
multiset of parents and offspring and selecting the top segment, or the age-biased
approach of selecting only from the offspring.
Survivor Selection Mechanism (Replacement)
17
18. • The maximally allowed CPU time elapses.
• The total number of fitness evaluations reaches a given limit.
• The fitness improvement remains under a threshold value for a given period of time
• The population diversity drops under a given threshold.
Termination Condition
18
19. • A CPU is basically a microprocessor that executes instructions given by a program
based on operations for arithmetic, control, logic, and input-output.
• The fundamental components of a CPU include an arithmetic logic unit (ALU),
processor registers that provide operations to the ALU and store the results, a
control unit (CU) that executes instructions from memory, and various registers.
Central Processing Units (CPU)
19
21. • A CPU is designed for low latency (quick response time) by implementing a large
cache that is used for intermediate storage to avoid reading from global memory,
which is very slow.
• Core’s concept
Central Processing Units (CPU)
21
22. • Originally, the GPU was made for rendering images in computer games and was optimized
for the fact that each pixel value can be processed independently from the others.
• Instead of focusing on low latency as a CPU does, a GPU focuses on high throughputs that
is, calculating on as much data as possible. Thus a GPU has more hardware allocated to
computation and less to fast cache memory, the opposite of a CPU.
Graphic Processing Unit (GPU)
22
23. • Another main difference between a CPU and a GPU is that a CPU has a few
powerful cores while a GPU has thousands of weaker cores.
• This gives the GPU an advantage in highly parallelizable applications, while the
CPU is better for sequential runs.
Graphic Processing Unit (GPU)
23
25. Code written for a CPU cannot be run on a GPU since the two platforms are based on different
hardware and thus require code specifically written for each specific platform. For NVIDIA
graphics cards the language is CUDA, which is accessible as a superset of C++, among others.
From a programmer’s perspective, CUDA code looks like normal C++ code, except that
functions are marked as being run able on CPU, GPU, or both.
Programming
25
26. The code run on the GPU is called a “kernel.” The difference from code run on the
CPU is that the each kernel will be executed by thousands, or even millions, of
threads.
The programmer can specify the number of blocks and the number of threads per
block to be run. The threads in a block will all run on the same core.
Programming
26