SUMO - Simulation of Urban MObility
RONet.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The router's network representation
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
13 // Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef RONet_h
24 #define RONet_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include "ROEdge.h"
38 #include "RONode.h"
39 #include "ROVehicleCont.h"
40 #include "ROVehicle.h"
41 #include "RORouteDef.h"
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
50 class RONode;
51 class RORouteDef;
52 class OptionsCont;
53 class OutputDevice;
54 
55 
56 // ===========================================================================
57 // class definitions
58 // ===========================================================================
67 class RONet {
68  friend class RouteAggregator;
69 
70 public:
72  RONet();
73 
74 
76  virtual ~RONet();
77 
78 
80 
81 
82  /* @brief Adds a read edge to the network
83  *
84  * If the edge is already known (another one with the same id exists),
85  * an error is generated and given to msg-error-handler. The edge
86  * is deleted in this case and false is returned.
87  *
88  * @param[in] edge The edge to add
89  * @return Whether the edge was added (if not, it was deleted, too)
90  */
91  virtual bool addEdge(ROEdge* edge);
92 
93 
102  ROEdge* getEdge(const std::string& name) const {
103  return myEdges.get(name);
104  }
105 
106 
107  /* @brief Adds a read node to the network
108  *
109  * If the node is already known (another one with the same id exists),
110  * an error is generated and given to msg-error-handler. The node
111  * is deleted in this case
112  *
113  * @param[in] node The node to add
114  */
115  void addNode(RONode* node);
116 
117 
124  RONode* getNode(const std::string& id) const {
125  return myNodes.get(id);
126  }
127 
128 
129  /* @brief Adds a read bus stop to the network
130  *
131  * If the bus stop is already known (another one with the same id exists),
132  * an error is generated and given to msg-error-handler. The stop
133  * is deleted in this case
134  *
135  * @param[in] node The stop to add
136  */
137  void addBusStop(const std::string& id, SUMOVehicleParameter::Stop* stop);
138 
139 
145  const SUMOVehicleParameter::Stop* getBusStop(const std::string& id) const {
146  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myBusStops.find(id);
147  if (it == myBusStops.end()) {
148  return 0;
149  }
150  return it->second;
151  }
153 
154 
155 
157 
158 
165  bool checkVType(const std::string& id);
166 
167 
177  virtual bool addVehicleType(SUMOVTypeParameter* type);
178 
179 
193  bool addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution);
194 
195 
208  SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id);
209 
210 
211  /* @brief Adds a route definition to the network
212  *
213  * If the route definition is already known (another one with
214  * the same id exists), false is returned, but the route definition
215  * is not deleted.
216  *
217  * @param[in] def The route definition to add
218  * @return Whether the route definition could be added
219  * @todo Rename myRoutes to myRouteDefinitions
220  */
221  bool addRouteDef(RORouteDef* def);
222 
223 
231  RORouteDef* getRouteDef(const std::string& name) const {
232  return myRoutes.get(name);
233  }
234 
235 
236  /* @brief Adds a vehicle to the network
237  *
238  * If the vehicle is already known (another one with the same id
239  * exists), false is returned, but the vehicle is not deleted.
240  *
241  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
242  *
243  * @param[in] id The id of the vehicle to add
244  * @param[in] veh The vehicle to add
245  * @return Whether the vehicle could be added
246  */
247  virtual bool addVehicle(const std::string& id, ROVehicle* veh);
248 
249 
250  /* @brief Adds a flow of vehicles to the network
251  *
252  * If the flow is already known (another one with the same id
253  * exists), false is returned, but the vehicle parameter are not deleted.
254  *
255  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
256  *
257  * @param[in] flow The parameter of the flow to add
258  * @return Whether the flow could be added
259  */
260  bool addFlow(SUMOVehicleParameter* flow, const bool randomize);
261 
262 
263  /* @brief Adds a person to the network
264  *
265  * @param[in] depart The departure time of the person
266  * @param[in] desc The xml description of the person
267  */
268  void addPerson(const SUMOTime depart, const std::string desc);
269  // @}
270 
271 
273 
274 
288 
289 
291  virtual bool furtherStored();
293 
294 
295 
296 
297 
308  void openOutput(const std::string& filename, const std::string altFilename, const std::string typeFilename);
309 
310 
312  void closeOutput();
313 
314 
316  unsigned int getEdgeNo() const;
317 
319  unsigned int getEdgeNoWithoutInternal() const;
320 
321  const std::map<std::string, ROEdge*>& getEdgeMap() const;
322 
323  bool hasRestrictions() const;
324 
325  void setRestrictionFound();
326 
327  OutputDevice* getRouteOutput(const bool alternative = false) {
328  if (alternative) {
330  }
331  return myRoutesOutput;
332  }
333 
334 protected:
335  bool computeRoute(OptionsCont& options,
336  SUMOAbstractRouter<ROEdge, ROVehicle>& router, const ROVehicle* const veh);
337 
340  return myVehicles;
341  }
342 
343 
344  void checkFlows(SUMOTime time);
345 
346 
347 protected:
349  std::set<std::string> myVehIDs;
350 
353 
356 
358  std::map<std::string, SUMOVehicleParameter::Stop*> myBusStops;
359 
362 
364  typedef std::map< std::string, RandomDistributor<SUMOVTypeParameter*>* > VTypeDistDictType;
366  VTypeDistDictType myVTypeDistDict;
367 
370 
373 
376 
379 
381  typedef std::multimap<const SUMOTime, const std::string> PersonMap;
382  PersonMap myPersons;
383 
385  std::map<std::string, std::vector<SUMOTime> > myDepartures;
386 
389 
392 
395 
397  unsigned int myReadRouteNo;
398 
400  unsigned int myDiscardedRouteNo;
401 
403  unsigned int myWrittenRouteNo;
404 
407 
410 
411 private:
413  RONet(const RONet& src);
414 
416  RONet& operator=(const RONet& src);
417 
418 };
419 
420 
421 #endif
422 
423 /****************************************************************************/
424 
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition: RONet.h:391
OutputDevice * getRouteOutput(const bool alternative=false)
Definition: RONet.h:327
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:378
ROVehicleCont & getVehicles()
return vehicles for use by RouteAggregator
Definition: RONet.h:339
int myNumInternalEdges
The number of internal edges in the dictionary.
Definition: RONet.h:409
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: RONet.cpp:186
Structure representing possible vehicle parameter.
void addNode(RONode *node)
Definition: RONet.cpp:94
unsigned int getEdgeNo() const
Returns the number of edges the network contains.
Definition: RONet.cpp:395
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:102
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:355
unsigned int myDiscardedRouteNo
The number of discarded routes.
Definition: RONet.h:400
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
Definition: RONet.h:385
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition: RONet.h:394
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:204
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:227
const std::map< std::string, ROEdge * > & getEdgeMap() const
Definition: RONet.cpp:407
void openOutput(const std::string &filename, const std::string altFilename, const std::string typeFilename)
Opens the output for computed routes.
Definition: RONet.cpp:120
T get(const std::string &id) const
Retrieves an item.
void checkFlows(SUMOTime time)
Definition: RONet.cpp:298
const SUMOVehicleParameter::Stop * getBusStop(const std::string &id) const
Retrieves a bus stop from the network.
Definition: RONet.h:145
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:217
A vehicle as used by router.
Definition: ROVehicle.h:59
void closeOutput()
closes the file output for computed routes
Definition: RONet.cpp:139
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:114
bool myHaveRestrictions
Whether the network contains edges which not all vehicles may pass.
Definition: RONet.h:406
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:388
friend class RouteAggregator
Definition: RONet.h:68
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:361
void addPerson(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:253
virtual bool furtherStored()
Returns the information whether further vehicles are stored.
Definition: RONet.cpp:389
unsigned int getEdgeNoWithoutInternal() const
Returns the number of non-internal edges the network contains.
Definition: RONet.cpp:401
ROVehicleCont myVehicles
Known vehicles.
Definition: RONet.h:375
unsigned int myReadRouteNo
The number of read routes.
Definition: RONet.h:397
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type was loaded.
Definition: RONet.h:369
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition: RONet.h:372
A basic edge for routing applications.
Definition: ROEdge.h:69
A container for vehicles sorted by their departure time.
Definition: ROVehicleCont.h:54
RONet()
Constructor.
Definition: RONet.cpp:58
The router's network representation.
Definition: RONet.h:67
Structure representing possible vehicle parameter.
void setRestrictionFound()
Definition: RONet.cpp:419
Definition of vehicle stop (position and duration)
PersonMap myPersons
Definition: RONet.h:382
std::map< std::string, RandomDistributor< SUMOVTypeParameter * > * > VTypeDistDictType
Vehicle type distribution dictionary type.
Definition: RONet.h:364
A storage for options typed value containers)
Definition: OptionsCont.h:108
bool hasRestrictions() const
Definition: RONet.cpp:413
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition: RONet.h:366
Base class for a vehicle's route definition.
Definition: RORouteDef.h:64
void addBusStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:103
int SUMOTime
Definition: SUMOTime.h:43
RONode * getNode(const std::string &id) const
Retrieves an node from the network.
Definition: RONet.h:124
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:80
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
std::set< std::string > myVehIDs
Known vehicle ids.
Definition: RONet.h:349
virtual ~RONet()
Destructor.
Definition: RONet.cpp:70
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:157
Base class for nodes used by the router.
Definition: RONode.h:51
std::multimap< const SUMOTime, const std::string > PersonMap
Known persons.
Definition: RONet.h:381
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition: RONet.h:352
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:239
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition: RONet.cpp:335
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:231
RONet & operator=(const RONet &src)
Invalidated assignment operator.
std::map< std::string, SUMOVehicleParameter::Stop * > myBusStops
Known bus stops.
Definition: RONet.h:358
bool computeRoute(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const veh)
Definition: RONet.cpp:259
unsigned int myWrittenRouteNo
The number of written routes.
Definition: RONet.h:403