72 bool addVehiclesDirectly) :
75 myActiveContainerPlan(0),
76 myAddVehiclesDirectly(addVehiclesDirectly),
77 myCurrentVTypeDistribution(0),
78 myCurrentRouteDistribution(0),
79 myAmLoadingState(false) {
91 MSTransportable::MSTransportablePlan::iterator i;
190 to = &bs->getLane().getEdge();
195 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, pid.c_str(), ok);
198 throw ProcessError(
"The from edge '" + fromID +
"' within a ride of person '" + pid +
"' is not known.");
208 throw ProcessError(
"The start edge for person '" + pid +
"' is not known.");
211 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, pid.c_str(), ok);
214 throw ProcessError(
"The to edge '" + toID +
"' within a ride of person '" + pid +
"' is not known.");
225 const std::string desc = attrs.
get<std::string>(
SUMO_ATTR_LINES, containerId.c_str(), ok);
238 const std::string fromID = attrs.
get<std::string>(
SUMO_ATTR_FROM, containerId.c_str(), ok);
241 throw ProcessError(
"The from edge '" + fromID +
"' within a transport of container '" + containerId +
"' is not known.");
251 throw ProcessError(
"The start edge within a transport of container '" + containerId +
"' is not known.");
253 const std::string toID = attrs.
get<std::string>(
SUMO_ATTR_TO, containerId.c_str(), ok);
256 throw ProcessError(
"The to edge '" + toID +
"' within a transport of container '" + containerId +
"' is not known.");
287 arrivalPos = cs->getEndLanePosition();
307 const std::string
error =
"No connection found between '" + from->getID() +
"' and '" + to->getID() +
"' for container '" +
myVehicleParameter->
id +
"'.";
356 while (st.hasNext()) {
357 std::string vtypeID = st.next();
442 const std::string
id = vehType->
getID();
445 throw ProcessError(
"Another vehicle type (or distribution) with the id '" +
id +
"' exists.");
470 std::string type =
"vehicle";
471 if (mayBeDisconnected) {
553 std::vector<double> probs;
566 std::string routeID = st.
next();
571 const double prob = ((int)probs.size() > probIndex ? probs[probIndex] : 1.0);
577 if (probs.size() > 0 && probIndex != (int)probs.size()) {
681 for (
int i = 1; i < quota; i++) {
703 throw ProcessError(
"Another vehicle with the id '" + veh_id +
"' exists.");
827 std::string errorSuffix;
898 if (ok && stop.
lane !=
"") {
900 WRITE_ERROR(
"The lane '" + stop.
lane +
"' for a stop is not known" + errorSuffix);
918 WRITE_ERROR(
"A stop must be placed on a busStop, a chargingStation, a containerStop a parkingArea or a lane" + errorSuffix);
943 WRITE_WARNING(
"Deprecated attribute 'pos' in description of stop" + errorSuffix);
949 WRITE_ERROR(
"Invalid start or end position for stop on lane '" + stop.
lane +
"'" + errorSuffix);
982 const std::string description =
"person '" + personID +
"' walking from " + fromEdge->
getID();
985 WRITE_WARNING(
"The attribute departPos is no longer supported for walks, please use the person attribute, the arrivalPos of the previous step or explicit stops.");
1000 throw ProcessError(
"Unknown bus stop '" + bsID +
"' for " + description +
".");
1006 if (arrivalPos < 0) {
1007 throw ProcessError(
"Bus stop '" + bsID +
"' is not connected to arrival edge '" + toEdge->
getID() +
"' for " + description +
".");
1013 arrivalPos = arrPos;
1015 WRITE_WARNING(
"Ignoring arrivalPos for " + description +
" because it is outside the given stop '" +
toString(SUMO_ATTR_BUS_STOP) +
"'.");
1020 throw ProcessError(
"No destination edge for " + description +
".");
1050 if (toID !=
"" && to == 0) {
1053 double departPos = 0;
1054 double arrivalPos = 0;
1068 const std::string mode = st.next();
1069 if (mode ==
"car") {
1071 }
else if (mode ==
"bicycle") {
1073 }
else if (mode ==
"public") {
1080 std::vector<SUMOVehicleParameter*> pars;
1083 pars.back()->vtypeid = st.next();
1098 }
else if ((modeSet &
SVC_BUS) != 0) {
1104 if (attrs.
hasAttribute(SUMO_ATTR_SPEED) && speed <= 0) {
1110 const std::string
error =
"No connection found between '" + from->getID() +
"' and '" + to->getID() +
"' for person '" +
myVehicleParameter->
id +
"'.";
1134 bool carUsed =
false;
1135 std::vector<MSNet::MSIntermodalRouter::TripItem> result;
1136 if (
MSNet::getInstance()->getIntermodalRouter().compute(from, to, departPos, arrivalPos,
1138 for (std::vector<MSNet::MSIntermodalRouter::TripItem>::iterator it = result.begin(); it != result.end(); ++it) {
1139 if (!it->edges.empty()) {
1141 if (it->line ==
"") {
1142 const double depPos =
myActivePlan->back()->getDestinationStop() != 0 ?
myActivePlan->back()->getDestinationStop()->getAccessPos(it->edges.front()) : departPos;
1144 }
else if (vehicle != 0 && it->line == vehicle->getID()) {
1145 double vehicleArrivalPos = bs != 0 ? bs->
getAccessPos(it->edges.back()) : it->edges.back()->getLength();
1146 if (it + 1 == result.end()) {
1147 vehicleArrivalPos = arrivalPos;
1150 vehicle->replaceRouteEdges(it->edges,
true);
1151 vehicle->setArrivalPos(vehicleArrivalPos);
1164 if (vehicle != 0 && !carUsed) {
1190 double departPos = 0;
1191 double arrivalPos = 0;
The departure is person triggered.
void addStop(const SUMOSAXAttributes &attrs)
Processing of a stop.
const int VTYPEPARS_MAXSPEED_SET
const int VEHPARS_TO_TAZ_SET
MSRouteHandler(const std::string &file, bool addVehiclesDirectly)
standard constructor
double getAccessPos(const MSEdge *edge) const
the position on the given edge which is connected to this stop, -1 on failure
int getNumPredecessors() const
Returns the number of edges this edge is connected to.
static StringBijection< SumoXMLTag > CarFollowModels
car following models
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void myEndElement(int element)
Called when a closing tag occurs.
MSEdge & getEdge() const
Returns the lane's edge.
ConstMSEdgeVector myActiveRoute
The current route.
virtual void deleteVehicle(SUMOVehicle *v, bool discard=false)
Deletes the vehicle.
const int VEHPARS_FORCE_REROUTE
double getBeginLanePosition() const
Returns the begin position of this stop.
void parseFromViaTo(std::string element, const SUMOSAXAttributes &attrs)
Called for parsing from and to and the corresponding taz attributes.
description of a vehicle type
RandomDistributor< const MSRoute * > * myCurrentRouteDistribution
The currently parsed distribution of routes (probability->route)
static double _2doubleSec(const E *const data, double def)
converts a 0-terminated char-type array into the double value described by it
std::string containerstop
(Optional) container stop if one is assigned to the stop
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::string vtypeid
The vehicle's type id.
virtual void closeVehicle()
Ends the processing of a vehicle.
void release() const
deletes the route if there are no further references to it
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
a flow definition (used by router)
A lane area vehicles can halt at.
Represents a generic random distribution.
bool myAddVehiclesDirectly
Information whether vehicles shall be directly added to the network or kept within the buffer...
SUMOTime duration
The stopping duration.
SUMOVehicleParameter * myVehicleParameter
Parameter of the current vehicle, trip, person, container or flow.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
double repetitionProbability
The probability for emitting a vehicle per second.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
static bool gStateLoaded
Information whether a state has been loaded.
int parametersSet
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
SUMOVTypeParameter * myCurrentVType
The currently parsed vehicle type.
void closePerson()
Ends the processing of a person.
int repetitionsDone
The number of times the vehicle was already inserted.
int getQuota(double frac=-1) const
Returns the number of instances of the current vehicle that shall be emitted considering that "frac" ...
void openRoute(const SUMOSAXAttributes &attrs)
double myActiveRouteProbability
The probability of the current route.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSPedestrianRouterDijkstra & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
SUMOTime until
The time at which the vehicle may continue its journey.
virtual bool addVehicle(const std::string &id, SUMOVehicle *v)
Tries to insert the vehicle into the internal vehicle container.
std::vector< const MSEdge * > ConstMSEdgeVector
void registerLastDepart()
save last depart (only to be used if vehicle is not discarded)
const double DEFAULT_VEH_PROB
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
void addWalk(const SUMOSAXAttributes &attrs)
add a fully specified walk
const std::string & getID() const
Returns the id.
std::string myActiveRouteID
The id of the current route.
void setCosts(double costs)
Sets the costs of the route.
int myInsertStopEdgesAt
where stop edges can be inserted into the current route (-1 means no insertion)
double getLength() const
return the length of the edge
const MSJunction * getToJunction() const
const std::string DEFAULT_VTYPE_ID
The position is chosen randomly.
void parseWalkPositions(const SUMOSAXAttributes &attrs, const std::string &personID, const MSEdge *fromEdge, const MSEdge *&toEdge, double &departPos, double &arrivalPos, MSStoppingPlace *&bs, const MSTransportable::Stage *const lastStage, bool &ok)
@ brief parse depart- and arrival positions of a walk
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
static MSVehicleType * build(SUMOVTypeParameter &from)
Builds the microsim vehicle type described by the given parameter.
static double parseWalkPos(SumoXMLAttr attr, const std::string &id, double maxPos, const std::string &val, std::mt19937 *rng=0)
parse departPos or arrivalPos for a walk
std::string parkingarea
(Optional) parking area if one is assigned to the stop
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
#define WRITE_WARNING(msg)
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
The car-following model and parameter.
static OptionsCont & getOptions()
Retrieves the options.
std::string toTaz
The vehicle's destination zone (district)
bool wasSet(int what) const
Returns whether the given parameter was set.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
void addPersonTrip(const SUMOSAXAttributes &attrs)
add a routing request for a walking or intermodal person
virtual MSTransportableControl & getContainerControl()
Returns the container control.
double getDefaultProbability() const
Get the default probability of this vehicle type.
std::string busstop
(Optional) bus stop if one is assigned to the stop
A road/street connecting two junctions.
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
double getEndLanePosition() const
Returns the end position of this stop.
RandomDistributor< MSVehicleType * > * myCurrentVTypeDistribution
The currently parsed distribution of vehicle types (probability->vehicle type)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void closeRouteDistribution()
std::string routeid
The vehicle's route id.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Representation of a vehicle.
double startPos
The stopping position start.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
Encapsulated SAX-Attributes.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
std::string chargingStation
(Optional) charging station if one is assigned to the stop
void deleteActivePlans()
delete already created MSTransportablePlans if error occurs before handing over responsibility to a M...
void closeContainer()
Ends the processing of a container.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
void closeVehicleTypeDistribution()
T get(const std::string &str) const
const double DEFAULT_CONTAINER_TRANSHIP_SPEED
SUMOTime depart
The vehicle's departure time.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
double getArrivalPos() const
SUMOTime string2time(const std::string &r)
double getMaxSpeed() const
Get vehicle's maximum speed [m/s].
const int VEHPARS_ROUTE_SET
std::string fromTaz
The vehicle's origin zone (district)
double endPos
The stopping position end.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
vehicle is a passenger car (a "normal" car)
SumoXMLTag myDefaultCFModel
the default car following model
const int VEHPARS_FROM_TAZ_SET
MSTransportable::MSTransportablePlan * myActivePlan
The plan of the current person.
std::string lane
The lane to stop at.
MSVehicleType * getVType(const std::string &id=DEFAULT_VTYPE_ID, std::mt19937 *rng=0)
Returns the named vehicle type or a sample from the named distribution.
Parser for routes during their loading.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
std::string myCurrentRouteDistributionID
The id of the currently parsed route distribution.
std::vector< std::string > getVector()
void openRouteDistribution(const SUMOSAXAttributes &attrs)
virtual void myEndElement(int element)
Called when a closing tag occurs.
double departPos
(optional) The position the vehicle shall depart from
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
static bool checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
std::vector< SUMOVehicleParameter::Stop > myActiveRouteStops
List of the stops on the parsed route.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
Structure representing possible vehicle parameter.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
double compute(const E *from, const E *to, double departPos, double arrivalPos, double speed, SUMOTime msTime, const N *onlyNode, std::vector< const E *> &into, bool allEdges=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
const MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
bool myAmLoadingState
whether a state file is being loaded
static std::mt19937 myParsingRNG
A random number generator used to choose from vtype/route distributions and computing the speed facto...
MSInsertionControl & getInsertionControl()
Returns the insertion control.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
std::string myCurrentVTypeDistributionID
The id of the currently parsed vehicle type distribution.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
Definition of vehicle stop (position and duration)
bool parseStop(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs, std::string errorSuffix, MsgHandler *const errorOutput)
parses attributes common to all stops
const std::string & getID() const
Returns the name of the vehicle type.
void addReference() const
increments the reference counter for the route
double getOverallProb() const
Return the sum of the probabilites assigned to the members.
const MSEdge & getDestination() const
returns the destination edge
bool wasSet(int what) const
Returns whether the given parameter was set.
const int VEHPARS_VTYPE_SET
const RGBColor * myActiveRouteColor
The currently parsed route's color.
double myCurrentCosts
The currently parsed route costs.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
virtual ~MSRouteHandler()
standard destructor
a single trip definition (used by router)
void openVehicleTypeDistribution(const SUMOSAXAttributes &attrs)
The class responsible for building and deletion of vehicles.
virtual SUMOVehicle * buildVehicle(SUMOVehicleParameter *defs, const MSRoute *route, MSVehicleType *type, const bool ignoreStopErrors, const bool fromRouteFile=true)
Builds a vehicle, increases the number of built vehicles.
const MSLane & getLane() const
Returns the lane this stop is located at.
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
void add(SUMOVehicle *veh)
Adds a single vehicle for departure.
bool checkLastDepart()
Checks whether the route file is sorted by departure time if needed.
std::string myActiveRouteRefID
The id of the route the current route references to.
Representation of a lane in the micro simulation.
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
vehicles ignoring classes
void closeRoute(const bool mayBeDisconnected=false)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void closeFlow()
Ends the processing of a flow.
MSTransportable::MSTransportablePlan * myActiveContainerPlan
The plan of the current container.
std::string id
The vehicle's id.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.