Download Evolutionary Search - Computing Science and Mathematics

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Hybrid (biology) wikipedia , lookup

Genetic code wikipedia , lookup

Genetic drift wikipedia , lookup

Group selection wikipedia , lookup

Microevolution wikipedia , lookup

Gene expression programming wikipedia , lookup

Koinophilia wikipedia , lookup

Population genetics wikipedia , lookup

Transcript
University of Stirling Computing Science and Mathematics ITNPD8, Evolutionary and Heuristic Optimisation Practical 5 and 6: Evolutionary Algorithms for the Knapsack Problem Reading Material Lecture slides from the module website: “Population-­‐based Algorithms” The purpose of this lab is to implement a simple Genetic Algorithm (GA) and a Hybrid GA (also named Memetic Algorithm) for the same problem formulation and examples we considered in the previous lab (the Knapsack problem and instances: easy20.txt, hard200.txt). Background Genetic Algorithms (GAs) are the most widely known form of evolutionary algorithms. They are more complex to implement than the local search heuristics discussed so far, but are popular due to their inspiration in natural evolution. Their performance can be improved by applying local search to the individuals, or embedding knowledge of the problem into the search operators. However, we will implement a simple GA and hope that it will have better performance than the simpler local search heuristics we implemented in the previous lab. Find below the pseudo-­‐code for a simple steady-­‐state GA: Procedure Steady-­‐state GA P = Generate_initial_population Evaluate_population(P) while NOT Termination_Criterion { mom = Tournament_selection(P) dad = Tournament_selection(P) child1, child2 = crossover(mom, dad) Mutate(child1) Mutate(child2) Evaluate_individual(child1) Evaluate_individual(child2) Replace_worst(P, child1, child2) } Procedure Tournament_selection(P) ind1 = select_random_individual(P) ind2 = select_random_individual(P) if (ind1.fitness > ind2.fitness) return ind1 else return ind2 } Programming activities • In the programming language of your choice, and following the pseudo-­‐codes discussed above, implement a steady-­‐state Genetic Algorithm with the following characteristics: • Tournament selection of size two • Replacement of the two worst individual at each iteration •
•
•
•
• Mutation operator: 1-­‐flip mutation • Crossover operator: 1-­‐point crossover • Population size = 50 Implement a Hybrid GA for the same problem. Use the same characteristics of your GA, but aapply local search (hill-­‐climbing) to the offspring individuals: chlid1 and child2 before replacing them in the population. Some auxiliary source code in both Python and Java has been provided o Python: knapsack.py and binary.py o Java: Knapsack.java and binary.java Apply the algorithms to the two instances given: easy20.txt, hard200.txt You can re-­‐use all your code from the previous lab that is relevant to this activity. Check point 1. Source code and output of your GA on the two instances 2. Source code and output of your Hybrid GA on the two instances 3. Compare the performance of your simple GA vs. your Hybrid GA. 4. Compare your best GA vs. your best performing local search heuristic from the previous lab