Esempio n. 1
0
    def tryAddCommande(self, plan, commande):
        #Recherche si la station est deja dans la tournee
        station = plan.clients[commande.noeud].stationProche 

        #copie de la tournee pour tester l'ajout
        cpCheminReseau = copy.copy(self.cheminReseau)
        cpCheminStations = copy.deepcopy(self.cheminStations)


        if station in cpCheminReseau :
            #Si la station est dans la tournee, ajout de la commande a la 
            #sous-tournee
            distance = tsp.insertNodeTSP(plan.mDistancesVille, commande.noeud, cpCheminStations[station], self.distance)
        else:
            #Sinon
            #ajout de la station a la tournee
            distance = tsp.insertNodeTSP(plan.mDistancesReseau, station, cpCheminReseau, self.distance)
            #creation de la sous-tournee
            (cpCheminStations[station], d) = tsp.greedyTSP(plan.mDistancesVille, [station, commande.noeud])
            distance += d
        diffDist = distance - self.distance
        poids = self.poids + commande.poids
        volume = self.volume + commande.vol
        """
        print "resultat de l'ajout try"
        print cpCheminReseau
        print pprint(cpCheminStations)
        print pprint(self.cheminStations)
        """
        return (distance, diffDist, poids, volume)
Esempio n. 2
0
 def addCommande(self, plan, commande):
     #Recherche si la station est deja dans la tournee
     station = plan.clients[commande.noeud].stationProche 
     if station in self.cheminReseau :
         #Si la station est dans la tournee, ajout de la commande a la 
         #sous-tournee
         self.distance = tsp.insertNodeTSP(plan.mDistancesVille, commande.noeud, self.cheminStations[station], self.distance)
     else:
         #Sinon
         #ajout de la station a la tournee
         self.distance = tsp.insertNodeTSP(plan.mDistancesReseau, station, self.cheminReseau, self.distance)
         #creation de la sous-tournee
         (self.cheminStations[station], d) = tsp.greedyTSP(plan.mDistancesVille, [station, commande.noeud])
         self.distance += d
     self.poids += commande.poids
     self.volume += commande.vol
Esempio n. 3
0
    stations = (11,41,70,72)
    plan.createClients()
    (longueur, chemin) = plusCourtChemin(grapheVille, 0, 30)

    """
    print "distances"
    for ligne in plan.mDistances:
        print str(ligne).strip('[]')
    """

    print "clients : stations"
    for client in plan.clients:
        print str(plan.clients[client].idClient) + " : " + str(plan.clients[client].stationProche)


    cycle = tsp.greedyTSP(plan.mDistancesVille, [0,2,1,4,5,6,7])
    print "cycle tsp : ",
    print cycle

    max_x = max([n.x for k,n in plan.plan.nodes.iteritems()])
    max_y = max([n.y for k,n in plan.plan.nodes.iteritems()])

    propor_x = (WIDTH - 3 * decalage_w) / max_x
    propor_y = (HEIGHT - 3 * decalage_h) / max_y

    effacer(plan)
    while 1 :
        pygame.display.update()
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit(); sys.exit();