In this assignment, you will implement a simple genetic algorithm in Java. Consider the problem of finding the shortest route through several cities, such that each city is visited only once and in the end return to the starting city (the Travelling Salesman problem). In the TSP optimization problem, there are n cities, assuming that the number of each city is an integer 1,2,3,...,n. and such a chromosome is made up of a n segment. For example, there are 10 cities in the TSP problem, then {1, 3, 4, 2, 6, 9, 10, 8, 5, 7} is a legitimate chromosome and a possible optimal solution.
To make implementing your GA easier, you should break up your program into the following smaller pieces, rather than trying to implement everything as one large program. Write and test each of the functions listed below separately, and then use them as building blocks in your main GA program. Feel free to write any other helper functions that you like.
• randomGenome(length) returns a random genome (Integer) of a given length.
• makePopulation(size, length) returns a new randomly created population of the specified size, represented as a list of genomes of the specified length.
• fitness(genome) returns the fitness value of a genome.
• evaluateFitness(population) returns a pair of values: the average fitness of the population as a whole and the fitness of the best individual in the population.
INSTRUCTION
In this assignment, you will implement a simple genetic algorithm in Java. Consider the problem of finding the shortest route through several cities, such that each city is visited only once and in the end return to the starting city (the Travelling Salesman problem). In the TSP optimization problem, there are n cities, assuming that the number of each city is an integer 1,2,3,...,n. and such a chromosome is made up of a n segment. For example, there are 10 cities in the TSP problem, then {1, 3, 4, 2, 6, 9, 10, 8, 5, 7} is a legitimate chromosome and a possible optimal solution.
To make implementing your GA easier, you should break up your program into the following smaller pieces, rather than trying to implement everything as one large program. Write and test each of the functions listed below separately, and then use them as building blocks in your main GA program. Feel free to write any other helper functions that you like. • randomGenome(length) returns a random genome (Integer) of a given length. • makePopulation(size, length) returns a new randomly created population of the specified size, represented as a list of genomes of the specified length. • fitness(genome) returns the fitness value of a genome. • evaluateFitness(population) returns a pair of values: the average fitness of the population as a whole and the fitness of the best individual in the population.
SUBMISSION