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) {
106 RONet::openOutput(
const std::string& filename,
const std::string altFilename,
const std::string typeFilename) {
107 if (filename !=
"") {
110 myRoutesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.sf.net/xsd/routes_file.xsd");
112 if (altFilename !=
"") {
117 if (typeFilename !=
"") {
119 myTypesOutput->
writeXMLHeader(
"routes",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.sf.net/xsd/routes_file.xsd\"");
154 return it2->second->get();
195 WRITE_ERROR(
"The vehicle type '" + type->
id +
"' occurs at least twice.");
220 WRITE_ERROR(
"The vehicle '" +
id +
"' occurs at least twice.");
241 myPersons.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
250 std::string noRouteMsg =
"The vehicle '" + veh->
getID() +
"' has no valid route.";
263 if (current == 0 || current->
size() == 0) {
269 if (options.
getBool(
"remove-loops")) {
272 if (current->
size() == 0) {
274 mh->
inform(noRouteMsg +
" (after removing loops)");
286 std::vector<std::string> toRemove;
294 if (depart >= time +
DELTA_T) {
312 toRemove.push_back(i->first);
315 for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
331 PersonMap::iterator person =
myPersons.begin();
334 if (vehicleTime > time && personTime > time) {
335 lastTime =
MIN2(vehicleTime, personTime);
338 if (vehicleTime < personTime) {
340 if (lastTime != vehicleTime && lastTime != -1) {
342 if (options.
getInt(
"stats-period") >= 0 && ((
int) vehicleTime % options.
getInt(
"stats-period")) == 0) {
346 lastTime = vehicleTime;
364 (*myRoutesOutput) << person->second;
366 (*myRouteAlternativesOutput) << person->second;
387 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.
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.
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 thenetwork 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.
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.
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.
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.
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.
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.