def Rutas_edad(analyzer, opt): if opt == "1": menor = 0 mayor = 10 elif opt == "2": menor = 11 mayor = 20 elif opt == "3": menor = 21 mayor = 30 elif opt == "4": menor = 31 mayor = 40 elif opt == "5": menor = 41 mayor = 50 elif opt == "6": menor = 51 mayor = 60 elif opt == "7": menor = 61 mayor = 200 else: return ("opción no valida") cond = 'año_lleg' condt = 'año_sal' ruta = None inicial, num = model.Rutas_edad(analyzer, menor, mayor, cond) final, number = model.Rutas_edad(analyzer, menor, mayor, condt) model.minimumCostPaths(analyzer, inicial) if hasPath(analyzer, final) != False: ruta = model.minimumCostPath(analyzer, final) lista = [] for i in ruta: for llave in ruta[i]: if ruta[i][llave] != None: x = (ruta[i]["info"]['vertexA'], ruta[i]["info"]['vertexB']) lista.append(x) else: ruta = lista Rt = { "e_i": inicial, "e_f": final, "n": num, "num": number, "ruta": ruta } return Rt
def minimumCostPaths(analyzer, initialStation): """ Calcula todos los caminos de costo minimo de initialStation a todas las otras estaciones del sistema """ return model.minimumCostPaths(analyzer, initialStation)
def opc6(analyzer,valores): for valor in valores: delta_time = -1.0 tracemalloc.start() start_time = getTime() #req narch = "bus_routes_"+str(valor)+".csv" loadServices(analyzer,narch) dest = "15151-10" model.minimumCostPaths(analyzer,"75009-10") #print(analyzer) path = model.minimumCostPath(analyzer,dest) #print("paso controller") if path is not None: pathlen = stack.size(path) print('El camino es de longitud: ' + str(pathlen)) while (not stack.isEmpty(path)): stop = stack.pop(path) print(stop) else: print('No hay camino') numedges = totalConnections(analyzer) numvertex = totalStops(analyzer) stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time print(" -- opc 6: -- ") print(str(valor)+".csv file:") print('El camino es de longitud: ' + str(pathlen)) print("Tiempo: ", round(delta_time,3)) print('Numero de vertices: ' + str(numvertex)) print('Numero de arcos: ' + str(numedges))
def minimumCostPaths(analyzer, initialStation): """ Calcula todos los caminos de costo minimo de initialStation a todas las otras estaciones del sistema """ delta_time = -1.0 start_time = getTime() respuesta=model.minimumCostPaths(analyzer, initialStation) stop_time = getTime() delta_time = stop_time - start_time return (respuesta,delta_time)
def optionSix(cont, lp): tracemalloc.start() start_time = getTime() start_memory = getMemory() resp = model.minimumCostPaths(cont, lp) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return resp, delta_time, delta_memory
def optionFive(cont, countryA, countryB): tracemalloc.start() start_time = getTime() start_memory = getMemory() countryA = model.getCountry(cont, countryA) countryB = model.getCountry(cont, countryB) resp = model.minimumCostPaths(cont, countryA) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return resp, delta_time, delta_memory
def minimumCostPaths(analyzer, initialStation): """ Calcula todos los caminos de costo minimo de initialStation a todas las otras estaciones del sistema """ delta_time = -1.0 tracemalloc.start() start_time = getTime() sol = model.minimumCostPaths(analyzer, initialStation) stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time return delta_time, sol
def minimumCostPaths(analyzer, initialStation): """ Calcula todos los caminos de costo minimo de initialStation a todas las otras estaciones del sistema """ delta_time = -1.0 delta_memory = -1.0 tracemalloc.start() start_time = getTime() start_memory = getMemory() res = model.minimumCostPaths(analyzer, initialStation) stop_memory = getMemory() stop_time = getTime() tracemalloc.stop() delta_time = stop_time - start_time delta_memory = deltaMemory(start_memory, stop_memory) return res, delta_time, delta_memory
def getminimumCostPaths(analyzer, initialStation): return model.minimumCostPaths(analyzer, initialStation)