{'id': '3', 'graph': [[3],[0],[1],[2],[5],[4]]} ] c = 0.85 tol = 0.001 dataDirectory = '../../data/exp3' outDirectory = 'exp3' executable = '../../tp' if not os.path.exists(outDirectory): os.mkdir(outDirectory) if not os.path.exists(dataDirectory): os.mkdir(dataDirectory) dataSuffix = dataDirectory + '/exp3' outSuffix = outDirectory + '/exp3' for i in instances: print "Procesando instancia " + i['id'] graphFile = dataSuffix + '-' + i['id'] + '-graph.txt' if not os.path.isfile(graphFile): print ' Generando datos de entrada' graphs.writeGraph(i['graph'], graphFile) for j in [0, 1]: print ' Corriendo algoritmo ' + str(j) outFile = outSuffix + '-' + i['id'] + '-' + str(j) + '.out.txt' subprocess.call([executable, str(j), str(c), '0', graphFile, str(tol), '-o', outFile])
nodes = [400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 4000, 6000, 8000, 10000, 20000, 40000, 60000, 80000, 100000] edges = 100000 dataSuffix = dataDirectory + '/exp1-a' outSuffix = outDirectory + '/exp1-a' timesFile = outSuffix + '-times.txt' with open(timesFile, 'w') as f: f.write(str(repetitions) + '\n') for n in nodes: print ' Corriendo instancia con ' + str(n) + ' nodos' graphFile = dataSuffix + '-' + str(n) + '-graph.txt' if not os.path.isfile(graphFile): print ' Generando datos de entrada' graph = graphs.randomGraph(n, edges) graphs.writeGraph(graph, graphFile) outFile = outSuffix + '-' + str(n) + '.out.txt' f.write(str(n)) sys.stdout.write(' Repeticiones:') sys.stdout.flush() for i in range(repetitions): sys.stdout.write(' ' + str(i + 1)) sys.stdout.flush() p = subprocess.Popen([executable, '0', str(c), '0', graphFile, str(tol), '-t', '-o', outFile], stdout=subprocess.PIPE) f.write(' ' + p.communicate()[0][39:-1]) sys.stdout.write('\n') f.write('\n') # Etapa B print 'Etapa B'