SlideShare a Scribd company logo
Approximation Algorithms Presented By  Ahlam Ansari
1. Approximation Algorithm 2.   Performance Ratio of AA 3. Examples of AA 4.   The vertex-cover problem - Algorithm - Example 5.  Traveling salesman problem -  Algorithm - Example 6.   Cover-Set Problem - Algorithm - Example 7. Genetic Algorithm -Algorithm for GA - Pictorial Representation of GA - Working Principle 8. Solving TSP using GA - Steps   - Flowchart -Solution with Example 9.  Analysis of TSP Algorithms   10. Results 11.Conclusion
Abstract In computer science and operations research, approximation algorithms are algorithms used to find approximate solutions to optimization problems. Approximation algorithms are often associated with NP-hard problems . The Travelling Salesman Problem (TSP) is a deceptively simple combinatorial problem. It can be stated very simply: A salesman spends his time visiting N cities (or nodes) cyclically. In one tour he visits each city just once, and finishes up where he started. In what order should he visit them to minimize the distance traveled? TSP is applied in many different places such as warehousing, material handling and facility planning.  Although optimal algorithms exist for solving the TSP, like the IP formulation, industrial engineers have realized that it is computationally infeasible to obtain the optimal solution to TSP. And it has been proved that for large-size TSP, it is almost impossible to generate an optimal solution within a reasonable amount of time. Heuristics, instead of optimal algorithms, are extensively used to solved such problems. People conceived many heuristic algorithms to get near optimal solutions. Among them, there are greedy and genetic algorithm, etc. But their efficiencies vary from case to case, from size to size . In this paper we will compare a normal Approximation Algorithm with the Genetic Algorithm to see which one gives the best optimal solution
Approximation Algorithm
In computer science and operations research, approximation algorithms are algorithms used to find approximate solutions to optimization problems. Approximation Algorithm
Approximation algorithms are often associated with NP-hard problems. Since it is unlikely that there can ever be efficient polynomial time exact algorithms solving NP-hard problems, one settles for polynomial time sub-optimal solutions. Approximation Algorithm
Approximation algorithms are increasingly being used for problems where exact polynomial-time algorithms are known but are too expensive due to the input size.[1] Approximation Algorithm
Performance ratios of Approximation Algorithm
A problem (knapsack, traveling salesperson) is denoted by P. Let I be an instance of problem P Cost of optimal solution for instance I is given by C (I), and C(I) > 0 Optimal solution may be defined as maximum or minimum possible cost (maximization or minimization problem) Performance ratios of Approximation Algorithm
If for any input of size n, the cost C of the solution produced by the algorithm is within a factor of  ρ(n)  of the cost C* of an optimal solution: Max ( C/C* , C*/C ) ≤ ρ(n) We call this algorithm as an ρ(n)-approximation algorithm. Performance ratios of Approximation Algorithm
Cost of approximate solution C*(I) C*(I) < C (I) [Approximate solution < optimal solution] if P is a maximization problem.  0<C*≤C , ρ(n) = C/C* C*(I) > C(I) [Approximate solution > optimal solution] if P is a minimization problem.  0<C≤C* , ρ(n) = C*/C  [2] Performance ratios of Approximation Algorithm
Examples of Approximation Algorithm
Vertex cover problem. Traveling salesman problem. Set cover problem. Examples of Approximation Algorithm
The vertex-cover problem
A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. The problem of finding a minimum vertex cover is a classical optimization problem in computer science and is a typical example of an NP-hard optimization problem that has an approximation algorithm. The vertex-cover problem
A vertex cover of an undirected graph G = (V,E) is a subset V` of the vertices of the graph which contains at least one of the two endpoints of each edge and V` is a subset of V . The size of a vertex cover is the number of vertices in it.[3] The vertex-cover problem
Example Fig: 1 The vertex-cover problem Optimal Size=3 Near Optimal size=6
Procedures 1.  Given a simple graph G with n vertices and a vertex cover C of G, if C has no removable vertices, output C. Else, for each removable vertex v of C, find the number ρ(C−{v}) of removable vertices of the vertex cover C−{v}. Let vmax denote a removable vertex such that ρ(C−{vmax}) is a maximum and obtain the vertex cover C−{vmax}. Repeat until the vertex cover has no removable vertices. The vertex-cover problem
Contd… 2. Given a simple graph G with n vertices and a minimal vertex cover C of G, if there is no vertex v in C such that v has exactly one neighbor w outside C, output C. Else, find a vertex v in C such that v has exactly one neighbor w outside C. Define Cv,w by removing v from C and adding w to C. Perform procedure 3.1 on Cv,w and output the resulting vertex cover.[5] The vertex-cover problem
Algorithm Given as input a simple graph G with n vertices labeled 1, 2, …, n, search for a vertex cover of size at most k. At each stage, if the vertex cover obtained has size at most k, then stop. The vertex-cover problem
Contd… Part 1: For i = 1, 2, ..., n in turn Initialize the vertex cover Ci = V−{i}. Perform procedure 1 on Ci. For r = 1, 2, ..., n−k perform procedure 2 repeated r times. The result is a minimal vertex cover Ci. The vertex-cover problem
Contd… Part 2: For each pair of minimal vertex covers Ci, Cj found in Part 1 Initialize the vertex cover Ci, j = Ci∪Cj . Perform procedure 1 on Ci, j. For r = 1, 2, ..., n−k perform procedure 2 repeated r times. The result is a minimal vertex cover Ci, j.[5] The vertex-cover problem
Example The input is the graph [6] shown below with n = 12 vertices labeled  V = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12}. The vertex-cover problem
Contd… Fig: 2 The vertex-cover problem
Contd… We search for a vertex cover of size at most k = 7. Part I for i = 1 and i = 2 yields vertex covers C1 and C2 of size 8, so we give the details starting from i = 3 The vertex-cover problem
Contd… We initialize the vertex cover as  C3 = V−{3}={1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12}. The vertex-cover problem
Contd… We now perform procedure 1. Here are the results in tabular form:  Vertex Cover C3 = {1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12}. Size: 11. The vertex-cover problem
Contd… The vertex-cover problem
Contd… The vertex-cover problem
Contd… The vertex-cover problem
Contd… The vertex-cover problem
Traveling salesman problem
The traveling salesman problem (TSP) is an NP-hard problem in combinatorial optimization studied in operations research and theoretical computer science. Given a list of cities and their pair wise distances, the task is to find a shortest possible tour that visits each city exactly once. [3] Traveling salesman problem
Given an undirected weighted Graph G we are to find a minimum cost Hamiltonian cycle. Traveling salesman problem
Algorithm Traveling salesman problem
Example Fig: 3 Traveling salesman problem 2 2 3 9 8 7 4 1 3 9 9 9 9 7 7 5 5 7 7 4 Solution for TSP
The set cover problem
The set cover problem is to identify the smallest number of sets whose union still contains all elements in the universe. The set cover problem
Algorithm The set cover problem
Example Assume we are given the following elements U = {1,2,3,4,5} and sets S = {{1,2,3},{2,4},{3,4},{4,5}}. Clearly the union of all the sets in S contain all elements in U. However, we can cover all of the elements with the following, smaller number of sets: SETCOVER = {{1,2,3},{4,5}}. [4] The set cover problem
The set cover problem Fig: 4 1 2 5 4 3 SET COVER SET COVER
Genetic Algorithm
Genetic Algorithms are a family of computational models inspired by evolution. These algorithms encode a potential solution to a specific problem on a simple chromosome-like data structure and apply recombination operators to these structures as to preserve critical information. Genetic algorithms are often viewed as function optimizer, although the range of problems to which genetic algorithms have been applied are quite broad.[7] Genetic Algorithm
An implementation of genetic algorithm begins with a population of (typically random) chromosomes. One then evaluates these structures and allocated reproductive opportunities in such a way that these chromosomes which represent a better solution to the target problem are given more chances to `reproduce’ than those chromosomes which are poorer solutions. The 'goodness' of a solution is typically defined with respect to the current population. Genetic Algorithm
Algorithm GA formulate initial population randomly initialize population repeat evaluate objective function find fitness function apply genetic operators reproduction crossover mutation until stopping criteria Genetic Algorithm
The Pictorial representation of the Working Principle of a Simple Genetic Algorithm Fig: 5
The Travelling salesman and Vertex cover can be solved using Genetic Algorithm. In order to use GA’s to solve the above problems we need to follow the working principles of GA. Genetic Algorithm
1.Coding Variables are first coded in some string structures . Fig: 6 Genetic Algorithm
Binary-coded strings having 1's and 0's are mostly used. The length of the string is usually determined according to the desired solution accuracy. For example, if four bits are used to code each variable in a two-variable optimization problem, the strings (0000 0000) and (1111 1111) would represent the points respectively Genetic Algorithm
B ecause the sub-strings (0000) and (1111) have the minimum and the maximum decoded values. Any other eight bit string can be found to represent a point in the search space according to a xed mapping rule. Usually, the following linear mapping rule is used: Genetic Algorithm
2. Fitness function A Fitness function F(i) is first derived from the objective function and used in successive genetic operations. Fitness in biological sense is a quality value which is a measure of the reproductive efficiency of chromosomes. Genetic Algorithm
Individuals with higher fitness value will have higher probability of being selected as candidates for further examination. Certain genetic operators require that the fitness function be non-negative, although certain operators need not have this requirement. Genetic Algorithm
Two commonly adopted  fitness mappings is presented below: 1. 2. Genetic Algorithm
3. GA operator The operation of GA’s begins with a population of a random strings representing design or decision variables. The population is then operated by three main operators; reproduction, crossover and mutation to create a new population of points. GA’s can be viewed as trying to maximize the fitness function, by evaluating several solution vectors. The purpose of these operators is to create new solution vectors by selection, combination or alteration of the current solution vectors that have shown to be good temporary solutions. Genetic Algorithm
4.   Reproduction   Reproduction (or selection) is an operator that makes more copies of better strings in a new population. Reproduction is usually the first operator applied on a population. Reproduction selects good strings in a population and forms a mating pool. This is one of the reason for the reproduction operation to be sometimes known as the selection operator. Thus, in reproduction operation the process of natural selection cause those individuals that encode successful structures to produce copies more frequently. To sustain the generation of a new population, the reproduction of the individuals in the current population is necessary. For better individuals, these should be from the fittest individuals of the previous population. Genetic Algorithm
5. Crossover A crossover operator is used to recombine two strings to get a better string. In crossover operation, recombination process creates different individuals in the successive generations by combining material from two individuals of the previous generation. In reproduction, good strings in a population are probabilistic-ally assigned a larger number of copies and a mating pool is formed. It is important to note that no new strings are formed in the reproduction phase. In the crossover operator, new strings are created by exchanging information among strings of the mating pool. The two strings participating in the crossover operation are known as parent strings and the resulting strings are known as children strings.  Genetic Algorithm
One site crossover and two site crossover are the most common ones adopted. In most crossover operators, two strings are picked from the mating pool at random and some portion of the strings are exchanged between the strings. Crossover operation is done at string level by randomly selecting two strings for crossover operations. A one site crossover operator is performed by randomly choosing a crossing site along the string and by exchanging all bits on the right side of the crossing site. Genetic Algorithm
One site crossover operation Fig: 7 Genetic Algorithm
Two site crossover operation Fig: 8 Genetic Algorithm
6. Mutation Mutation adds new information in a random way to the genetic search process and ultimately helps to avoid getting trapped at local optima. It is an operator that introduces diversity in the population whenever the population tends to become homogeneous due to repeated use of reproduction and crossover operators. Mutation may cause the chromosomes of individuals to be different from those of their parent individuals. Genetic Algorithm
Mutation in a way is the process of randomly disturbing genetic information. They operate at the bit level; when the bits are being copied from the current string to the new string, there is probability that each bit may become mutated. This probability is usually a quite small value, called as mutation probability p m.[7] Genetic Algorithm
Solving TSP using GA
Step to be followed i. Randomly create the initial population of individual strings of the given TSP problem and create a matrix representation of each, must satisfy the two basic conditions as mentioned earlier. ii. Assign a fitness to each individual in the population using fitness criteria measure, F(t)=value of assignment of given problem value of the string The selection criterion depends upon the value of the strings if it is close to 1. Solving TSP using GA
iii. Create new off-spring population of strings from the two existing strings in the parent population by applying crossover operation. iv. Mutate the resultant off-springs if required. Note: After the cross-over and mutation off-spring population has the fitness higher than the parents. v. Call the new off-springs as parent population and continue the steps (iii) and (iv) until we get a single offspring that will be an optimal or near optimal solution to the problem. Solving TSP using GA
Fig 9: Flow chart of TSP using GA
1. Matrix Representation: According to the algorithm we are presenting the tour as binary matrix. In figure (A,B,C,D,E) every gene is presented as binary bits, if the element (i ,j) in the matrix is a set to 1 its mean there is an edge (directed path) between the city I to city j in the tour.[8] Solving TSP using GA
Fig: 10 Solving TSP using GA
According to the algorithm we are presenting the tour as a binary matrix. In fig 10 gene is represented as a binary bit, if the element (i,j) is set to (1) its mean that there is an edge (directed path) between the city I and city j in the tour. The above representation is for symmetric matrix TSP that the d ij  = d ji  . For asymmetric matrix that is when d ij  ≠ d ji  the above representation will be considered as, Solving TSP using GA
Fig: 11 Solving TSP using GA
The left upper triangle (LUTM) represents the movement from left to right that is the forward movement. In (LUTM) we have the path from A->B, B->C, C->E. where as the upper right triangular matrix (URTM) represents the movement from bottom to top, in (URTM) there is the path from E->D, D->A. In this way the complete tour will be, A->B-> C->E -> D->A Solving TSP using GA
The matrix representation must satisfy the two conditions to satisfy a legal tour: symmetric case asymmetric case Solving TSP using GA
For symmetric case (i) The number of matrix element that has the value (1) must equal to the number of vertices in the tour. (ii) The number of matrix elements that have the value of (1) in each row and each column of the same vertex must be equal to two. Solving TSP using GA
For asymmetric case: (i) The total number of the element that has the value (1) in both (LUTM) and (RUTM) must be equal to the number of vertices in the tour. (ii) For the same vertex the sum of both matrix elements that has the value (1) must be equal to 2. Solving TSP using GA
2.  Cross-over Operation Here we are using the cross-over operator by applying the  OR  operation on the two parent matrices to get a single matrix. Solving TSP using GA
3.  Mutation Operation If the resultant tour (matrix) is an illegal tour (i.e does not satisfy the two condition mentioned above), then it must be repaired. This is done by counting the number of element with (1) value in each row and column for the city, if the number is greater than 2 then repeat deleting the longest edge from the resultant tour until the number of element in the resultant tour is equal to 2. However, if the number of elements in the resultant tour is less then 2 than add the missing edges in the tour by greedy algorithm. Considering two tours T1: A->E-> C->D -> B->A=17 T2: A->B-> E->C -> D->A=22 Solving TSP using GA
Then cross-over and mutation of these two tours will be, Fig: 12
Example Consider the weighted matrix, Solving TSP using GA
The value of the assignment of the above problem is 13 Initial population: A->E-> C->D -> B->A=17 A->B-> E->C -> D->A=22 A->C-> D->E -> B->A=23 A->B-> D->C -> E->A=24 A->E-> B->C -> D->A=25 A->B-> C->E -> D->A=26 A->E-> D->C -> B->A=28 A->D-> C->E -> B->A=29 A->E-> C->B -> D->A=30 According to the fitness criteria we are selecting the tour having values, 17,22,25,29 Solving TSP using GA
The resultant tour will be, A->B-> C->D-> E->A=15 Solving TSP using GA
Analysis of TSP Algorithms
Greedy algorithm  is the simplest improvement algorithm. It starts with the departure Node 1. Then the algorithm calculates all the distances to other n-1 nodes. Go to the next closest node. Take the current node as the departing node, and select the next nearest node from the remaining n-2 nodes. The process continues until all the nodes are visited once and only once then back to Node 1. When the algorithm is terminated, the sequence is returned as the best tour; that is the final solution. The advantage of this algorithm is its simplicity to understand and implement. Sometime, it may lead to a very good solution when the problem size is small. Also, because this algorithm does not entail any exchange of nodes, it saves considerably much computational time. Analysis of TSP Algorithms
Genetic Algorithm  as the name implies, this algorithm gets its idea from genetics. The algorithm works this way. By obtaining the maximum number of individuals in the population and the maximum number of generations from the user, generate solutions for the first generation’s population randomly, and represent each solution as a string. Mutation to generate a population by swapping any two randomly selected genes. Genetic Algorithm works better than the Greedy method but its complicated and require a large amount of computation time. [9] Analysis of TSP Algorithms
Result
Result Based on Length Comparison   Result 9906 4302 2295 Genetic Algorithm   10402 4478 2330 Greedy  500 100 30 Algorithm \ City Size
Result Based on Time Comparison Result 27 6 2  Genetic Algorithm   34 8 6 Greedy  500 100 30 Algorithm \ City Size
Conclusion
The Greedy algorithm takes a very long time for a large number of cities such as 500. It is not efficient to use Greedy algorithm for problem with more than 100 cites. For small-size TSP, improved greedy algorithm is recommended. For medium-size large-size problem, the genetic algorithm is recommended.  Conclusion
Reference [1] http://www.cs.uiuc.edu/class/sp09/cs598csc/ [2] Introduction to Algorithms, Thomas H. Cormen [3] http://www.cs.umsl.edu/~sanjiv/classes/cs5130/lectures/ approx.pdf [4] http://en.wikipedia.org/wiki/Set_cover_problem [5] Hybrid Genetic Algorithm for Minimum Vertex Cover Problem, in Proceedings of Met heuristics International Conference, 2003, pp 13-17 [6] R. Frucht Graphs of degree three with a given abstract group, Canad. J. Math., 1949 [7] http://www.civil.iitb.ac.in/tvm/2701_dga/2701-ga-notes/gadoc.pdf [8] http://www.ijens.org/96110-1414%20IJBAS-IJENS.pdf [9] D. Whitley, “Modeling Hybrid Genetic Algorithms”. Genetic Algorithms in Engineering and Computer Science, Winter, Periaux, Galan and Cuesta, eds. pp: 191- 201, Wiley, 1995. [10] Traveling Salesman Problem Based on Genetic Algorithm, Third International Conference on Natural Computation (ICNC 2007)
Thank you  for your attendance and attention.
Ad

Recommended

String matching algorithms
String matching algorithms
Ashikapokiya12345
 
Greedy algorithms
Greedy algorithms
sandeep54552
 
Design and Analysis of Algorithms
Design and Analysis of Algorithms
Swapnil Agrawal
 
Greedy algorithm
Greedy algorithm
International Islamic University
 
Complexity analysis in Algorithms
Complexity analysis in Algorithms
Daffodil International University
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)
jehan1987
 
Backtracking
Backtracking
subhradeep mitra
 
Daa unit 1
Daa unit 1
Abhimanyu Mishra
 
Daa unit 4
Daa unit 4
Abhimanyu Mishra
 
Daa
Daa
Dhananjay Singh
 
Unit 2 in daa
Unit 2 in daa
Nv Thejaswini
 
Topological Sorting
Topological Sorting
ShahDhruv21
 
Divide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Hash Techniques in Cryptography
Hash Techniques in Cryptography
Basudev Saha
 
Backtracking
Backtracking
Vikas Sharma
 
Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
Tariq Khan
 
Greedy Algorihm
Greedy Algorihm
Muhammad Amjad Rana
 
Shortest path algorithm
Shortest path algorithm
sana younas
 
Divide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Kmp
Kmp
akruthi k
 
Backtracking Algorithm.ppt
Backtracking Algorithm.ppt
SalmIbrahimIlyas
 
Stressen's matrix multiplication
Stressen's matrix multiplication
Kumar
 
Asymptotic notations
Asymptotic notations
Ehtisham Ali
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
Abhimanyu Mishra
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
oneous
 
Transposition Cipher
Transposition Cipher
daniyalqureshi712
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
Fenil Shah
 
Adversarial search
Adversarial search
Dheerendra k
 
Algorithm chapter 2
Algorithm chapter 2
chidabdu
 
The Travelling Salesman Problem
The Travelling Salesman Problem
guest3d82c4
 

More Related Content

What's hot (20)

Daa unit 4
Daa unit 4
Abhimanyu Mishra
 
Daa
Daa
Dhananjay Singh
 
Unit 2 in daa
Unit 2 in daa
Nv Thejaswini
 
Topological Sorting
Topological Sorting
ShahDhruv21
 
Divide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Hash Techniques in Cryptography
Hash Techniques in Cryptography
Basudev Saha
 
Backtracking
Backtracking
Vikas Sharma
 
Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
Tariq Khan
 
Greedy Algorihm
Greedy Algorihm
Muhammad Amjad Rana
 
Shortest path algorithm
Shortest path algorithm
sana younas
 
Divide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Kmp
Kmp
akruthi k
 
Backtracking Algorithm.ppt
Backtracking Algorithm.ppt
SalmIbrahimIlyas
 
Stressen's matrix multiplication
Stressen's matrix multiplication
Kumar
 
Asymptotic notations
Asymptotic notations
Ehtisham Ali
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
Abhimanyu Mishra
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
oneous
 
Transposition Cipher
Transposition Cipher
daniyalqureshi712
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
Fenil Shah
 
Adversarial search
Adversarial search
Dheerendra k
 
Topological Sorting
Topological Sorting
ShahDhruv21
 
Hash Techniques in Cryptography
Hash Techniques in Cryptography
Basudev Saha
 
Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
Tariq Khan
 
Shortest path algorithm
Shortest path algorithm
sana younas
 
Divide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Backtracking Algorithm.ppt
Backtracking Algorithm.ppt
SalmIbrahimIlyas
 
Stressen's matrix multiplication
Stressen's matrix multiplication
Kumar
 
Asymptotic notations
Asymptotic notations
Ehtisham Ali
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
Abhimanyu Mishra
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
oneous
 
01 Knapsack using Dynamic Programming
01 Knapsack using Dynamic Programming
Fenil Shah
 
Adversarial search
Adversarial search
Dheerendra k
 

Viewers also liked (20)

Algorithm chapter 2
Algorithm chapter 2
chidabdu
 
The Travelling Salesman Problem
The Travelling Salesman Problem
guest3d82c4
 
01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes
Andres Mendez-Vazquez
 
Matrix multiplicationdesign
Matrix multiplicationdesign
Respa Peter
 
Matrix mult class-17
Matrix mult class-17
Kumar
 
Presentation on An Evaluation of Alternative Urban Growth Patterns
Presentation on An Evaluation of Alternative Urban Growth Patterns
Gbrdhn Banskota
 
2-Approximation Vertex Cover
2-Approximation Vertex Cover
Kowshik Roy
 
Tut5
Tut5
Manoj Ghorpade
 
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Nguyễn Công Hoàng
 
Giáo trình Phân tích và thiết kế giải thuật - CHAP 3
Giáo trình Phân tích và thiết kế giải thuật - CHAP 3
Nguyễn Công Hoàng
 
Exploring Algorithms
Exploring Algorithms
Sri Prasanna
 
04 brute force
04 brute force
Hira Gul
 
Giraph Travelling Salesman Example
Giraph Travelling Salesman Example
EliasDaboussi
 
01 Analysis of Algorithms: Introduction
01 Analysis of Algorithms: Introduction
Andres Mendez-Vazquez
 
Logistics. Terminology
Logistics. Terminology
SSA KPI
 
Traveling salesman problem__theory_and_applications
Traveling salesman problem__theory_and_applications
Sachin Kheveria
 
Greedy Knapsack Problem - by Y Achchuthan
Greedy Knapsack Problem - by Y Achchuthan
Achchuthan Yogarajah
 
Quicksort
Quicksort
maamir farooq
 
DESIGN AND ANALYSIS OF ALGORITHM (DAA)
DESIGN AND ANALYSIS OF ALGORITHM (DAA)
m.kumarasamy college of engineering
 
Dynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain Multiplication
Pecha Inc.
 
Algorithm chapter 2
Algorithm chapter 2
chidabdu
 
The Travelling Salesman Problem
The Travelling Salesman Problem
guest3d82c4
 
01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes
Andres Mendez-Vazquez
 
Matrix multiplicationdesign
Matrix multiplicationdesign
Respa Peter
 
Matrix mult class-17
Matrix mult class-17
Kumar
 
Presentation on An Evaluation of Alternative Urban Growth Patterns
Presentation on An Evaluation of Alternative Urban Growth Patterns
Gbrdhn Banskota
 
2-Approximation Vertex Cover
2-Approximation Vertex Cover
Kowshik Roy
 
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Giáo trình Phân tích và thiết kế giải thuật - CHAP 8
Nguyễn Công Hoàng
 
Giáo trình Phân tích và thiết kế giải thuật - CHAP 3
Giáo trình Phân tích và thiết kế giải thuật - CHAP 3
Nguyễn Công Hoàng
 
Exploring Algorithms
Exploring Algorithms
Sri Prasanna
 
04 brute force
04 brute force
Hira Gul
 
Giraph Travelling Salesman Example
Giraph Travelling Salesman Example
EliasDaboussi
 
01 Analysis of Algorithms: Introduction
01 Analysis of Algorithms: Introduction
Andres Mendez-Vazquez
 
Logistics. Terminology
Logistics. Terminology
SSA KPI
 
Traveling salesman problem__theory_and_applications
Traveling salesman problem__theory_and_applications
Sachin Kheveria
 
Greedy Knapsack Problem - by Y Achchuthan
Greedy Knapsack Problem - by Y Achchuthan
Achchuthan Yogarajah
 
Dynamic Programming - Matrix Chain Multiplication
Dynamic Programming - Matrix Chain Multiplication
Pecha Inc.
 
Ad

Similar to Analysis of Algorithm (20)

Approximation
Approximation
RiyaSingh235
 
Daa chapter11
Daa chapter11
B.Kirron Reddi
 
Chap8 new
Chap8 new
Loc Tran
 
Presentation of daa on approximation algorithm and vertex cover problem
Presentation of daa on approximation algorithm and vertex cover problem
sumit gyawali
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
Muthu Vinayagam
 
Introduction to Approximation Algorithms
Introduction to Approximation Algorithms
Jhoirene Clemente
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
muthukrishnavinayaga
 
Lecture26
Lecture26
Dr Sandeep Kumar Poonia
 
Algorithms And Optimization Techniques For Solving TSP
Algorithms And Optimization Techniques For Solving TSP
Carrie Romero
 
Approximation algorithms
Approximation algorithms
Bipesh Raj Subedi
 
Approximation Algorithms TSP
Approximation Algorithms TSP
P. Subathra Kishore, KAMARAJ College of Engineering and Technology, Madurai
 
Meetup Julio Algoritmos Genéticos
Meetup Julio Algoritmos Genéticos
DataLab Community
 
Introduction to algorithms and it's different types
Introduction to algorithms and it's different types
ShivaniSharma335055
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4
Deepak John
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1
Techglyphs
 
Combinatorial Optimization
Combinatorial Optimization
Institute of Technology, Nirma University
 
Data Analysis and Algorithms Lecture 1: Introduction
Data Analysis and Algorithms Lecture 1: Introduction
TayyabSattar5
 
unit-4-dynamic programming
unit-4-dynamic programming
hodcsencet
 
35 algorithm-types
35 algorithm-types
Kislay Bhardwaj L|PT,ECSA,C|EH
 
With saloni in ijarcsse
With saloni in ijarcsse
satish rana
 
Presentation of daa on approximation algorithm and vertex cover problem
Presentation of daa on approximation algorithm and vertex cover problem
sumit gyawali
 
Undecidable Problems and Approximation Algorithms
Undecidable Problems and Approximation Algorithms
Muthu Vinayagam
 
Introduction to Approximation Algorithms
Introduction to Approximation Algorithms
Jhoirene Clemente
 
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
muthukrishnavinayaga
 
Algorithms And Optimization Techniques For Solving TSP
Algorithms And Optimization Techniques For Solving TSP
Carrie Romero
 
Meetup Julio Algoritmos Genéticos
Meetup Julio Algoritmos Genéticos
DataLab Community
 
Introduction to algorithms and it's different types
Introduction to algorithms and it's different types
ShivaniSharma335055
 
Analysis and design of algorithms part 4
Analysis and design of algorithms part 4
Deepak John
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1
Techglyphs
 
Data Analysis and Algorithms Lecture 1: Introduction
Data Analysis and Algorithms Lecture 1: Introduction
TayyabSattar5
 
unit-4-dynamic programming
unit-4-dynamic programming
hodcsencet
 
With saloni in ijarcsse
With saloni in ijarcsse
satish rana
 
Ad

More from أحلام انصارى (20)

An Enhanced Independent Component-Based Human Facial Expression Recognition ...
An Enhanced Independent Component-Based Human Facial Expression Recognition ...
أحلام انصارى
 
Intention recognition for dynamic role exchange in haptic
Intention recognition for dynamic role exchange in haptic
أحلام انصارى
 
Noise Adaptive Training for Robust Automatic Speech Recognition
Noise Adaptive Training for Robust Automatic Speech Recognition
أحلام انصارى
 
Human behaviour analysis based on New motion descriptor
Human behaviour analysis based on New motion descriptor
أحلام انصارى
 
Recognizing Human-Object Interactions in Still Images by Modeling the Mutual ...
Recognizing Human-Object Interactions in Still Images by Modeling the Mutual ...
أحلام انصارى
 
Multimodal Biometric Human Recognition for Perceptual Human–Computer Interaction
Multimodal Biometric Human Recognition for Perceptual Human–Computer Interaction
أحلام انصارى
 
Security issues in cloud database
Security issues in cloud database
أحلام انصارى
 
Html5 offers 5 times better ways to hijack the website
Html5 offers 5 times better ways to hijack the website
أحلام انصارى
 
Honey pot in cloud computing
Honey pot in cloud computing
أحلام انصارى
 
grid authentication
grid authentication
أحلام انصارى
 
Security As A Service In Cloud(SECaaS)
Security As A Service In Cloud(SECaaS)
أحلام انصارى
 
Dos presentation by ahlam shakeel
Dos presentation by ahlam shakeel
أحلام انصارى
 
Soa
Soa
أحلام انصارى
 
Rbac
Rbac
أحلام انصارى
 
Password craking techniques
Password craking techniques
أحلام انصارى
 
Operating system vulnerability and control
Operating system vulnerability and control
أحلام انصارى
 
Network ssecurity toolkit
Network ssecurity toolkit
أحلام انصارى
 
Image forgery and security
Image forgery and security
أحلام انصارى
 
Image based authentication
Image based authentication
أحلام انصارى
 
Dmz
Dmz
أحلام انصارى
 
An Enhanced Independent Component-Based Human Facial Expression Recognition ...
An Enhanced Independent Component-Based Human Facial Expression Recognition ...
أحلام انصارى
 
Intention recognition for dynamic role exchange in haptic
Intention recognition for dynamic role exchange in haptic
أحلام انصارى
 
Noise Adaptive Training for Robust Automatic Speech Recognition
Noise Adaptive Training for Robust Automatic Speech Recognition
أحلام انصارى
 
Human behaviour analysis based on New motion descriptor
Human behaviour analysis based on New motion descriptor
أحلام انصارى
 
Recognizing Human-Object Interactions in Still Images by Modeling the Mutual ...
Recognizing Human-Object Interactions in Still Images by Modeling the Mutual ...
أحلام انصارى
 
Multimodal Biometric Human Recognition for Perceptual Human–Computer Interaction
Multimodal Biometric Human Recognition for Perceptual Human–Computer Interaction
أحلام انصارى
 
Html5 offers 5 times better ways to hijack the website
Html5 offers 5 times better ways to hijack the website
أحلام انصارى
 
Operating system vulnerability and control
Operating system vulnerability and control
أحلام انصارى
 

Recently uploaded (20)

Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 6-14-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
Intellectual Property Right (Jurisprudence).pptx
Intellectual Property Right (Jurisprudence).pptx
Vishal Chanalia
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
OBSESSIVE COMPULSIVE DISORDER.pptx IN 5TH SEMESTER B.SC NURSING, 2ND YEAR GNM...
parmarjuli1412
 
LDMMIA Shop & Student News Summer Solstice 25
LDMMIA Shop & Student News Summer Solstice 25
LDM & Mia eStudios
 
2025 June Year 9 Presentation: Subject selection.pptx
2025 June Year 9 Presentation: Subject selection.pptx
mansk2
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
INDUCTIVE EFFECT slide for first prof pharamacy students
INDUCTIVE EFFECT slide for first prof pharamacy students
SHABNAM FAIZ
 
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
Filipino 9 Maikling Kwento Ang Ama Panitikang Asiyano
sumadsadjelly121997
 
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
ECONOMICS, DISASTER MANAGEMENT, ROAD SAFETY - STUDY MATERIAL [10TH]
SHERAZ AHMAD LONE
 
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
Romanticism in Love and Sacrifice An Analysis of Oscar Wilde’s The Nightingal...
KaryanaTantri21
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Birnagar High School Platinum Jubilee Quiz.pptx
Birnagar High School Platinum Jubilee Quiz.pptx
Sourav Kr Podder
 
Code Profiling in Odoo 18 - Odoo 18 Slides
Code Profiling in Odoo 18 - Odoo 18 Slides
Celine George
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
Hurricane Helene Application Documents Checklists
Hurricane Helene Application Documents Checklists
Mebane Rash
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
Intellectual Property Right (Jurisprudence).pptx
Intellectual Property Right (Jurisprudence).pptx
Vishal Chanalia
 

Analysis of Algorithm

  • 2. 1. Approximation Algorithm 2. Performance Ratio of AA 3. Examples of AA 4. The vertex-cover problem - Algorithm - Example 5. Traveling salesman problem - Algorithm - Example 6. Cover-Set Problem - Algorithm - Example 7. Genetic Algorithm -Algorithm for GA - Pictorial Representation of GA - Working Principle 8. Solving TSP using GA - Steps - Flowchart -Solution with Example 9. Analysis of TSP Algorithms 10. Results 11.Conclusion
  • 3. Abstract In computer science and operations research, approximation algorithms are algorithms used to find approximate solutions to optimization problems. Approximation algorithms are often associated with NP-hard problems . The Travelling Salesman Problem (TSP) is a deceptively simple combinatorial problem. It can be stated very simply: A salesman spends his time visiting N cities (or nodes) cyclically. In one tour he visits each city just once, and finishes up where he started. In what order should he visit them to minimize the distance traveled? TSP is applied in many different places such as warehousing, material handling and facility planning. Although optimal algorithms exist for solving the TSP, like the IP formulation, industrial engineers have realized that it is computationally infeasible to obtain the optimal solution to TSP. And it has been proved that for large-size TSP, it is almost impossible to generate an optimal solution within a reasonable amount of time. Heuristics, instead of optimal algorithms, are extensively used to solved such problems. People conceived many heuristic algorithms to get near optimal solutions. Among them, there are greedy and genetic algorithm, etc. But their efficiencies vary from case to case, from size to size . In this paper we will compare a normal Approximation Algorithm with the Genetic Algorithm to see which one gives the best optimal solution
  • 5. In computer science and operations research, approximation algorithms are algorithms used to find approximate solutions to optimization problems. Approximation Algorithm
  • 6. Approximation algorithms are often associated with NP-hard problems. Since it is unlikely that there can ever be efficient polynomial time exact algorithms solving NP-hard problems, one settles for polynomial time sub-optimal solutions. Approximation Algorithm
  • 7. Approximation algorithms are increasingly being used for problems where exact polynomial-time algorithms are known but are too expensive due to the input size.[1] Approximation Algorithm
  • 8. Performance ratios of Approximation Algorithm
  • 9. A problem (knapsack, traveling salesperson) is denoted by P. Let I be an instance of problem P Cost of optimal solution for instance I is given by C (I), and C(I) > 0 Optimal solution may be defined as maximum or minimum possible cost (maximization or minimization problem) Performance ratios of Approximation Algorithm
  • 10. If for any input of size n, the cost C of the solution produced by the algorithm is within a factor of ρ(n) of the cost C* of an optimal solution: Max ( C/C* , C*/C ) ≤ ρ(n) We call this algorithm as an ρ(n)-approximation algorithm. Performance ratios of Approximation Algorithm
  • 11. Cost of approximate solution C*(I) C*(I) < C (I) [Approximate solution < optimal solution] if P is a maximization problem. 0<C*≤C , ρ(n) = C/C* C*(I) > C(I) [Approximate solution > optimal solution] if P is a minimization problem. 0<C≤C* , ρ(n) = C*/C [2] Performance ratios of Approximation Algorithm
  • 13. Vertex cover problem. Traveling salesman problem. Set cover problem. Examples of Approximation Algorithm
  • 15. A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. The problem of finding a minimum vertex cover is a classical optimization problem in computer science and is a typical example of an NP-hard optimization problem that has an approximation algorithm. The vertex-cover problem
  • 16. A vertex cover of an undirected graph G = (V,E) is a subset V` of the vertices of the graph which contains at least one of the two endpoints of each edge and V` is a subset of V . The size of a vertex cover is the number of vertices in it.[3] The vertex-cover problem
  • 17. Example Fig: 1 The vertex-cover problem Optimal Size=3 Near Optimal size=6
  • 18. Procedures 1. Given a simple graph G with n vertices and a vertex cover C of G, if C has no removable vertices, output C. Else, for each removable vertex v of C, find the number ρ(C−{v}) of removable vertices of the vertex cover C−{v}. Let vmax denote a removable vertex such that ρ(C−{vmax}) is a maximum and obtain the vertex cover C−{vmax}. Repeat until the vertex cover has no removable vertices. The vertex-cover problem
  • 19. Contd… 2. Given a simple graph G with n vertices and a minimal vertex cover C of G, if there is no vertex v in C such that v has exactly one neighbor w outside C, output C. Else, find a vertex v in C such that v has exactly one neighbor w outside C. Define Cv,w by removing v from C and adding w to C. Perform procedure 3.1 on Cv,w and output the resulting vertex cover.[5] The vertex-cover problem
  • 20. Algorithm Given as input a simple graph G with n vertices labeled 1, 2, …, n, search for a vertex cover of size at most k. At each stage, if the vertex cover obtained has size at most k, then stop. The vertex-cover problem
  • 21. Contd… Part 1: For i = 1, 2, ..., n in turn Initialize the vertex cover Ci = V−{i}. Perform procedure 1 on Ci. For r = 1, 2, ..., n−k perform procedure 2 repeated r times. The result is a minimal vertex cover Ci. The vertex-cover problem
  • 22. Contd… Part 2: For each pair of minimal vertex covers Ci, Cj found in Part 1 Initialize the vertex cover Ci, j = Ci∪Cj . Perform procedure 1 on Ci, j. For r = 1, 2, ..., n−k perform procedure 2 repeated r times. The result is a minimal vertex cover Ci, j.[5] The vertex-cover problem
  • 23. Example The input is the graph [6] shown below with n = 12 vertices labeled V = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12}. The vertex-cover problem
  • 24. Contd… Fig: 2 The vertex-cover problem
  • 25. Contd… We search for a vertex cover of size at most k = 7. Part I for i = 1 and i = 2 yields vertex covers C1 and C2 of size 8, so we give the details starting from i = 3 The vertex-cover problem
  • 26. Contd… We initialize the vertex cover as C3 = V−{3}={1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12}. The vertex-cover problem
  • 27. Contd… We now perform procedure 1. Here are the results in tabular form: Vertex Cover C3 = {1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12}. Size: 11. The vertex-cover problem
  • 33. The traveling salesman problem (TSP) is an NP-hard problem in combinatorial optimization studied in operations research and theoretical computer science. Given a list of cities and their pair wise distances, the task is to find a shortest possible tour that visits each city exactly once. [3] Traveling salesman problem
  • 34. Given an undirected weighted Graph G we are to find a minimum cost Hamiltonian cycle. Traveling salesman problem
  • 36. Example Fig: 3 Traveling salesman problem 2 2 3 9 8 7 4 1 3 9 9 9 9 7 7 5 5 7 7 4 Solution for TSP
  • 37. The set cover problem
  • 38. The set cover problem is to identify the smallest number of sets whose union still contains all elements in the universe. The set cover problem
  • 39. Algorithm The set cover problem
  • 40. Example Assume we are given the following elements U = {1,2,3,4,5} and sets S = {{1,2,3},{2,4},{3,4},{4,5}}. Clearly the union of all the sets in S contain all elements in U. However, we can cover all of the elements with the following, smaller number of sets: SETCOVER = {{1,2,3},{4,5}}. [4] The set cover problem
  • 41. The set cover problem Fig: 4 1 2 5 4 3 SET COVER SET COVER
  • 43. Genetic Algorithms are a family of computational models inspired by evolution. These algorithms encode a potential solution to a specific problem on a simple chromosome-like data structure and apply recombination operators to these structures as to preserve critical information. Genetic algorithms are often viewed as function optimizer, although the range of problems to which genetic algorithms have been applied are quite broad.[7] Genetic Algorithm
  • 44. An implementation of genetic algorithm begins with a population of (typically random) chromosomes. One then evaluates these structures and allocated reproductive opportunities in such a way that these chromosomes which represent a better solution to the target problem are given more chances to `reproduce’ than those chromosomes which are poorer solutions. The 'goodness' of a solution is typically defined with respect to the current population. Genetic Algorithm
  • 45. Algorithm GA formulate initial population randomly initialize population repeat evaluate objective function find fitness function apply genetic operators reproduction crossover mutation until stopping criteria Genetic Algorithm
  • 46. The Pictorial representation of the Working Principle of a Simple Genetic Algorithm Fig: 5
  • 47. The Travelling salesman and Vertex cover can be solved using Genetic Algorithm. In order to use GA’s to solve the above problems we need to follow the working principles of GA. Genetic Algorithm
  • 48. 1.Coding Variables are first coded in some string structures . Fig: 6 Genetic Algorithm
  • 49. Binary-coded strings having 1's and 0's are mostly used. The length of the string is usually determined according to the desired solution accuracy. For example, if four bits are used to code each variable in a two-variable optimization problem, the strings (0000 0000) and (1111 1111) would represent the points respectively Genetic Algorithm
  • 50. B ecause the sub-strings (0000) and (1111) have the minimum and the maximum decoded values. Any other eight bit string can be found to represent a point in the search space according to a xed mapping rule. Usually, the following linear mapping rule is used: Genetic Algorithm
  • 51. 2. Fitness function A Fitness function F(i) is first derived from the objective function and used in successive genetic operations. Fitness in biological sense is a quality value which is a measure of the reproductive efficiency of chromosomes. Genetic Algorithm
  • 52. Individuals with higher fitness value will have higher probability of being selected as candidates for further examination. Certain genetic operators require that the fitness function be non-negative, although certain operators need not have this requirement. Genetic Algorithm
  • 53. Two commonly adopted fitness mappings is presented below: 1. 2. Genetic Algorithm
  • 54. 3. GA operator The operation of GA’s begins with a population of a random strings representing design or decision variables. The population is then operated by three main operators; reproduction, crossover and mutation to create a new population of points. GA’s can be viewed as trying to maximize the fitness function, by evaluating several solution vectors. The purpose of these operators is to create new solution vectors by selection, combination or alteration of the current solution vectors that have shown to be good temporary solutions. Genetic Algorithm
  • 55. 4. Reproduction Reproduction (or selection) is an operator that makes more copies of better strings in a new population. Reproduction is usually the first operator applied on a population. Reproduction selects good strings in a population and forms a mating pool. This is one of the reason for the reproduction operation to be sometimes known as the selection operator. Thus, in reproduction operation the process of natural selection cause those individuals that encode successful structures to produce copies more frequently. To sustain the generation of a new population, the reproduction of the individuals in the current population is necessary. For better individuals, these should be from the fittest individuals of the previous population. Genetic Algorithm
  • 56. 5. Crossover A crossover operator is used to recombine two strings to get a better string. In crossover operation, recombination process creates different individuals in the successive generations by combining material from two individuals of the previous generation. In reproduction, good strings in a population are probabilistic-ally assigned a larger number of copies and a mating pool is formed. It is important to note that no new strings are formed in the reproduction phase. In the crossover operator, new strings are created by exchanging information among strings of the mating pool. The two strings participating in the crossover operation are known as parent strings and the resulting strings are known as children strings. Genetic Algorithm
  • 57. One site crossover and two site crossover are the most common ones adopted. In most crossover operators, two strings are picked from the mating pool at random and some portion of the strings are exchanged between the strings. Crossover operation is done at string level by randomly selecting two strings for crossover operations. A one site crossover operator is performed by randomly choosing a crossing site along the string and by exchanging all bits on the right side of the crossing site. Genetic Algorithm
  • 58. One site crossover operation Fig: 7 Genetic Algorithm
  • 59. Two site crossover operation Fig: 8 Genetic Algorithm
  • 60. 6. Mutation Mutation adds new information in a random way to the genetic search process and ultimately helps to avoid getting trapped at local optima. It is an operator that introduces diversity in the population whenever the population tends to become homogeneous due to repeated use of reproduction and crossover operators. Mutation may cause the chromosomes of individuals to be different from those of their parent individuals. Genetic Algorithm
  • 61. Mutation in a way is the process of randomly disturbing genetic information. They operate at the bit level; when the bits are being copied from the current string to the new string, there is probability that each bit may become mutated. This probability is usually a quite small value, called as mutation probability p m.[7] Genetic Algorithm
  • 63. Step to be followed i. Randomly create the initial population of individual strings of the given TSP problem and create a matrix representation of each, must satisfy the two basic conditions as mentioned earlier. ii. Assign a fitness to each individual in the population using fitness criteria measure, F(t)=value of assignment of given problem value of the string The selection criterion depends upon the value of the strings if it is close to 1. Solving TSP using GA
  • 64. iii. Create new off-spring population of strings from the two existing strings in the parent population by applying crossover operation. iv. Mutate the resultant off-springs if required. Note: After the cross-over and mutation off-spring population has the fitness higher than the parents. v. Call the new off-springs as parent population and continue the steps (iii) and (iv) until we get a single offspring that will be an optimal or near optimal solution to the problem. Solving TSP using GA
  • 65. Fig 9: Flow chart of TSP using GA
  • 66. 1. Matrix Representation: According to the algorithm we are presenting the tour as binary matrix. In figure (A,B,C,D,E) every gene is presented as binary bits, if the element (i ,j) in the matrix is a set to 1 its mean there is an edge (directed path) between the city I to city j in the tour.[8] Solving TSP using GA
  • 67. Fig: 10 Solving TSP using GA
  • 68. According to the algorithm we are presenting the tour as a binary matrix. In fig 10 gene is represented as a binary bit, if the element (i,j) is set to (1) its mean that there is an edge (directed path) between the city I and city j in the tour. The above representation is for symmetric matrix TSP that the d ij = d ji . For asymmetric matrix that is when d ij ≠ d ji the above representation will be considered as, Solving TSP using GA
  • 69. Fig: 11 Solving TSP using GA
  • 70. The left upper triangle (LUTM) represents the movement from left to right that is the forward movement. In (LUTM) we have the path from A->B, B->C, C->E. where as the upper right triangular matrix (URTM) represents the movement from bottom to top, in (URTM) there is the path from E->D, D->A. In this way the complete tour will be, A->B-> C->E -> D->A Solving TSP using GA
  • 71. The matrix representation must satisfy the two conditions to satisfy a legal tour: symmetric case asymmetric case Solving TSP using GA
  • 72. For symmetric case (i) The number of matrix element that has the value (1) must equal to the number of vertices in the tour. (ii) The number of matrix elements that have the value of (1) in each row and each column of the same vertex must be equal to two. Solving TSP using GA
  • 73. For asymmetric case: (i) The total number of the element that has the value (1) in both (LUTM) and (RUTM) must be equal to the number of vertices in the tour. (ii) For the same vertex the sum of both matrix elements that has the value (1) must be equal to 2. Solving TSP using GA
  • 74. 2. Cross-over Operation Here we are using the cross-over operator by applying the OR operation on the two parent matrices to get a single matrix. Solving TSP using GA
  • 75. 3. Mutation Operation If the resultant tour (matrix) is an illegal tour (i.e does not satisfy the two condition mentioned above), then it must be repaired. This is done by counting the number of element with (1) value in each row and column for the city, if the number is greater than 2 then repeat deleting the longest edge from the resultant tour until the number of element in the resultant tour is equal to 2. However, if the number of elements in the resultant tour is less then 2 than add the missing edges in the tour by greedy algorithm. Considering two tours T1: A->E-> C->D -> B->A=17 T2: A->B-> E->C -> D->A=22 Solving TSP using GA
  • 76. Then cross-over and mutation of these two tours will be, Fig: 12
  • 77. Example Consider the weighted matrix, Solving TSP using GA
  • 78. The value of the assignment of the above problem is 13 Initial population: A->E-> C->D -> B->A=17 A->B-> E->C -> D->A=22 A->C-> D->E -> B->A=23 A->B-> D->C -> E->A=24 A->E-> B->C -> D->A=25 A->B-> C->E -> D->A=26 A->E-> D->C -> B->A=28 A->D-> C->E -> B->A=29 A->E-> C->B -> D->A=30 According to the fitness criteria we are selecting the tour having values, 17,22,25,29 Solving TSP using GA
  • 79. The resultant tour will be, A->B-> C->D-> E->A=15 Solving TSP using GA
  • 80. Analysis of TSP Algorithms
  • 81. Greedy algorithm is the simplest improvement algorithm. It starts with the departure Node 1. Then the algorithm calculates all the distances to other n-1 nodes. Go to the next closest node. Take the current node as the departing node, and select the next nearest node from the remaining n-2 nodes. The process continues until all the nodes are visited once and only once then back to Node 1. When the algorithm is terminated, the sequence is returned as the best tour; that is the final solution. The advantage of this algorithm is its simplicity to understand and implement. Sometime, it may lead to a very good solution when the problem size is small. Also, because this algorithm does not entail any exchange of nodes, it saves considerably much computational time. Analysis of TSP Algorithms
  • 82. Genetic Algorithm as the name implies, this algorithm gets its idea from genetics. The algorithm works this way. By obtaining the maximum number of individuals in the population and the maximum number of generations from the user, generate solutions for the first generation’s population randomly, and represent each solution as a string. Mutation to generate a population by swapping any two randomly selected genes. Genetic Algorithm works better than the Greedy method but its complicated and require a large amount of computation time. [9] Analysis of TSP Algorithms
  • 84. Result Based on Length Comparison Result 9906 4302 2295 Genetic Algorithm 10402 4478 2330 Greedy 500 100 30 Algorithm \ City Size
  • 85. Result Based on Time Comparison Result 27 6 2 Genetic Algorithm 34 8 6 Greedy 500 100 30 Algorithm \ City Size
  • 87. The Greedy algorithm takes a very long time for a large number of cities such as 500. It is not efficient to use Greedy algorithm for problem with more than 100 cites. For small-size TSP, improved greedy algorithm is recommended. For medium-size large-size problem, the genetic algorithm is recommended. Conclusion
  • 88. Reference [1] http://www.cs.uiuc.edu/class/sp09/cs598csc/ [2] Introduction to Algorithms, Thomas H. Cormen [3] http://www.cs.umsl.edu/~sanjiv/classes/cs5130/lectures/ approx.pdf [4] http://en.wikipedia.org/wiki/Set_cover_problem [5] Hybrid Genetic Algorithm for Minimum Vertex Cover Problem, in Proceedings of Met heuristics International Conference, 2003, pp 13-17 [6] R. Frucht Graphs of degree three with a given abstract group, Canad. J. Math., 1949 [7] http://www.civil.iitb.ac.in/tvm/2701_dga/2701-ga-notes/gadoc.pdf [8] http://www.ijens.org/96110-1414%20IJBAS-IJENS.pdf [9] D. Whitley, “Modeling Hybrid Genetic Algorithms”. Genetic Algorithms in Engineering and Computer Science, Winter, Periaux, Galan and Cuesta, eds. pp: 191- 201, Wiley, 1995. [10] Traveling Salesman Problem Based on Genetic Algorithm, Third International Conference on Natural Computation (ICNC 2007)
  • 89. Thank you for your attendance and attention.