Beispiel #1
0
    def create_epos_output_files(self, sourceID, targetID, tick, agent_ind):

        router_res_length = CustomRouter.route_by_min_length(
            sourceID, targetID)
        if len(router_res_length.route) > 0:
            self.create_output_files(
                history_prefs[self.id]["min_length"], router_res_length.route,
                self.find_occupancy_for_route(router_res_length.meta),
                agent_ind)

        router_res_speeds = CustomRouter.route_by_max_speed(sourceID, targetID)
        if len(router_res_speeds.route) > 0:
            self.create_output_files(
                history_prefs[self.id]["max_speed"], router_res_speeds.route,
                self.find_occupancy_for_route(router_res_speeds.meta),
                agent_ind)

        router_res_length_and_speeds = CustomRouter.minimalRoute(
            sourceID, targetID)
        if len(router_res_length_and_speeds.route) > 0:
            self.create_output_files(
                history_prefs[self.id]["balanced"],
                router_res_length_and_speeds.route,
                self.find_occupancy_for_route(
                    router_res_length_and_speeds.meta), agent_ind)
Beispiel #2
0
    def __createNewRoute(self, tick):
        """ creates a new route to a random target and uploads this route to SUMO """
        if self.targetID is None:
            self.sourceID = Network.get_random_node_id_of_passenger_edge(
                random)
        else:
            self.sourceID = self.targetID  # We start where we stopped
        self.targetID = Network.get_random_node_id_of_passenger_edge(random)
        self.currentRouteID = self.id + "-" + str(self.rounds)

        try:
            if self.driver_preference == "min_length":
                self.currentRouterResult = CustomRouter.route_by_min_length(
                    self.sourceID, self.targetID)
            elif self.driver_preference == "max_speed":
                self.currentRouterResult = CustomRouter.route_by_max_speed(
                    self.sourceID, self.targetID)
            else:
                self.currentRouterResult = CustomRouter.minimalRoute(
                    self.sourceID, self.targetID)

            if len(self.currentRouterResult.route) > 0:
                traci.route.add(self.currentRouteID,
                                self.currentRouterResult.route)
                return self.currentRouteID
            else:
                if Config.debug:
                    print "vehicle " + str(
                        self.id) + " could not be added, retrying"
                return self.__createNewRoute(tick)

        except:
            if Config.debug:
                print "vehicle " + str(
                    self.id) + " could not be added [exception], retrying"
            return self.__createNewRoute(tick)