def main(): allCities = importData("santa_cities.csv") #allCities = importData("santa_cities_test.csv") dist = Dist(allCities) print "done with dist matrix" bestPath = furthestInsertion(allCities, dist) print evaluate(bestPath, dist) exportPaths(bestPath, "run1.csv") print noSharedEdge(bestPath)
def randPaths(allCities): path1 = allCities[:] path2 = allCities[:] while not noSharedEdge([path1,path2]): shuffle(path1) shuffle(path2) return [path1, path2]
def objFunc(paths): '''If there are no shared edges, return the longest path length if there are shared edges return the largest negative integer''' if noSharedEdge(paths): return -max(pathLength(paths[0]), pathLength(paths[1])) else: return -maxint