Babylon university-uloom college for women- advanced intelligent applicationsGenetic Algorithms----------------4TH class---------------------- zainab falah Introduction: Professor John Holland in 1975 proposed an attractive class of computational models, called Genetic Algorithms (GA), that simulate the biological evolution process for solving problems in a wide domain. GA has three main applications, namely, intelligent search, optimization and machine and robot learning. Currently, GA is used along with neural nets and fuzzy logic for solving more complex problems. Because of their joint usage in many problems, these together are often referred to by a generic name: “soft-computing”. 2.1Genetic Algorithm: Genetic algorithms are adaptive heuristic search algorithm premised on the Darwin’s evolutionary ideas of natural selection and genetic. The basic concept of genetic algorithms is designed to simulate processes in natural system necessary for evolution. Strength of Genetic Algorithm comes from: 1. Genetic algorithms are intrinsically parallel. They can explore the solution space in multiple directions at once. So convergence to an optimal solution does not depend on the chosen initial solution. 2. They are well-suited to solving problems having huge search space. 3. They perform well in problems for which the fitness landscape is complex - where the function is discontinuous, noisy, changes over time, or has many local optima. Genetic algorithm maintains a population of individuals, for generation. Each individual represents a potential solution to the problem. Each individual is evaluated to give some measure of its fitness. Some 1 Babylon university-uloom college for women- advanced intelligent applicationsGenetic Algorithms----------------4TH class---------------------- zainab falah individuals undergo random transformations by means of genetic operations to form new individuals. There are two type of transformation: Mutation, which forms new individuals by making changes in a single individual, and Crossover, which forms new individuals by combining parts from two individuals. The new individuals, called offspring , are then evaluated. A new population is formed by selecting the more fit individuals from the parent population and offspring population transformation. After several generations, genetic algorithm converges to the best individual, which represents an optimal or suboptimal solution to the problem. The flowchart of a GA work is presented below in fig.1 2 Babylon university-uloom college for women- advanced intelligent applicationsGenetic Algorithms----------------4TH class---------------------- zainab falah 2.2 Standard Genetic Algorithm(Simple genetic Algorithm): Algorithm SGA - Initial (population); - Evaluation (population); - Gen = 0; - Do - Selected_parents ← selection (population); - Created_offspring ← crossover (selected_parents); - Mutation (created_offspring); - Population ← created_offspring; - Evaluation (population); - Gen ← gen+1; - Until stop_criterion Basic concepts: 2.2.1The population size : is the number of individuals that are allowed in the population maintained by a GA. If the population size is too large, the GA tends to takes longer to converge upon a solution. However, if the population size is too small, the GA is in danger of premature convergence upon a suboptimal solution. This is primarily because there may not be enough diversity in the population to allow the GA to escape local optima. 3 Babylon university-uloom college for women- advanced intelligent applicationsGenetic Algorithms----------------4TH class---------------------- zainab falah 2.2.2 Encoding: Encoding the solutions of the problem into chromosomes is a main issue when using genetic algorithms. One excellent problem related with encoding is that some individuals correspond to infeasible or illegal solutions to a given problem. The difference between two concepts: infeasibility and illegality, is shown in fig.2. Infeasibility mean that a solution decoded from chromosome is outside the feasible area of given problem. Illegality mean that a chromosome does not represent a solution to a given problem. According to what kind of a gene, the encoding methods are the following: 1. Binary encoding. 2. Real-number encoding. 3. Integer or literal permutation encoding. a) Binary Encoding: Binary encoding (i.e., the bit strings) are the most common encoding used for several of reasons. Holland and his students concentrated on such encodings. Binary encoding for function optimization problems is know to severe drawbacks due to the existence 4 Babylon university-uloom college for women- advanced intelligent applicationsGenetic Algorithms----------------4TH class---------------------- zainab falah of Hamming cliffs, pairs of encoding having a large Hamming distance (The Hamming distance between two bit strings is defined as the number of corresponding positions in these bit strings where the bits have a different value) while belonging to points of minimal distance in phenotype space. The bit strings 1000 and 0111 differ in every single bit, therefore having maximal hamming distance of four, but encode the two adjacent integers 8 and 7. This adverse encoding may prevent the GA from converging to the global optimum in case it is located at a so-called Hamming cliff, like the one above. GAs employ a Gray code which guarantees that adjacent integers are represented by bit strings which only differ in a single bit and therefore avoid Hamming cliffs. Given a binary string si,...,s„ coding integers in the standard way, the conversion formula for obtaining the corresponding Gray-coded string gi,...,gn is the following: s1 if k =1 gk = sk+1 XOR sk if k >1 The inverse conversion is defined by means of the following expression: Table 1 compares the coding of integers 0 to 7 using binary and Gray codes. Notice that strings encoding adjacent integers have a minimal hamming distance of 1. Nevertheless, even for a Gray code, a single mutation may still result in a large change of the integer value depending 5 Babylon university-uloom college for women- advanced intelligent applicationsGenetic Algorithms----------------4TH class---------------------- zainab falah on the position of the reversed bit. In general, mutation in binary-coded GAs lacks the ability to strictly focus the search on solutions that are located close to its parents in phenotype space. Table 1 Comparison of binary and Gray codes. integer 0 1 2 3 4 5 6 7 Binary 000 001 010 011 100 101 110 111 Gray Code 000 001 011 010 110 111 101 100 Exercise: encode binary code for numbers(11-20)using gray code. b) Integer or Literal Permutation Encoding: Integer encoding is best used for combinational optimization problems because to search for the best permutation or combination of items subject to constrains. This mean that each gene is integer number therefore a chromosome consists of string of integers. Encoding binary Integer Parent Chromosome 1 | 00 010 001 0 | 01 110 000 4| 2 1 1| 6 0 Offspring Chromosome 101 000 4 6 1 2 110 000 010 001 0 1 value 560 021 460 121 Comparison between binary encoding and integer encoding. c) Real Number Encoding: Real number encoding is best used for function optimization problems. It has been widely verified that real number encoding perform better than binary encoding for function optimization and constrained 6 Babylon university-uloom college for women- advanced intelligent applicationsGenetic Algorithms----------------4TH class---------------------- zainab falah optimizations problems. In real number encoding, the structure of genotype space is identical to that of the phenotype. Each gene is real number and chromosome is string of real numbers. such as chromosome is 0.0 1.4 3.5 4.4 9.1 Exercise: give chromosome with length 8 genes encding in real form. Next lecture spooler: After knowledge of the genetic algorithm , in the next lecture , we shall know the evaluation of chromosomes and selection of chromosomes to next generation. 7