32#define DEBUG_COND2(obj) (true)
51 myReservationCount(0) {
52 const std::string opt =
"device.taxi.dispatch-algorithm.output";
73 const MSEdge* from,
double fromPos,
74 const MSEdge* to,
double toPos,
76 const std::string& line,
78 int maxContainerCapacity) {
83 group = person->
getID();
91 if (res->persons.count(person) == 0
94 && res->fromPos == fromPos
95 && res->toPos == toPos) {
96 if (res->persons.size() > 0 && (*res->persons.begin())->isPerson() != person->
isPerson()) {
97 WRITE_WARNINGF(
TL(
"Mixing reservations of persons and containers with the same group is not supported for % and %"),
98 (*res->persons.begin())->getID(), person->
getID());
100 if ((person->
isPerson() && (
int)res->persons.size() >= maxCapacity) ||
101 (!person->
isPerson() && (
int)res->persons.size() >= maxContainerCapacity)) {
105 res->persons.insert(person);
118#ifdef DEBUG_RESERVATION
120 <<
" addReservation p=" << person->
getID()
123 <<
" from=" << from->
getID() <<
" fromPos=" << fromPos
124 <<
" to=" << to->
getID() <<
" toPos=" << toPos
125 <<
" group=" << group
126 <<
" added=" << added
135 const MSEdge* from,
double fromPos,
136 const MSEdge* to,
double toPos,
141 group = person->
getID();
143 std::string removedID =
"";
147 for (
auto itRes = it->second.begin(); itRes != it->second.end(); itRes++) {
149 if (res->
persons.count(person) != 0
153 && res->
toPos == toPos) {
158 it->second.erase(itRes);
164#ifdef DEBUG_RESERVATION
166 <<
" removeReservation p=" << person->
getID()
167 <<
" from=" << from->
getID() <<
" fromPos=" << fromPos
168 <<
" to=" << to->
getID() <<
" toPos=" << toPos
169 <<
" group=" << group
170 <<
" removedID=" << removedID
177std::vector<Reservation*>
179 std::vector<Reservation*> reservations;
181 reservations.insert(reservations.end(), it.second.begin(), it.second.end());
187std::vector<const Reservation*>
202 auto it2 = std::find(it->second.begin(), it->second.end(), res);
203 if (it2 == it->second.end()) {
208 it->second.erase(it2);
209 if (it->second.empty()) {
233 const MSEdge* from,
double fromPos,
234 const MSEdge* via,
double viaPos,
235 const MSEdge* to,
double toPos,
237 double& timeDirect) {
239 if (timeDirect < 0) {
240 router.
compute(from, fromPos, to, toPos, &taxi->
getHolder(), t, edges,
true);
245 router.
compute(from, fromPos, via, viaPos, &taxi->
getHolder(), t, edges,
true);
249 std::cout <<
" leg1=" <<
toString(edges) <<
" startPos=" << fromPos <<
" toPos=" << viaPos <<
" time=" << leg1 <<
"\n";
251 const double wait =
MAX2(0.0,
STEPS2TIME(viaTime) - (start + leg1));
254 router.
compute(via, viaPos, to, toPos, &taxi->
getHolder(), timeContinue, edges,
true);
256 const double timeDetour = leg1 + wait + leg2;
258 std::cout <<
" leg2=" <<
toString(edges) <<
" startPos=" << viaPos <<
" toPos=" << toPos <<
" time=" << leg2 <<
"\n";
260 <<
" from=" << from->
getID() <<
" to=" << to->
getID() <<
" via=" << via->
getID()
261 <<
" direct=" << timeDirect <<
" detour=" << timeDetour <<
" wait=" << wait <<
"\n";
269 assert(res->
persons.size() > 0);
270 return ((*res->
persons.begin())->isPerson()
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
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)
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 SUMOTime computePickupTime(SUMOTime t, const MSDevice_Taxi *taxi, const Reservation &res, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router)
compute time to pick up the given reservation
virtual std::string removeReservation(MSTransportable *person, const MSEdge *from, double fromPos, const MSEdge *to, double toPos, std::string group)
remove person from reservation. If the whole reservation is removed, return it's id
bool myHasServableReservations
whether the last call to computeDispatch has left servable reservations
std::map< std::string, std::vector< Reservation * > > myGroupReservations
std::vector< Reservation * > getReservations()
retrieve all reservations
virtual std::vector< const Reservation * > getRunningReservations()
retrieve all reservations that were already dispatched and are still active
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
virtual Reservation * addReservation(MSTransportable *person, SUMOTime reservationTime, SUMOTime pickupTime, const MSEdge *from, double fromPos, const MSEdge *to, double toPos, std::string group, const std::string &line, int maxCapacity, int maxContainerCapacity)
add a new reservation
virtual void fulfilledReservation(const Reservation *res)
erase reservation from storage
MSDispatch(const Parameterised::Map ¶ms)
Constructor;.
void servedReservation(const Reservation *res)
std::set< const Reservation * > myRunningReservations
virtual ~MSDispatch()
Destructor.
A road/street connecting two junctions.
bool isPerson() const
Whether it is a person.
SUMOVehicle & getHolder() const
Returns the vehicle that holds this device.
int getPersonCapacity() const
Get this vehicle type's person capacity.
int getContainerCapacity() const
Get this vehicle type's container capacity.
const std::string & getID() const
Returns the id.
static OptionsCont & getOptions()
Retrieves the options.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
An upper class for objects with additional parameters.
std::map< std::string, std::string > Map
parameters map
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 double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
double recomputeCostsPos(const std::vector< const E * > &edges, const V *const v, double fromPos, double toPos, SUMOTime msTime, double *lengthp=nullptr) const
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
std::string getID() const
debug identification
std::set< MSTransportable * > persons