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),
64 myErrorHandler(
OptionsCont::getOptions().exists(
"ignore-errors")
106 std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it =
myBusStops.find(
id);
108 WRITE_ERROR(
"The bus stop '" +
id +
"' occurs at least twice.");
122 RONet::openOutput(
const std::string& filename,
const std::string altFilename,
const std::string typeFilename) {
123 if (filename !=
"") {
126 myRoutesOutput->
writeAttr(
"xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance").
writeAttr(
"xsi:noNamespaceSchemaLocation",
"http://sumo.dlr.de/xsd/routes_file.xsd");
128 if (altFilename !=
"") {
133 if (typeFilename !=
"") {
135 myTypesOutput->
writeXMLHeader(
"routes",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/routes_file.xsd\"");
156 if (myThreadPool.size() > 0) {
157 myThreadPool.clear();
178 return it2->second->get();
213 WRITE_ERROR(
"The vehicle type '" + type->
id +
"' occurs at least twice.");
238 WRITE_ERROR(
"The vehicle '" +
id +
"' occurs at least twice.");
259 myPersons.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
265 const ROVehicle*
const veh,
const bool removeLoops,
267 std::string noRouteMsg =
"The vehicle '" + veh->
getID() +
"' has no valid route.";
271 errorHandler->
inform(noRouteMsg);
275 if (current == 0 || current->
size() == 0) {
277 errorHandler->
inform(noRouteMsg);
284 if (current->
size() == 0) {
286 errorHandler->
inform(noRouteMsg +
" (after removing loops)");
298 std::vector<std::string> toRemove;
302 while (pars->
depart < time) {
304 toRemove.push_back(i->first);
329 if (depart >= time +
DELTA_T) {
347 toRemove.push_back(i->first);
351 for (std::vector<std::string>::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) {
362 const bool removeLoops = options.
getBool(
"remove-loops");
364 const int maxNumThreads = options.
getInt(
"routing-threads");
368 for (std::map<std::string, ROVehicle*>::const_iterator i = mmap.begin(); i != mmap.end(); ++i) {
369 if (i->second->getDepart() >= time) {
373 i->second->setRoutingSuccess(
false);
376 const int numThreads = (int)myThreadPool.size();
377 if (numThreads < maxNumThreads && myThreadPool.isFull()) {
378 new WorkerThread(myThreadPool, numThreads == 0 ? &router : router.
clone());
381 if (maxNumThreads > 0) {
382 myThreadPool.add(
new RoutingTask(i->second, removeLoops,
myErrorHandler));
389 myThreadPool.waitAll();
397 PersonMap::iterator person =
myPersons.begin();
400 if (vehicleTime >= time && personTime >= time) {
401 lastTime =
MIN2(vehicleTime, personTime);
404 if (vehicleTime < personTime) {
406 if (lastTime != vehicleTime && lastTime != -1) {
408 if (options.
getInt(
"stats-period") >= 0 && ((int) vehicleTime % options.
getInt(
"stats-period")) == 0) {
412 lastTime = vehicleTime;
459 const std::map<std::string, ROEdge*>&
483 myVehicle->setRoutingSuccess(
RONet::computeRoute(static_cast<WorkerThread*>(context)->getRouter(), myVehicle, myRemoveLoops, myErrorHandler));
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
const std::string & getID() const
Returns the id of the vehicle.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
SUMOReal repetitionProbability
The probability for emitting a vehicle per second.
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.
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.
size_t getEdgeNo() const
Returns the total number of edges the network contains including internal edges.
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...
virtual SUMOAbstractRouter * clone() const =0
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed ...
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.
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
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
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.
bool getRoutingSuccess() const
A vehicle as used by router.
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) ...
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
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)
static bool computeRoute(SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const veh, const bool removeLoops, MsgHandler *errorHandler)
std::set< std::string > myVehIDs
Known vehicle ids.
virtual ~RONet()
Destructor.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
A thread repeatingly calculating incoming tasks.
MsgHandler * myErrorHandler
handler for ignorable error messages
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)
void cleanup(SUMOAbstractRouter< ROEdge, ROVehicle > *router)
closes the file output for computed routes and deletes routers and associated threads if necessary ...
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
vehicles ignoring classes
std::map< std::string, SUMOVehicleParameter::Stop * > myBusStops
Known bus stops.
A complete router's route.
std::string id
The vehicle's id.
unsigned int myWrittenRouteNo
The number of written routes.