import random import sys if len(sys.argv) == 2: x = int(sys.argv[1]) else: x = 10 file1 = open("data" + str(x) + ".lp", "w") file2 = open("data" + str(x) + ".py", "w") file3 = open("data" + str(x) + ".dat", "w") file4 = open("data" + str(x) + ".P", "w") file2.write('[\n') for i in range(x): file1.write("node({}).\n".format(str(chr(ord('a') + i)))) file2.write('[') for j in range(x): k = random.randint(1,20) if i != j: file1.write("path({}, {}).\n".format(str(chr(ord('a') + i)), str(chr(ord('a') + j)))) file1.write("edge({}, {}, {}).\n".format(str(chr(ord('a') + i)), str(chr(ord('a') + j)), k)) file4.write("edge({}, {}, {}).\n".format(str(chr(ord('a') + i)), str(chr(ord('a') + j)), k)) file2.write(str(k)) file3.write("let dist[{}, {}] := {};\n".format(i+1, j+1,k)) if j != x - 1: file2.write(", ") file2.write('],\n') file2.write(']') file1.close() file2.close() file3.close() file4.close()