31 #define DEBUG_COND2(obj) (true)
40 const MSEdge* newEdge,
const double newPos)
const {
41 for (
const MSEdge* edge : route) {
42 while (edgeIt != edgeEnd && edge == edgeIt->first) {
43 if (edge == newEdge && edgeIt->second > newPos) {
49 if (edge == newEdge) {
65 const bool isPerson = (*res->
persons.begin())->isPerson();
67 std::vector<const Reservation*> sequence{ res, res };
68 std::vector<const Reservation*> toRemove{ res };
75 for (
auto it2 = resIt + 1; it2 != reservations.end();) {
77 const bool isPerson2 = (*res2->
persons.begin())->isPerson();
78 if (capacityLeft < (
int)res2->
persons.size() || isPerson != isPerson2 || !taxi->
compatibleLine(res2)) {
86 const bool pickup = std::find(route.begin(), route.end(), res2->
from) != route.end();
87 const bool dropoff = std::find(route.begin(), route.end(), res2->
to) != route.end();
90 <<
" pickup=" << pickup <<
" startFirst=" << (std::find(route2.begin(), route2.end(), first->from) != route2.end())
91 <<
" dropoff=" << dropoff <<
" endLast=" << (std::find(route2.begin(), route2.end(), last->
to) != route2.end())
94 if ((pickup || std::find(route2.begin(), route2.end(), first->from) != route2.end()) &&
95 (dropoff || std::find(route2.begin(), route2.end(), last->
to) != route2.end())) {
96 std::vector<const Reservation*>::iterator resSeqIt = sequence.begin();
97 EdgePosVector::iterator edgeIt = posSequence.begin();
102 resSeqIt = sequence.insert(resSeqIt, res2) + 1;
103 edgeIt = posSequence.insert(edgeIt, std::make_pair(res2->
from, res2->
fromPos)) + 1;
107 sequence.insert(resSeqIt, res2);
108 posSequence.insert(edgeIt, std::make_pair(res2->
from, res2->
fromPos));
111 sequence.push_back(res2);
112 posSequence.push_back(std::make_pair(res2->
to, res2->
toPos));
114 toRemove.push_back(res2);
115 it2 = reservations.erase(it2);
117 capacityLeft -= (int)res2->
persons.size();
118 if (capacityLeft == 0) {
122 first = sequence.front();
123 last = sequence.back();
130 if (sequence.size() > 2) {
142 #ifdef DEBUG_DISPATCH
152 resIt = reservations.erase(resIt);
153 return (
int)toRemove.size();
std::vector< const MSEdge * > ConstMSEdgeVector
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
void findInsertionPoint(std::vector< const Reservation * >::iterator &resIt, EdgePosVector::iterator &edgeIt, const EdgePosVector::iterator &edgeEnd, ConstMSEdgeVector &route, const MSEdge *newEdge, const double newPos) const
virtual int dispatch(MSDevice_Taxi *taxi, std::vector< Reservation * >::iterator &resIt, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, std::vector< Reservation * > &reservations)
trigger taxi dispatch.
std::vector< std::pair< const MSEdge *, double > > EdgePosVector
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
void servedReservation(const Reservation *res)
A road/street connecting two junctions.
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 & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
std::set< const MSTransportable * > persons