Implement a genetic algorithm to solve the following problem:

    November 5, 2022

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.
 

 
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 .zip (e.g. smith_12345678.zip). Upload your zip file to the folder named “Homework

Trust your assignments to an essay writing service with the fastest delivery time and fully original content.

Verified