Question: Homework #2. (Practicing Genetic Algorithm) Homework (Project #1) description. Implement a genetic algorithm to solve the following problem: Consider filling a MxN rectangle with


Homework #2. (Practicing Genetic Algorithm) Homework (Project #1) description. Implement a genetic algorithm to solve the following problem: Consider filling a MxN rectangle with the numbers 1...MN in some random order. For example: Cost = 1 2 5 9 3 4 6 7 8 10 11 12 14 15 16 13 |1-2|+|2-3|+|3-4|+|5-6|+|6-7|+|7-8|+|9-10|+|10-11|+|11-12|| + |1-5|+|2-6|+|3-7|+|4-8|+|5-9|+|6-10|+|7-11|+|8-12| Each number has either 4 neighbors or 3 neighbors (on the edge) or 2 neighbors (in a corner). The total cost is the sum of the absolute differences between all neighboring pairs of numbers. If you come up with a fancy alternative to the genetic algorithm, you may request to implement that as an alternative to solve the same problem. To construct the initial population of completed states, you can initialize the rectangle however you want. For example, you might generate completely random initial states, use a specific ordering of the numbers, or use some other algorithm to create the initial states. Your program will accept the M and N values on the command line where N follows M, e.g., java Genetic Algorithm 2 5, where M-2 and N-5. Your program can output the solution to a test file (solution_1.txt, solution_2.txt, ...), and the total cost both to the standard output (screen) to a text file (solution_cost.txt). However, it will be given more credits if the ouputs are visualized graphically on the screen. Please test your genetic algorithm on the problems listed below. You should report: 1. One text file (solution cost.txt) should contain the total cost for each of the given problems. (one line for each) 2. For each of the problems output your solution to a separate file (solution 1.txt, solution 2.txt, etc.). Each of the files should contain only your solution (no other text), in other words it should have N columns and M rows. Try your genetic algorithm on the following problems. If your algorithm cannot solve or takes too long to solve a particular problem, please state that in your solution cost.txt file. If your algorithm takes too long to solve a problem, you may terminate or wait as long as you choose for it to complete. You are required to solve only problems 1 and 2, but we encourage you to try all of them. If your algorithm can solve the bigger problems, you will get extra credits. 1. N-4, M-5 2. N-7 M-13 3. N-37 M-35 4. N-75 M-100 5. N-490 M-730 A text file with your solution should contain just the data. In other words, it should have M rows separated by a new line character ( ) and each one of the N columns should be separated by a comma. You can use the following programming languages: Java. We will compile (if necessary) and run your code, therefore, make sure you are not using any non-standard libraries Your algorithm has to run on Windows 10. Submit all of your code and a report. In a report, describe what algorithm you have implemented and how to run your code. The report is required to be in a pdf format.
Step by Step Solution
3.39 Rating (152 Votes )
There are 3 Steps involved in it
This seems like an interesting challenge Designing a genetic algorithm to solve this problem require... View full answer
Get step-by-step solutions from verified subject matter experts
