Write a program that attempts to solve the &amp;acirc;€œpartial Latin square problem&amp;acirc;€ using simple optimization techniques. Specifically your program will allow the user to input a problem, and will produce a solution using a descent method, and possibly other more sophisticated methods. The program should not allow the user to edit the spreadsheet directly. Instead, all user interaction should be carried out via UserForms and/or input boxes and message boxes.

Latin squares are n &amp;Atilde;— n arrays filled with n different symbols, each occurring once per row and once per column. Here is an example using n = 5.

3 5 1 4 2

5 4 3 2 1

1 2 4 5 3

4 3 2 1 5

2 1 5 3 4

Deadline 24/04/2012

Task 1

Write a program that reads-in a specified problem file. Program should then produce an initial solution to this problem in a randomized fashion, such that (a) the givens appear in their correct positions in the grid, and (b) all rows contain the values 1,&amp;acirc;€&amp;brvbar;,n exactly once, as explained above. If a problem contains no givens, then your program should be able to detect this and can simply return the &amp;acirc;€œroot solution&amp;acirc;€ to the user. The root solution is simply a grid that has values (1, 2,&amp;acirc;€&amp;brvbar;, n) on the first row, (2, 3,&amp;acirc;€&amp;brvbar;, n, 1) on the second row, (3, 4,&amp;acirc;€&amp;brvbar;, n, 1, 2) on the third row, and so on. For example, here are the root solutions for n = 3 and n = 5

Task 2

Assuming that your initial solution is not yet a Latin square, a cost function should now be written that calculates its quality according to the descriptions.

Next task is to write code that attempts to improve on the initial solution. To start, this is to be achieved using a random descent technique. This should operate by making a random alteration (move) to the solution and then re-evaluating. If the cost is lowered or stays the same, then we accept the changes, otherwise the change should be reset. This process is then repeated.

Task 3

Modify the code so that when an initial solution is first produced the user has a choice of using the descent method or simulated annealing. Hence write the code for carrying out the simulated annealing. You may wish to use a UserForm to allow the user to define the various choices and control parameters.

Task 4

If you have successfully completed Tasks 1-3, then try improving your program by making it more efficient, powerful and/or user-friendly. Extras to include:

Allowing your program to collect information on each run (e.g. initial cost, final cost, the changes in cost according to the number of evaluations, etc.) and then store this in a worksheet. You might also choose to include graphs that allow you to view the changes in cost that were achieved according to the number of evaluations.

Modifying your algorithm to see if further improvements might be made. For example, you could:

Make your solution evaluations more efficient by only recalculating the cost of the columns that were altered during a move;

Use different types of neighborhood operators, cooling schedules etc.

Attempt to introduce some heuristics into the algorithm e.g. clever methods for producing high-quality initial solutions, clever methods for making changes to a solution.