Exemplo n.º 1
0
    def step(self) -> List[Itinerary]:
        bookings = self.booking_service.get_pending_bookings()
        vehicles = self.get_idling_vehicles()

        itineraries = []
        for booking in bookings:
            if not vehicles:
                break

            vehicle = np.random.choice(vehicles)
            vehicles.remove(vehicle)

            itinerary = basic_booking_itinerary(self.clock.now, vehicle, booking)
            itineraries.append(itinerary)

        return itineraries
Exemplo n.º 2
0
    def step(self) -> List[Itinerary]:
        # bookings in descending order
        bookings = self.booking_service.get_pending_bookings()
        vehicles = self.get_idling_vehicles()

        itineraries = []
        # FIFO
        for booking in bookings:
            if vehicles:
                vehicle, eta = self.closest_vehicle(booking, vehicles)
                if eta > self.search_radius:
                    continue

                vehicles.remove(vehicle)

                itinerary = basic_booking_itinerary(self.clock.now, vehicle, booking)
                itineraries.append(itinerary)

        return itineraries
Exemplo n.º 3
0
    def step(self):
        taxies = self.find_idling_taxies()
        if self.bookings_queue and taxies:
            # first come, first servce (FIFO)
            booking = self.bookings_queue.pop(0)

            candidates = self.taxi_drivers.find_candidate_taxies(booking, taxies)

            self.locked_bookings.append(booking)

            for taxi in candidates:
                self.taxi_drivers.add_request(taxi, booking)

        accepted = self.taxi_drivers.get_accepted_requests()

        for (taxi, booking) in accepted:
            itinerary = basic_booking_itinerary(self.clock.now, taxi, booking)
            self.dispatcher.dispatch(itinerary)

            self.locked_bookings.remove(booking)