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) {
66 std::vector<const Reservation*> sequence{ res, res };
67 std::vector<const Reservation*> toRemove{ res };
74 for (
auto it2 = resIt + 1; it2 != reservations.end();) {
76 if (capacityLeft < (
int)res2->
persons.size()) {
84 const bool pickup = std::find(route.begin(), route.end(), res2->
from) != route.end();
85 const bool dropoff = std::find(route.begin(), route.end(), res2->
to) != route.end();
88 <<
" pickup=" << pickup <<
" startFirst=" << (std::find(route2.begin(), route2.end(), first->from) != route2.end())
89 <<
" dropoff=" << dropoff <<
" endLast=" << (std::find(route2.begin(), route2.end(), last->
to) != route2.end())
92 if ((pickup || std::find(route2.begin(), route2.end(), first->from) != route2.end()) &&
93 (dropoff || std::find(route2.begin(), route2.end(), last->
to) != route2.end())) {
94 std::vector<const Reservation*>::iterator resSeqIt = sequence.begin();
95 EdgePosVector::iterator edgeIt = posSequence.begin();
100 resSeqIt = sequence.insert(resSeqIt, res2) + 1;
101 edgeIt = posSequence.insert(edgeIt, std::make_pair(res2->
from, res2->
fromPos)) + 1;
105 sequence.insert(resSeqIt, res2);
106 posSequence.insert(edgeIt, std::make_pair(res2->
from, res2->
fromPos));
109 sequence.push_back(res2);
110 posSequence.push_back(std::make_pair(res2->
to, res2->
toPos));
112 toRemove.push_back(res2);
113 it2 = reservations.erase(it2);
115 capacityLeft -= (int)res2->
persons.size();
116 if (capacityLeft == 0) {
120 first = sequence.front();
121 last = sequence.back();
128 if (sequence.size() > 2) {
140 #ifdef DEBUG_DISPATCH
150 resIt = reservations.erase(resIt);
151 return (
int)toRemove.size();
std::vector< const MSEdge * > ConstMSEdgeVector
std::string time2string(SUMOTime t)
convert SUMOTime to string
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(const std::vector< const Reservation * > &reservations)
service the given reservations
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
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.
int getPersonCapacity() const
Get this vehicle type's person capacity.
const std::string & getID() const
Returns the id.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
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.
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...
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
std::set< MSTransportable * > persons