60 #define TAXI_SERVICE "taxi"
74 oc.
addDescription(
"device.taxi.dispatch-algorithm",
"Taxi Device",
"The dispatch algorithm [greedy|greedyClosest|greedyShared|routeExtension|traci]");
77 oc.
addDescription(
"device.taxi.dispatch-algorithm.output",
"Taxi Device",
"Write information from the dispatch algorithm to FILE");
80 oc.
addDescription(
"device.taxi.dispatch-algorithm.params",
"Taxi Device",
"Load dispatch algorithm parameters in format KEY1:VALUE1[,KEY2:VALUE]");
83 oc.
addDescription(
"device.taxi.dispatch-period",
"Taxi Device",
"The period between successive calls to the dispatcher");
86 oc.
addDescription(
"device.taxi.idle-algorithm",
"Taxi Device",
"The behavior of idle taxis [stop|randomCircling]");
89 oc.
addDescription(
"device.taxi.idle-algorithm.output",
"Taxi Device",
"Write information from the idling algorithm to FILE");
98 WRITE_WARNING(
"Mesoscopic simulation does not support the taxi device yet.");
103 into.push_back(device);
115 if (personCapacity < 1) {
126 std::string algo = oc.
getString(
"device.taxi.dispatch-algorithm");
129 if (algo ==
"greedy") {
131 }
else if (algo ==
"greedyClosest") {
133 }
else if (algo ==
"greedyShared") {
135 }
else if (algo ==
"routeExtension") {
137 }
else if (algo ==
"traci") {
140 throw ProcessError(
"Dispatch algorithm '" + algo +
"' is not known");
152 const std::set<std::string>& lines,
155 const MSEdge* from,
double fromPos,
156 const MSEdge* to,
double toPos,
157 const std::string& group) {
158 if (lines.size() == 1 && *lines.begin() ==
TAXI_SERVICE) {
169 std::vector<MSDevice_Taxi*> active;
171 if (taxi->getHolder().hasDeparted()) {
172 active.push_back(taxi);
198 std::string defaultServiceEnd =
toString(1e15);
200 if (algo ==
"stop") {
202 }
else if (algo ==
"randomCircling") {
229 return &
myFleet[0]->getHolder();
244 #ifdef DEBUG_DISPATCH
248 std::cout <<
" persons=" <<
toString(res->persons) <<
"\n";
256 std::vector<SUMOVehicleParameter::Stop> stops;
259 bool isPickup =
false;
267 prepareStop(tmpEdges, stops, lastPos, res->from, res->fromPos,
"pickup " +
toString(res->persons));
270 stops.back().triggered =
true;
272 stops.back().containerTriggered =
true;
277 prepareStop(tmpEdges, stops, lastPos, res->to, res->toPos,
"dropOff " +
toString(res->persons));
293 throw ProcessError(
"Dispatch for busy taxis not yet implemented");
301 std::vector<SUMOVehicleParameter::Stop>& stops,
302 double& lastPos,
const MSEdge* stopEdge,
double stopPos,
303 const std::string& action) {
304 assert(!edges.empty());
305 if (stopEdge == edges.back() && !stops.empty()) {
306 if (stopPos >= lastPos && stopPos <= stops.back().endPos) {
316 if (stopEdge != edges.back() || stopPos < lastPos) {
317 edges.push_back(stopEdge);
327 stops.push_back(stop);
334 if (allowedLanes ==
nullptr) {
337 return allowedLanes->front();
354 double newPos,
double ) {
406 WRITE_WARNINGF(
"All customers left vehicle '%' at time % but there are % remaining stops",
408 while (veh->
getStops().size() > 1) {
418 for (
const auto& stop : veh->
getStops()) {
431 if (tripinfoOut !=
nullptr) {
442 if (key ==
"customers") {
444 }
else if (key ==
"occupiedDistance") {
446 }
else if (key ==
"occupiedTime") {
448 }
else if (key ==
"state") {
std::vector< const MSEdge * > ConstMSEdgeVector
#define WRITE_WARNINGF(...)
#define WRITE_WARNING(msg)
std::string time2string(SUMOTime t)
convert SUMOTime to string
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
@ SVC_TAXI
vehicle is a taxi
@ DEPART_GIVEN
The time is given.
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Base (microsim) event class.
const std::list< MSStop > & getStops() const
bool abortNextStop(int nextStopIndex=0)
deletes the next stop at the given index if it exists
A device which collects info on the vehicle trip (mainly on departure and arrival)
static void initDispatch()
initialize the dispatch algorithm
static Command * myDispatchCommand
The repeated call to the dispatcher.
void customerArrived(const MSTransportable *person)
called by MSDevice_Transportable upon unloading a person
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves arrival info.
static SUMOTime triggerDispatch(SUMOTime currentTime)
period command to trigger the dispatch algorithm
MSLane * getStopLane(const MSEdge *edge)
determine stopping lane for taxi
void dispatch(const Reservation &res)
service the given reservation
void dispatchShared(const std::vector< const Reservation * > &reservations)
service the given reservations
std::set< const MSTransportable * > myCustomers
the customer of the current reservation
SUMOTime myServiceEnd
the time at which the taxi service ends (end the vehicle may leave the simulation)
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
MSIdling * myIdleAlgorithm
algorithm for controlling idle behavior
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks for waiting steps when the vehicle moves.
bool hasFuturePickup()
whether the taxi has another pickup scheduled
bool allowsBoarding(MSTransportable *t) const
whether the given person is allowed to board this taxi
static MSDispatch * myDispatcher
the dispatch algorithm
int myCustomersServed
number of customers that were served
bool isEmpty()
whether the taxi is empty
const std::string deviceName() const
return the name for this type of device
static std::vector< MSDevice_Taxi * > myFleet
static SUMOTime myDispatchPeriod
the time between successive calls to the dispatcher
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Saves departure info on insertion.
static void cleanup()
resets counters
double myOccupiedDistance
distance driven with customers
MSDevice_Taxi(SUMOVehicle &holder, const std::string &id)
Constructor.
static void addReservation(MSTransportable *person, const std::set< std::string > &lines, SUMOTime reservationTime, SUMOTime pickupTime, const MSEdge *from, double fromPos, const MSEdge *to, double toPos, const std::string &group)
add new reservation
static bool hasServableReservations()
check whether there are still (servable) reservations in the system
void prepareStop(ConstMSEdgeVector &edges, std::vector< SUMOVehicleParameter::Stop > &stops, double &lastPos, const MSEdge *stopEdge, double stopPos, const std::string &action)
prepare stop for the given action
static SUMOVehicle * getTaxi()
returns a taxi if any exist or nullptr
void customerEntered(const MSTransportable *t)
called by MSDevice_Transportable upon loading a person
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Taxi-options.
bool myIsStopped
whether the vehicle is currently stopped
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
SUMOTime myOccupiedTime
time spent driving with customers
~MSDevice_Taxi()
Destructor.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
static std::string getStringParam(const SUMOVehicle &v, const OptionsCont &oc, std::string paramName, std::string deflt, bool required)
A dispatch algorithm that services the reservations with the shortest traveltime-to-pickup first.
A dispatch algorithm that services customers in reservation order and always sends the closest availa...
A dispatch algorithm that services customers in reservation order and always sends the closest availa...
An algorithm that performs distpach for a taxi fleet.
virtual Reservation * addReservation(MSTransportable *person, SUMOTime reservationTime, SUMOTime pickupTime, const MSEdge *from, double fromPos, const MSEdge *to, double toPos, const std::string &group, int maxCapacity)
add a new reservation
bool hasServableReservations()
check whether there are still (servable) reservations in the system
virtual void computeDispatch(SUMOTime now, const std::vector< MSDevice_Taxi * > &fleet)=0
computes dispatch and updates reservations
A road/street connecting two junctions.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
double getLength() const
return the length of the edge
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
virtual void idle(MSDevice_Taxi *taxi)=0
computes Idling and updates reservations
Representation of a lane in the micro simulation.
Notification
Definition of a vehicle state.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the router instance
SUMOTime endBoarding
the maximum time at which persons may board this vehicle
bool isPerson() const
Whether it is a person.
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
int getPersonCapacity() const
Get this vehicle type's person capacity.
double getLength() const
Get vehicle's length [m].
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
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.
An upper class for objects with additional parameters.
void setParametersStr(const std::string ¶msString, const std::string kvsep="=", const std::string sep="|")
set the inner key/value map in string format "key1=value1|key2=value2|...|keyN=valueN"
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
Representation of a vehicle, person, or container.
virtual bool isStopped() const =0
Returns whether the object is at a stop.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
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.
Representation of a vehicle.
virtual void reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false)=0
Performs a rerouting using the given router.
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, ConstMSEdgeVector::const_iterator *searchStart=0)=0
Adds a stop.
virtual int getRNGIndex() const =0
virtual int getPersonNumber() const =0
Returns the number of persons.
virtual int getContainerNumber() const =0
Returns the number of containers.
virtual bool replaceRouteEdges(ConstMSEdgeVector &edges, double cost, double savings, const std::string &info, bool onInit=false, bool check=false, bool removeStops=true)=0
Replaces the current route by the given edges.
virtual bool abortNextStop(int nextStopIndex=0)=0
deletes the next stop at the given index if it exists
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
int index
at which position in the stops list
std::string actType
act Type (only used by Persons) (used by NETEDIT)
double endPos
The stopping position end.
bool parking
whether the vehicle is removed from the net while stopping
Structure representing possible vehicle parameter.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string line
The vehicle's line (mainly for public transport)
A wrapper for a Command function.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.