Implement a genetic algorithm to solve the following problem:
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:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Cost = |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
GeneticAlgorithm 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.
<Testing your algorithm>
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 ( n ) 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.
Submission Instructions
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.
In addition, please create a YouTube video. You should explain how your codes work, what the outputs of the codes are, and how those outputs were produced in that video. After uploading the video on YouTube, you should include the YouTube link in report. (If you do not include the link, you will lose 40 points)
Zip all of your code and report and text files in a zip file titled <lastname_studentid>.zip (e.g. smith_12345678.zip). Upload your zip file to the folder named “Homework #3” in the Brightspace by the deadline.
Important reminder: You must write your own codes and give your own answers. If you copy someone else’s codes or answers, it is a serious plagiarism. You will receive zero for this assignment and disciplinary actions will be taken. Late Policy: If you submit m days later than the deadline, your maximum grade will be 100*(1-0.m). For example, if m=2, your maximum grade is 100*(1-0.2)=100*0.8=80.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.