def doDijkstra(rootObj, start, end): print("in doDijkstra") print("graph: ") #pprint(graph) print("start: " + start) print("end: " + end) #g = graph g = CityParser.getGraphe(rootObj['rootObject']) print("vertices") g.afficherVertices() pprint(g.get_vertex(end)) #print 'Graph data:' #for v in g: # for w in v.get_connections(): # vid = v.get_id() # wid = w.get_id() # print '( %s , %s, %3d)' % ( vid, wid, v.get_weight(w)) dijkstra(g, g.get_vertex(start), g.get_vertex(end)) target = g.get_vertex(end) print("end, target") print(end) print(target) path = [target.get_id()] shortest(target, path) print 'The shortest path : %s' %(path[::-1]) print("in dijktstra:") pprint((path[::-1])) return (path[::-1])
def run(self): global theShortestPath global traitementTaxiEnCours print("in moverrunner run") # on bouge le taxi toutes les x secondes, x etant le poid de l'arrete # le 1er terme est a ignorer car c'est le point actuel print("theShortestPath in the moverunner") print(theShortestPath) pointActuel = unicode( rootObject['cabInfo']['loc_now']['area'] + "." + rootObject['cabInfo']['loc_now']['location'] ) print"pointActuel, theShortestPath[0], pointActuel == theShortestPath[0]" print(pointActuel) print(theShortestPath[0]) print( pointActuel == theShortestPath[0] ) #pointActuel = theShortestPath[0] if pointActuel == theShortestPath[0]: del theShortestPath[0] print("theshortestpath: ") pprint(theShortestPath) coeffSleep = 1 for point in theShortestPath: print("before sleep") print(pointActuel) print(point) poid = CityParser.getPoids(pointActuel, point) sleep(coeffSleep*poid + 1) # go to point print (point.split('.')) print("\".\".join( (point.split('.'))[:-1] ) ") print ( unicode( ".".join( (point.split('.'))[:-1] ) ) ) rootObject['cabInfo']['loc_now']['area'] = unicode( ".".join( (point.split('.'))[:-1] ) ) print("(point.split('.'))[-1] ") print ( (point.split('.'))[-1] ) rootObject['cabInfo']['loc_now']['location'] = unicode( (point.split('.'))[-1] ) rootObject['cabInfo']['odometer'] = float("{:10.2f}".format( rootObject['cabInfo']['odometer'] + poid )) pointActuel = point print("le point " + point + " a ete atteind") #traitementTaxiEnCours = False pass