Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the answer you do not need to run the four heuristics and get the results. J

ID: 3602669 • Letter: F

Question

For the answer you do not need to run the four heuristics and get the results. Just tell me how to get the results or give me the code to do so.

randomLAP creates random 25 X 25 matrices with values in the range of 100 to 500. It's code looks like this:

# ------------------
import sys
from random import random

# default parameter values in case they aren't specified

# on the command line
fname = 'r.csv'
num = 25
min_val = 100
max_val = 500
# command line parameters
if len(sys.argv) > 1:
# asking for help?
if sys.argv[1] == '--help':
print 'Syntax: randomLAP [fname] [num min_val max_val]'
exit()
fname = sys.argv[1]
if len(sys.argv) == 5 :
try:
num = int(sys.argv[2])
min_val = float(sys.argv[3])
max_val = float(sys.argv[4])
except:
print 'Invalid parameters. Syntax: randomLP.py fname num min_val max_val'
exit()
val_range = max_val - min_val
matrix = []
# generate the random values - use U(min_val, max_val)
for k in range(num):
matrix.append([])
for j in range(num):
matrix[k].append(min_val + (random() * val_range))
# write the file
with open(fname, 'w') as outfile:
for k in range(num):
row = ['{:.2f}'.format(x) for x in matrix[k]]
outfile.write('{} '.format(', '.join(row)))
# print information
print ' Created a {}x{} cost matrix with values in the range {} - {}. File: {} '.format(
num, num, min_val, max_val, fname
)

(30pts) Using randomLAP.py, generate five problem instances (cost matrices) with dimension 200 and values in the range 100 to 500. Store the problem instances in files named r1.csv . r5.csv. Run each of the four heuristics and the optimal provided on Canvas (lap_h1.py, lap_h2.py, lap_h3.py, lap_h4.py, and lap_optimal) with each of the five problem instances. This will result in 25 different results. Display your results in a table on your Word document similar to the one below. (You can choose any sufficiently large number for maxreps in lap h4 and nreps in lap_h3.py. Suggested value for maxreps and nreps: 10000) 1. Problem Instances H1H2 H3 H4Optimal 3 4 5

Explanation / Answer

#include <stdio.h>

int main()
{
    printf("Hello, World! I have created a dynamic 2D-array of 20x30 integers! ");
    int i,j,k,arr[20][30];
    k = 0;
    for(i=0 ; i<20 ; i++)
    {
        k = i;
        for(j=0 ; j<30 ; j++)
        {
            arr[i][j] = k;
            printf("%d ",k);
            k++;
        }
        printf(" ");
    }

    return 0;
}

                   =============>     OUTPUT      <=================

  

Hello, World! I have created a dynamic 2D-array of 20x30 integers!
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48