{"id":1873,"date":"2018-12-14T12:00:00","date_gmt":"2018-12-14T11:00:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/basics-of-genetic-algorithm-ga-explained-in-simple-terms\/"},"modified":"2026-07-05T03:21:32","modified_gmt":"2026-07-05T01:21:32","slug":"basics-of-genetic-algorithm-ga-explained-in-simple-terms","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/basics-of-genetic-algorithm-ga-explained-in-simple-terms\/","title":{"rendered":"Basics of Genetic Algorithm \u2013 GA (Explained in Simple Terms)"},"content":{"rendered":"<p>We would examine the basics of Genetic Algorithm and dive a little deeper into the actual steps in genetics algorithm. I will try to be clear and also explain the any term I use clearly.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-227 \" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Basics-of-Genetic-Algorithm2-1024x477.jpg\" alt=\"\" width=\"449\" height=\"209\" \/><\/p>\n<p>We would cover the following topics:<\/p>\n<ol>\n<li><a href=\"#t1\">Introduction of Genetic Algorithm<\/a><\/li>\n<li><a href=\"#t2\">How Genetic Algorithm Works<\/a><\/li>\n<li><a href=\"#t3\">Motivation for Genetic Algorithm<\/a><\/li>\n<li><a href=\"#t4\">Phases in Genetic Algorithm<\/a><\/li>\n<ul>\n<li><a href=\"#ta\">Initial Population<\/a><\/li>\n<li><a href=\"#tb\">Fitness Function<\/a><\/li>\n<li><a href=\"#tc\">Selection<\/a><\/li>\n<li><a href=\"#td\">Cross-Over<\/a><\/li>\n<li><a href=\"#te\">Mutation<\/a><\/li>\n<li><a href=\"#tf\">Termination<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#t5\">Application Areas of Genetic Algorithm<\/a><\/li>\n<li><a href=\"#t6\">The Actual Algorithm (Simplified)<\/a><\/li>\n<li><a href=\"#t7\">Advantages Genetic Algorithm<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p><strong><\/p>\n<h5 id=\"t1\">1. Introduction of Genetic Algorithm<\/h5>\n<p><\/strong><\/p>\n<p>Genetic Algorithm(GA) is a class of random-based classical algorithms based on Charlse Darwin&#8217;s theory of evolution.\u00a0 It is also regarded as a process of solving optimization problems by method of natural selection.\u00a0 It is yet another human&#8217;s desperate attempt to mimic what is thought to\u00a0 happen in nature. It answers questions like:<\/p>\n<ul>\n<li>Why do some organisms die off while some live on?<\/li>\n<li>Why are there more women than men in certain places?<\/li>\n<li>Why do certain plants thrive in certain region, but don&#8217;t survive in other region<\/li>\n<li>Why is there difference in the population of various living things<\/li>\n<\/ul>\n<p>It then appears that there is something about living things, deep in their genes that could explain this. Some kind of biological process (algorithm) that explains this. Genetic Algorithm tend to explain the concept of &#8216;survival of the fittest&#8217; in a formal and systematic way.<\/p>\n<figure id=\"attachment_226\" aria-describedby=\"caption-attachment-226\" style=\"width: 416px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-226 \" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Genetic-Algorithm-Phases.jpg\" alt=\"\" width=\"416\" height=\"466\" \/><figcaption id=\"caption-attachment-226\" class=\"wp-caption-text\">Genetic Algorithm Phases<\/figcaption><\/figure>\n<p><strong><\/p>\n<h5 id=\"t2\">2. How Genetic Algorithm Works<\/h5>\n<p><\/strong><\/p>\n<p>Just a mentioned before, Genetic Algorithm works by the process of natural selection. It starts from an initial, maybe random population (which represent a pool of all possible solutions to a problem). Then these population undergoes several processed such as Selection, Cross-Over and Mutation and finally produces the best results (optimal solution) at the end of the process.<\/p>\n<p>&nbsp;<\/p>\n<p><strong><\/p>\n<h5 id=\"t3\">3. Motivation for Genetic Algorithm<\/h5>\n<p><\/strong><\/p>\n<p>By application of Genetic Algorithms, we are able to find optimal solutions to difficult problems. How? In the field of Artificial Intelligence and Machine Learning, there seems to be problem that does not have an exact solution, a class of optimization problems. Attempt to find exact solution would require time as well as much complexity that exceeds the current available computing systems. But by applying GA, the problems can then be solved or optimized and in lesser time. The motivation for GA can be classified into three:<\/p>\n<ul>\n<li>Solving Difficult Problems<\/li>\n<li>Alternative to Gradient-Based Methods<\/li>\n<li>Speed of Convergence<\/li>\n<\/ul>\n<figure id=\"attachment_223\" aria-describedby=\"caption-attachment-223\" style=\"width: 435px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-223 \" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Genetic-Algorithm-Illustrated.jpg\" alt=\"\" width=\"435\" height=\"288\" \/><figcaption id=\"caption-attachment-223\" class=\"wp-caption-text\">Figure 1.0: Population, Chromosomes and Genes<\/figcaption><\/figure>\n<p><strong><\/p>\n<h5 id=\"t4\">4. Phases in Genetic Algorithm<\/h5>\n<p><\/strong><\/p>\n<p>Genetic Algorithm proceeds from an initial population through several phases till the termination when the optimal solution have been deduced. Let&#8217;s now examine the different phases of Genetic algorithm.<\/p>\n<p><strong id =\"ta\">a. Initial Population<\/strong><\/p>\n<p>This is the first phase of the process where an initial population is selected. The initial population is simply a set of individuals which are potential solution to the problem we want to solve. It could actually be made of of thousands or even hundreds of thousands of individuals that may have been randomly selected or selected based on some specified criteria.\u00a0 The two methods of initializing the population are summarized as:<\/p>\n<ul>\n<li>Random Initialization: selection is made randomly<\/li>\n<li>Heuristic Initialization: based on some rules<\/li>\n<\/ul>\n<p><strong id =\"tb\">b. Fitness Function Definition<\/strong><\/p>\n<p>This phase could also be regarded as part of the Initial phase (Initial Population) and it could also be part of the Selection phase. This is\u00a0 a way of specifying the criteria for the &#8216;goodness&#8217; of a given solution compared to others and to the problem being solved. Based on the fitness, members of the population are separated into two parts: those that are fit enough to be selected into the next generation and those that would be dropped.<\/p>\n<p>One approach to this is to have a fitness score for each individual in the population. So when this score is passed into the fitness function, it returns either 1(pass) or 0 (fail).<\/p>\n<p><strong id =\"tc\">c. Selection<\/strong><\/p>\n<p>Selection is simple the process of selecting the portion of the population that would pass into the next generation. The selection process is based on the fitness criteria from the preceding phase. Two pairs of individual members of the population are selected (like parents) based on their fitness. These parents would be used to produced individual for the next generation. In this way we are sure that the parents would pass on their &#8216;genes&#8217; to the next generation<\/p>\n<p><strong id =\"td\">d. Cross-Over<\/strong><\/p>\n<p>Cross-over is the most noteworthy of the phases of genetic algorithm.\u00a0 This is also called recombination. It is a genetic operator that determines what information is passed from the the two parents to the new offspring.\u00a0 This is illustrated below in Figure 1.1:<\/p>\n<figure id=\"attachment_224\" aria-describedby=\"caption-attachment-224\" style=\"width: 583px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-224 \" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Crossover-in-GA-1024x478.jpg\" alt=\"\" width=\"583\" height=\"272\" \/><figcaption id=\"caption-attachment-224\" class=\"wp-caption-text\">Figure 1.1: Illustration of Cross-over phase<\/figcaption><\/figure>\n<p>Cross-over point is the point in within the genes of the parents at which the cross-over occurs.<\/p>\n<p><strong id =\"te\">e. Mutation<\/strong><\/p>\n<p>Mutation is a random change in the chromosome of the new offspring. This change occurs with a little probability. The benefit of this phase is that if tends to prevent the algorithm from converging in a local minimum. To do this, a mutation rate is carefully chosen. This is illustrated in Figure 1.2<\/p>\n<figure id=\"attachment_225\" aria-describedby=\"caption-attachment-225\" style=\"width: 502px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-225 \" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Mutation-Illustrated.jpg\" alt=\"\" width=\"502\" height=\"233\" \/><figcaption id=\"caption-attachment-225\" class=\"wp-caption-text\">Figure 1.2: Mutation phase illustrated<\/figcaption><\/figure>\n<p><strong id =\"tf\">f. Termination<\/strong><\/p>\n<p>After a number of iterations through the phases of the algorithm, the process terminates based on certain defined termination criteria. At this stage the optimal solution is reached. Some of the possible termination conditions include:<\/p>\n<ul>\n<li>there is no further improvements<\/li>\n<li>given number of generations is reached<\/li>\n<li>objective function reaches minimum value<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong><\/p>\n<h5 id=\"t5\">5. Application Areas of Genetic Algorithm<\/h5>\n<p><\/strong><\/p>\n<p>Genetic Algorithm is used in many areas same as Neural Network, Fuzzy Logic etc. Some of the application areas of GA include:<\/p>\n<ul>\n<li><em>Image Processing &amp; Recognition<\/em>: GA is applied in digital image processing\u00a0 and recognition. This if further applied in pattern matching, image compression and reconstruction<\/li>\n<li><em>Optimization Problem Solving<\/em>: This is the most common application of genetic algorithm. It can be applied to find optimal solution to certain problems that can be represented as a cost or objective function.<\/li>\n<li><em>DNA\u00a0 Analysis<\/em>: Genetic Algorithms have been applied\u00a0 to create DNA profiles using spectrometric data from DNA samples<\/li>\n<li><em>Neural Network<\/em>: Training of neural network require an iterative process of reducing particular error quantity untill it reaches a minimum value.\u00a0 GA is applied here.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong><\/p>\n<h5 id=\"t6\">6. The Actual Algorithm (Simplified)<\/h5>\n<p><\/strong><\/p>\n<p>Now, I&#8217;m going to present a simplified form of the high-level view of the genetic algorithm. This algorithm is given below in Listing 1.0. We consider the implementation of the generalized algorithm (more detailed) in a different lesson<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #000080; font-weight: bold;\">BEGIN<\/span>\nGenerate Initial Population\nDetermine Fitness\nREPEAT<span style=\"color: #a61717; background-color: #e3d2d2;\">:<\/span>\n  Perform Selection\n  Perform Crossover\n  Perform Mutation\n  Compute Fitness\n<span style=\"color: #000080; font-weight: bold;\">UNTIL<\/span> population converges\n<span style=\"color: #000080; font-weight: bold;\">END<\/span>\n<\/pre>\n<\/div>\n<p>Listing 1.0: Simplified Genetic Algorithm<\/p>\n<p>&nbsp;<\/p>\n<p><strong><\/p>\n<h5 id=\"t7\">7. Advantages of Genetic Algorithms<\/h5>\n<p><\/strong><\/p>\n<p>Some of the advantages of GA includes:<\/p>\n<ul>\n<li>\n<h5 id=\"ta\">Can be applied to both continuous and discreet function<\/li>\n<li>\n<h5 id=\"tb\">\n<h5 id=\"t1\">Can be applied in multi-objective problems<\/li>\n<li>\n<h5 id=\"tc\">Very efficient in terms of time and space complexity<\/li>\n<li>\n<h5 id=\"td\">Provides improved solution over time<\/li>\n<li>\n<h5 id=\"te\">Can be applied when the search space is very large and involved many parameters<\/li>\n<li>\n<h5 id=\"tf\">Requires no derivative information<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>We would examine the basics of Genetic Algorithm and dive a little deeper into the actual steps in genetics algorithm. I will try to be &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[16],"tags":[],"class_list":["post-1873","post","type-post","status-publish","format-standard","hentry","category-machine-learning"],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1873","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=1873"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1873\/revisions"}],"predecessor-version":[{"id":2041,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1873\/revisions\/2041"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=1873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=1873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=1873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}