50 #ifdef CHECK_MEMORY_LEAKS
52 #endif // CHECK_MEMORY_LEAKS
59 : myVehicleTypes(), myDefaultVTypeMayBeDeleted(true),
60 myRoutesOutput(0), myRouteAlternativesOutput(0), myTypesOutput(0),
61 myReadRouteNo(0), myDiscardedRouteNo(0), myWrittenRouteNo(0),
62 myHaveRestrictions(false),
63 myNumInternalEdges(0) {
105 std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it =
myBusStops.find(
id);
107 WRITE_ERROR(
"The bus stop '" +
id +
"' occurs at least twice.");
121 RONet::openOutput(
const std::string& filename,
const std::string altFilename,
const std::string typeFilename) {
122 if (filename !=
"") {
125 myRoutesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo-sim.org/xsd/routes_file.xsd");
127 if (altFilename !=
"") {
132 if (typeFilename !=
"") {
134 myTypesOutput->
writeXMLHeader(
"routes",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo-sim.org/xsd/routes_file.xsd\"");
169 return it2->second->get();
210 WRITE_ERROR(
"The vehicle type '" + type->
id +
"' occurs at least twice.");
235 WRITE_ERROR(
"The vehicle '" +
id +
"' occurs at least twice.");
256 myPersons.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
265 std::string noRouteMsg =
"The vehicle '" + veh->
getID() +
"' has no valid route.";
278 if (current == 0 || current->
size() == 0) {
284 if (options.
getBool(
"remove-loops")) {
287 if (current->
size() == 0) {
289 mh->
inform(noRouteMsg +
" (after removing loops)");
301 std::vector<std::string> toRemove;
309 if (depart >= time +
DELTA_T) {
327 toRemove.push_back(i->first);
330 for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
346 PersonMap::iterator person =
myPersons.begin();
349 if (vehicleTime > time && personTime > time) {
350 lastTime =
MIN2(vehicleTime, personTime);
353 if (vehicleTime < personTime) {
355 if (lastTime != vehicleTime && lastTime != -1) {
357 if (options.
getInt(
"stats-period") >= 0 && ((
int) vehicleTime % options.
getInt(
"stats-period")) == 0) {
361 lastTime = vehicleTime;
379 (*myRoutesOutput) << person->second;
381 (*myRouteAlternativesOutput) << person->second;
408 const std::map<std::string, ROEdge*>&
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
const std::string & getID() const
Returns the id of the vehicle.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
void close()
Closes the device and removes it from the dictionary.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
EdgeType getType() const
Returns the type of the edge.
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
std::string vtypeid
The vehicle's type id.
int myNumInternalEdges
The number of internal edges in the dictionary.
void clear()
Deletes all vehicles stored; clears the lists.
unsigned int size() const
Returns the number of edges in this route.
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
bool erase(const std::string &id)
Removes the named item from the container.
virtual bool add(const std::string &id, T item)
Adds an item.
Structure representing possible vehicle parameter.
void addAlternative(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const, RORoute *current, SUMOTime begin)
Adds an alternative to the list of routes.
void addNode(RONode *node)
RORoute * buildCurrentRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime begin, const ROVehicle &veh) const
Triggers building of the complete route (via preComputeCurrentRoute) or returns precomputed route...
unsigned int getEdgeNo() const
Returns the number of edges the network contains.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
bool isSaved() const
Returns the information whether this item was already saved.
static SUMOReal rand()
Returns a random real number in [0, 1)
int repetitionsDone
The number of times the vehicle was already inserted.
void recheckForLoops()
Checks whether this route contains loops and removes such.
NamedObjectCont< ROEdge * > myEdges
Known edges.
An internal edge which models driving across a junction. This is currently not used for routing...
unsigned int myDiscardedRouteNo
The number of discarded routes.
A map of named object pointers.
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
OutputDevice * myTypesOutput
The file to write the vehicle types into.
SUMOReal repetitionOffset
The time offset between vehicle reinsertions.
const std::string DEFAULT_VTYPE_ID
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
void saveAllAsXML(OutputDevice &os, OutputDevice *const altos, OutputDevice *const typeos, bool withExitTimes) const
Saves the complete vehicle description.
const std::map< std::string, ROEdge * > & getEdgeMap() const
static OptionsCont & getOptions()
Retrieves the options.
virtual bool add(const std::string &id, ROVehicle *item)
Adds a vehicle to the container.
void openOutput(const std::string &filename, const std::string altFilename, const std::string typeFilename)
Opens the output for computed routes.
T get(const std::string &id) const
Retrieves an item.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
void checkFlows(SUMOTime time)
void clear()
Removes all items from the container (deletes them, too)
bool writeHeader(const SumoXMLTag &rootElement)
const std::string & getID() const
Returns the id.
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
A vehicle as used by router.
void closeOutput()
closes the file output for computed routes
bool addRouteDef(RORouteDef *def)
bool myHaveRestrictions
Whether the network contains edges which not all vehicles may pass.
std::string routeid
The vehicle's route id.
OutputDevice * myRoutesOutput
The file to write the computed routes into.
virtual bool remove(const std::string &id)
Removes an item.
const ROVehicle * getTopVehicle() const
Returns the vehicle that departs most early.
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
SUMOTime depart
The vehicle's departure time.
void addPerson(const SUMOTime depart, const std::string desc)
virtual bool furtherStored()
Returns the information whether further vehicles are stored.
unsigned int size() const
Returns the number of items within the container.
unsigned int getEdgeNoWithoutInternal() const
Returns the number of non-internal edges the network contains.
ROVehicleCont myVehicles
Known vehicles.
unsigned int myReadRouteNo
The number of read routes.
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type was loaded.
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
bool erase(const std::string &id)
Tries to remove (and delete) the named vehicle.
A basic edge for routing applications.
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers) ...
const IDMap & getMyMap() const
Structure representing possible vehicle parameter.
void setRestrictionFound()
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
RORouteDef * copy(const std::string &id) const
Returns a deep copy of the route definition.
Definition of vehicle stop (position and duration)
void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
bool hasRestrictions() const
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Base class for a vehicle's route definition.
std::string id
The vehicle type's id.
void addBusStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
virtual bool addEdge(ROEdge *edge)
std::set< std::string > myVehIDs
Known vehicle ids.
virtual ~RONet()
Destructor.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Base class for nodes used by the router.
NamedObjectCont< RONode * > myNodes
Known nodes.
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime time)
Computes routes described by their definitions and saves them.
#define WRITE_MESSAGE(msg)
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
std::map< std::string, SUMOVehicleParameter::Stop * > myBusStops
Known bus stops.
A complete router's route.
std::string id
The vehicle's id.
bool computeRoute(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const veh)
unsigned int myWrittenRouteNo
The number of written routes.