33#define DEBUG_COND2(obj) (true)
41 int numDispatched = 0;
44 std::set<MSDevice_Taxi*, MSVehicleDevice::ComparatorNumericalVehicleIdLess> available;
45 for (
auto* taxi : fleet) {
46 if (taxi->isEmpty()) {
47 available.insert(taxi);
53 std::sort(reservations.begin(), reservations.end(),
time_sorter());
55 std::cout <<
SIMTIME <<
" computeDispatch fleet=" << fleet.size() <<
" available=" << available.size() <<
" reservations=" <<
toString(reservations) <<
"\n";
57 for (
auto it = reservations.begin(); it != reservations.end();) {
58 if (available.size() == 0) {
70 bool tooEarly =
false;
71 for (
auto* taxi : available) {
76#ifdef DEBUG_TRAVELTIME
81 if (travelTime < closestTime) {
82 closestTime = travelTime;
93 if (tooEarly || closest ==
nullptr) {
98 numDispatched +=
dispatch(closest, it, router, reservations);
99 available.erase(closest);
103 myHasServableReservations = reservations.size() > 0 && (available.size() < fleet.size() || numPostponed > 0 || numDispatched > 0);
105 std::cout <<
SIMTIME <<
" reservations=" << reservations.size() <<
" avail=" << available.size()
106 <<
" fleet=" << fleet.size() <<
" postponed=" << numPostponed <<
" dispatched=" << numDispatched <<
"\n";
120 resIt = reservations.erase(resIt);
131 bool havePostponed =
false;
132 int numDispatched = 0;
134 std::set<MSDevice_Taxi*, MSVehicleDevice::ComparatorNumericalVehicleIdLess> available;
135 for (
auto* taxi : fleet) {
136 if (taxi->isEmpty()) {
137 available.insert(taxi);
141 std::cout <<
SIMTIME <<
" computeDispatch fleet=" << fleet.size() <<
" available=" << available.size() <<
"\n";
145 std::vector<Reservation*> activeReservations;
147 if (res->recheck <= now) {
148 activeReservations.push_back(res);
151 while (available.size() > 0 && activeReservations.size() > 0) {
157 for (
auto* taxi : available) {
162 SUMOTime taxiWait = res->pickupTime - (now + travelTime);
163#ifdef DEBUG_TRAVELTIME
164 if (
DEBUG_COND2(person)) std::cout <<
SIMTIME <<
" taxi=" << taxi->getHolder().getID() <<
" person=" <<
toString(res->persons)
169 if (travelTime < closestTime) {
171 closestTime = travelTime;
176 <<
" taxiPos=" << taxi->getHolder().getPositionOnLane() <<
" resFromPos=" << res->fromPos <<
" traveltime=" <<
time2string(travelTime) <<
" taxiWait=" <<
time2string(taxiWait) <<
"\n";
179 recheck =
MIN2(recheck,
191 if (closestTaxi !=
nullptr) {
192 auto closeIt = std::find(activeReservations.begin(), activeReservations.end(), closest);
193 numDispatched +=
dispatch(closestTaxi, closeIt, router, activeReservations);
194 available.erase(closestTaxi);
197 havePostponed =
true;
205 <<
" fleet=" << fleet.size() <<
" postponed=" << havePostponed <<
" dispatched=" << numDispatched <<
"\n";
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
@ SVC_TAXI
vehicle is a taxi
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A device which collects info on the vehicle trip (mainly on departure and arrival)
void dispatch(const Reservation &res)
service the given reservation
sorts reservations by time
void computeDispatch(SUMOTime now, const std::vector< MSDevice_Taxi * > &fleet)
computes dispatch and updates reservations
const SUMOTime myRecheckTime
recheck interval for early reservations
virtual void computeDispatch(SUMOTime now, const std::vector< MSDevice_Taxi * > &fleet)
computes dispatch and updates reservations
const int myRoutingMode
which router/edge weights to use
virtual int dispatch(MSDevice_Taxi *taxi, std::vector< Reservation * >::iterator &resIt, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, std::vector< Reservation * > &reservations)
trigger taxi dispatch.
const SUMOTime myRecheckSafety
const SUMOTime myMaximumWaitingTime
maximum time to arrive earlier at customer
int remainingCapacity(const MSDevice_Taxi *taxi, const Reservation *res)
whether the given taxi has sufficient capacity to serve the reservation
static SUMOTime computePickupTime(SUMOTime t, const MSDevice_Taxi *taxi, const Reservation &res, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router)
compute time to pick up the given reservation
bool myHasServableReservations
whether the last call to computeDispatch has left servable reservations
std::vector< Reservation * > getReservations()
retrieve all reservations
void servedReservation(const Reservation *res)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSVehicleRouter & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
static MSVehicleRouter & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the vehicle router instance
SUMOVehicle & getHolder() const
Returns the vehicle that holds this device.
const std::string & getID() const
Returns the id.
std::set< const MSTransportable * > persons