31#define DEBUG_COND2(obj) (true)
46 const bool isPerson = (*res->
persons.begin())->isPerson();
56 double directTime = -1;
57 double directTime2 = -1;
58 for (
auto it2 = resIt + 1; it2 != reservations.end(); it2++) {
60 const bool isPerson2 = (*res2->
persons.begin())->isPerson();
62 if (capacityLeft < (
int)res2->
persons.size() || isPerson != isPerson2 || !taxi->
compatibleLine(res2)) {
71 const double absLossPickup = detourTime - directTime;
72 const double relLossPickup = absLossPickup / directTime;
76 <<
" absLossPickup=" << absLossPickup
77 <<
" relLossPickup=" << relLossPickup
82 double directTimeTmp = -1;
86 const double absLoss_c1 = absLossPickup + (detourTime2 - directTimeTmp);
87 const double relLoss_c1 = absLoss_c1 / directTime;
92 const double absLoss_c2 = detourTime3 - directTime2;
93 const double relLoss_c2 = absLoss_c2 / directTime2;
98 absLoss = absLossPickup;
99 relLoss = relLossPickup;
100 absLoss2 = absLoss_c2;
101 relLoss2 = relLoss_c2;
105 absLoss = absLoss_c1;
106 relLoss = relLoss_c1;
110 if (shareCase != 0) {
111 reservations.erase(it2);
116 <<
" absLoss_c1=" << absLoss_c1
117 <<
" relLoss_c1=" << relLoss_c1
118 <<
" absLoss_c2=" << absLoss_c2
119 <<
" relLoss_c2=" << relLoss_c2
125 if (shareCase != 0) {
141 <<
" type=" << shareCase
142 <<
" absLoss=" << absLoss <<
" relLoss=" << relLoss
143 <<
" absLoss2=" << absLoss2 <<
" relLoss2=" << relLoss2
151 resIt = reservations.erase(resIt);
152 return shareCase == 0 ? 1 : 2;
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
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
void dispatchShared(std::vector< const Reservation * > reservations)
service the given reservations
bool compatibleLine(const Reservation *res)
whether the given reservation is compatible with the taxi line
const double myRelativeLossThreshold
relative time threshold for declining shared ride
const double myAbsoluteLossThreshold
absolute time threshold for declining shared ride in s
virtual int dispatch(MSDevice_Taxi *taxi, std::vector< Reservation * >::iterator &resIt, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, std::vector< Reservation * > &reservations)
trigger taxi dispatch.
OutputDevice * myOutput
optional file output for dispatch information
int remainingCapacity(const MSDevice_Taxi *taxi, const Reservation *res)
whether the given taxi has sufficient capacity to serve the reservation
static double computeDetourTime(SUMOTime t, SUMOTime viaTime, const MSDevice_Taxi *taxi, const MSEdge *from, double fromPos, const MSEdge *via, double viaPos, const MSEdge *to, double toPos, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, double &timeDirect)
compute directTime and detourTime
void servedReservation(const Reservation *res)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
SUMOVehicle & getHolder() const
Returns the vehicle that holds this device.
const std::string & getID() const
Returns the id.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
std::set< const MSTransportable * > persons