SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RONet.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // The router's network representation
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
11 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef RONet_h
22 #define RONet_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include "ROEdge.h"
36 #include "RONode.h"
37 #include "ROVehicleCont.h"
38 #include "ROVehicle.h"
39 #include "RORouteDef.h"
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class RONode;
49 class RORouteDef;
50 class OptionsCont;
51 class OutputDevice;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
65 class RONet {
66  friend class RouteAggregator;
67 
68 public:
70  RONet();
71 
72 
74  virtual ~RONet();
75 
76 
78 
79 
80  /* @brief Adds a read edge to the network
81  *
82  * If the edge is already known (another one with the same id exists),
83  * an error is generated and given to msg-error-handler. The edge
84  * is deleted in this case and false is returned.
85  *
86  * @param[in] edge The edge to add
87  * @return Whether the edge was added (if not, it was deleted, too)
88  */
89  virtual bool addEdge(ROEdge* edge);
90 
91 
100  ROEdge* getEdge(const std::string& name) const {
101  return myEdges.get(name);
102  }
103 
104 
105  /* @brief Adds a read node to the network
106  *
107  * If the node is already known (another one with the same id exists),
108  * an error is generated and given to msg-error-handler. The node
109  * is deleted in this case
110  *
111  * @param[in] node The node to add
112  */
113  void addNode(RONode* node);
114 
115 
122  RONode* getNode(const std::string& id) const {
123  return myNodes.get(id);
124  }
125 
126 
127  /* @brief Adds a read bus stop to the network
128  *
129  * If the bus stop is already known (another one with the same id exists),
130  * an error is generated and given to msg-error-handler. The stop
131  * is deleted in this case
132  *
133  * @param[in] node The stop to add
134  */
135  void addBusStop(const std::string& id, SUMOVehicleParameter::Stop* stop);
136 
137 
143  const SUMOVehicleParameter::Stop* getBusStop(const std::string& id) const {
144  std::map<std::string, SUMOVehicleParameter::Stop*>::const_iterator it = myBusStops.find(id);
145  if (it == myBusStops.end()) {
146  return 0;
147  }
148  return it->second;
149  }
151 
152 
153 
155 
156 
163  bool checkVType(const std::string& id);
164 
165 
175  virtual bool addVehicleType(SUMOVTypeParameter* type);
176 
177 
191  bool addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution);
192 
193 
206  SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id);
207 
208 
209  /* @brief Adds a route definition to the network
210  *
211  * If the route definition is already known (another one with
212  * the same id exists), false is returned, but the route definition
213  * is not deleted.
214  *
215  * @param[in] def The route definition to add
216  * @return Whether the route definition could be added
217  * @todo Rename myRoutes to myRouteDefinitions
218  */
219  bool addRouteDef(RORouteDef* def);
220 
221 
229  RORouteDef* getRouteDef(const std::string& name) const {
230  return myRoutes.get(name);
231  }
232 
233 
234  /* @brief Adds a vehicle to the network
235  *
236  * If the vehicle is already known (another one with the same id
237  * exists), false is returned, but the vehicle is not deleted.
238  *
239  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
240  *
241  * @param[in] id The id of the vehicle to add
242  * @param[in] veh The vehicle to add
243  * @return Whether the vehicle could be added
244  */
245  virtual bool addVehicle(const std::string& id, ROVehicle* veh);
246 
247 
248  /* @brief Adds a flow of vehicles to the network
249  *
250  * If the flow is already known (another one with the same id
251  * exists), false is returned, but the vehicle parameter are not deleted.
252  *
253  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
254  *
255  * @param[in] flow The parameter of the flow to add
256  * @return Whether the flow could be added
257  */
258  bool addFlow(SUMOVehicleParameter* flow, const bool randomize);
259 
260 
261  /* @brief Adds a person to the network
262  *
263  * @param[in] depart The departure time of the person
264  * @param[in] desc The xml description of the person
265  */
266  void addPerson(const SUMOTime depart, const std::string desc);
267  // @}
268 
269 
271 
272 
286 
287 
289  virtual bool furtherStored();
291 
292 
293 
294 
295 
306  void openOutput(const std::string& filename, const std::string altFilename, const std::string typeFilename);
307 
308 
310  void closeOutput();
311 
312 
314  unsigned int getEdgeNo() const;
315 
317  unsigned int getEdgeNoWithoutInternal() const;
318 
319  const std::map<std::string, ROEdge*>& getEdgeMap() const;
320 
321  bool hasRestrictions() const;
322 
323  void setRestrictionFound();
324 
325  OutputDevice* getRouteOutput(const bool alternative = false) {
326  if (alternative) {
328  }
329  return myRoutesOutput;
330  }
331 
332 protected:
333  bool computeRoute(OptionsCont& options,
334  SUMOAbstractRouter<ROEdge, ROVehicle>& router, const ROVehicle* const veh);
335 
338  return myVehicles;
339  }
340 
341 
342  void checkFlows(SUMOTime time);
343 
344 
345 protected:
347  std::set<std::string> myVehIDs;
348 
351 
354 
356  std::map<std::string, SUMOVehicleParameter::Stop*> myBusStops;
357 
360 
362  typedef std::map< std::string, RandomDistributor<SUMOVTypeParameter*>* > VTypeDistDictType;
365 
368 
371 
374 
377 
379  typedef std::multimap<const SUMOTime, const std::string> PersonMap;
381 
383  std::map<std::string, std::vector<SUMOTime> > myDepartures;
384 
387 
390 
393 
395  unsigned int myReadRouteNo;
396 
398  unsigned int myDiscardedRouteNo;
399 
401  unsigned int myWrittenRouteNo;
402 
405 
408 
409 private:
411  RONet(const RONet& src);
412 
414  RONet& operator=(const RONet& src);
415 
416 };
417 
418 
419 #endif
420 
421 /****************************************************************************/
422 
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition: RONet.h:389
OutputDevice * getRouteOutput(const bool alternative=false)
Definition: RONet.h:325
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:376
ROVehicleCont & getVehicles()
return vehicles for use by RouteAggregator
Definition: RONet.h:337
int myNumInternalEdges
The number of internal edges in the dictionary.
Definition: RONet.h:407
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: RONet.cpp:188
Structure representing possible vehicle parameter.
void addNode(RONode *node)
Definition: RONet.cpp:95
unsigned int getEdgeNo() const
Returns the number of edges the network contains.
Definition: RONet.cpp:397
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:100
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:353
unsigned int myDiscardedRouteNo
The number of discarded routes.
Definition: RONet.h:398
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
Definition: RONet.h:383
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition: RONet.h:392
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:206
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:229
const std::map< std::string, ROEdge * > & getEdgeMap() const
Definition: RONet.cpp:409
void openOutput(const std::string &filename, const std::string altFilename, const std::string typeFilename)
Opens the output for computed routes.
Definition: RONet.cpp:121
T get(const std::string &id) const
Retrieves an item.
void checkFlows(SUMOTime time)
Definition: RONet.cpp:300
const SUMOVehicleParameter::Stop * getBusStop(const std::string &id) const
Retrieves a bus stop from the network.
Definition: RONet.h:143
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:219
A vehicle as used by router.
Definition: ROVehicle.h:58
void closeOutput()
closes the file output for computed routes
Definition: RONet.cpp:140
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:115
bool myHaveRestrictions
Whether the network contains edges which not all vehicles may pass.
Definition: RONet.h:404
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:386
friend class RouteAggregator
Definition: RONet.h:66
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:359
void addPerson(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:255
virtual bool furtherStored()
Returns the information whether further vehicles are stored.
Definition: RONet.cpp:391
unsigned int getEdgeNoWithoutInternal() const
Returns the number of non-internal edges the network contains.
Definition: RONet.cpp:403
ROVehicleCont myVehicles
Known vehicles.
Definition: RONet.h:373
unsigned int myReadRouteNo
The number of read routes.
Definition: RONet.h:395
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type was loaded.
Definition: RONet.h:367
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition: RONet.h:370
A basic edge for routing applications.
Definition: ROEdge.h:67
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:65
Structure representing possible vehicle parameter.
void setRestrictionFound()
Definition: RONet.cpp:421
Definition of vehicle stop (position and duration)
PersonMap myPersons
Definition: RONet.h:380
std::map< std::string, RandomDistributor< SUMOVTypeParameter * > * > VTypeDistDictType
Vehicle type distribution dictionary type.
Definition: RONet.h:362
A storage for options typed value containers)
Definition: OptionsCont.h:108
bool hasRestrictions() const
Definition: RONet.cpp:415
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition: RONet.h:364
Base class for a vehicle's route definition.
Definition: RORouteDef.h:63
void addBusStop(const std::string &id, SUMOVehicleParameter::Stop *stop)
Definition: RONet.cpp:104
int SUMOTime
Definition: SUMOTime.h:43
RONode * getNode(const std::string &id) const
Retrieves an node from the network.
Definition: RONet.h:122
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:81
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
std::set< std::string > myVehIDs
Known vehicle ids.
Definition: RONet.h:347
virtual ~RONet()
Destructor.
Definition: RONet.cpp:71
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:158
Base class for nodes used by the router.
Definition: RONode.h:46
std::multimap< const SUMOTime, const std::string > PersonMap
Known persons.
Definition: RONet.h:379
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition: RONet.h:350
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:241
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition: RONet.cpp:337
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:229
RONet & operator=(const RONet &src)
Invalidated assignment operator.
std::map< std::string, SUMOVehicleParameter::Stop * > myBusStops
Known bus stops.
Definition: RONet.h:356
bool computeRoute(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const veh)
Definition: RONet.cpp:261
unsigned int myWrittenRouteNo
The number of written routes.
Definition: RONet.h:401