Ejemplo n.º 1
0
    def calcTripEffort(self):
        trip_time = 0
        trip_effort = 0
        pos = self.getPos()
        for elem in self.__trip_route:
            if Graph.queryTravelCost(pos, elem.getZoneID()) != 0:
                trip_effort = trip_effort + Graph.queryTravelCost(
                    pos, elem.getZoneID())
            else:
                trip_effort += 0.5
            trip_time = trip_time + Graph.queryTravelCost(
                pos, elem.getZoneID())
            elem.setEventTime(Driver.timestamp + trip_time)
            if elem.getEvent() == DROPOFF:
                rider = self.__riders[elem.getRiderID()]
                rider.setArrivalTimestamp(Driver.timestamp + trip_time)
                rider.calcDetourTime(
                    trip_time
                )  #detour time is b/w the rerquest accepted and arrive at destination.
            pos = elem.getZoneID()

        if trip_effort < 0:
            self.__logger.warning(Driver.timestamp, "calcTripEffort",
                                  self.getID(), None,
                                  "Trip effort value is unresonable ")
            raise Exception("Trip effort value is unresonable ")
        else:
            self.__trip_effort += trip_effort
Ejemplo n.º 2
0
    def __init__(self, uID, sT, sZ, dZ, dP, pat, srcX, srcY, destX, destY):
        # logger in Dispatcher
        self.__logger = Logger('Rider')
        #self.__logger.setLevel(logging.DEBUG)
        self.__logger.info(Rider.timestamp, "__INIT__", None, None, "Create A Rider Object")

        self.__id = uID
        self.__request_timestamp = sT
        self.__srcZone = sZ
        self.__destZone = dZ
        self.__default_price = dP
        self.__price = math.inf
        self.__patience = pat
        self.__dirID = self.__assignDirID(srcX, srcY, destX, destY)
        self.__shortest_time = Graph.queryTravelCost(sZ, dZ)
        self.__arrival_timestamp = None
        self.__groupID = None

        self.__status = WAITING
        self.__wait_time = 0
        self.__detour_time = -1
        self.__sat = 0

        if self.__default_price > 100:
            self.__logger.warning(Rider.timestamp, "__INIT__", None, self.getID(), str(self))
 def testQueryTravelCost(self):
     self.assertEqual(1, Graph.queryTravelCost(7, 6))
     self.assertEqual(3, Graph.queryTravelCost(7, 19))
     self.assertEqual(3, Graph.queryTravelCost(8, 30))
     self.assertEqual(1, Graph.queryTravelCost(7, 6))
     self.assertEqual(0, Graph.queryTravelCost(6, 6))