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-2013 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 
101  ROEdge* getEdge(const std::string& name) const {
102  return myEdges.get(name);
103  }
104 
105 
106  /* @brief Adds a read node to the network
107  *
108  * If the node is already known (another one with the same id exists),
109  * an error is generated and given to msg-error-handler. The node
110  * is deleted in this case
111  *
112  * @param[in] node The node to add
113  */
114  void addNode(RONode* node);
115 
116 
123  RONode* getNode(const std::string& id) const {
124  return myNodes.get(id);
125  }
127 
128 
129 
131 
132 
139  bool checkVType(const std::string& id);
140 
141 
151  virtual bool addVehicleType(SUMOVTypeParameter* type);
152 
153 
167  bool addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution);
168 
169 
182  SUMOVTypeParameter* getVehicleTypeSecure(const std::string& id);
183 
184 
185  /* @brief Adds a route definition to the network
186  *
187  * If the route definition is already known (another one with
188  * the same id exists), false is returned, but the route definition
189  * is not deleted.
190  *
191  * @param[in] def The route definition to add
192  * @return Whether the route definition could be added
193  * @todo Rename myRoutes to myRouteDefinitions
194  */
195  bool addRouteDef(RORouteDef* def);
196 
197 
205  RORouteDef* getRouteDef(const std::string& name) const {
206  return myRoutes.get(name);
207  }
208 
209 
210  /* @brief Adds a vehicle to the network
211  *
212  * If the vehicle is already known (another one with the same id
213  * exists), false is returned, but the vehicle is not deleted.
214  *
215  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
216  *
217  * @param[in] id The id of the vehicle to add
218  * @param[in] veh The vehicle to add
219  * @return Whether the vehicle could be added
220  */
221  virtual bool addVehicle(const std::string& id, ROVehicle* veh);
222 
223 
224  /* @brief Adds a flow of vehicles to the network
225  *
226  * If the flow is already known (another one with the same id
227  * exists), false is returned, but the vehicle parameter are not deleted.
228  *
229  * Otherwise, the number of loaded routes ("myReadRouteNo") is increased.
230  *
231  * @param[in] flow The parameter of the flow to add
232  * @return Whether the flow could be added
233  */
234  bool addFlow(SUMOVehicleParameter* flow, const bool randomize);
235 
236 
237  /* @brief Adds a person to the network
238  *
239  * @param[in] depart The departure time of the person
240  * @param[in] desc The xml description of the person
241  */
242  void addPerson(const SUMOTime depart, const std::string desc);
243  // @}
244 
245 
247 
248 
262 
263 
265  virtual bool furtherStored();
267 
268 
269 
270 
271 
282  void openOutput(const std::string& filename, const std::string altFilename, const std::string typeFilename);
283 
284 
286  void closeOutput();
287 
288 
290  unsigned int getEdgeNo() const;
291 
292  const std::map<std::string, ROEdge*>& getEdgeMap() const;
293 
294  bool hasRestrictions() const;
295 
296  void setRestrictionFound();
297 
298  OutputDevice* getRouteOutput(const bool alternative = false) {
299  if (alternative) {
301  }
302  return myRoutesOutput;
303  }
304 
305 protected:
306  bool computeRoute(OptionsCont& options,
307  SUMOAbstractRouter<ROEdge, ROVehicle>& router, const ROVehicle* const veh);
308 
311  return myVehicles;
312  }
313 
314 
315  void checkFlows(SUMOTime time);
316 
317 
318 protected:
320  std::set<std::string> myVehIDs;
321 
324 
327 
330 
332  typedef std::map< std::string, RandomDistributor<SUMOVTypeParameter*>* > VTypeDistDictType;
335 
338 
341 
344 
347 
349  typedef std::multimap<const SUMOTime, const std::string> PersonMap;
351 
353  std::map<std::string, std::vector<SUMOTime> > myDepartures;
354 
357 
360 
363 
365  unsigned int myReadRouteNo;
366 
368  unsigned int myDiscardedRouteNo;
369 
371  unsigned int myWrittenRouteNo;
372 
375 
376 
377 private:
379  RONet(const RONet& src);
380 
382  RONet& operator=(const RONet& src);
383 
384 };
385 
386 
387 #endif
388 
389 /****************************************************************************/
390 
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition: RONet.h:359
OutputDevice * getRouteOutput(const bool alternative=false)
Definition: RONet.h:298
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition: RONet.h:346
ROVehicleCont & getVehicles()
return vehicles for use by RouteAggregator
Definition: RONet.h:310
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition: RONet.cpp:173
Structure representing possible vehicle parameter.
void addNode(RONode *node)
Definition: RONet.cpp:91
unsigned int getEdgeNo() const
Returns the number of edges thenetwork contains.
Definition: RONet.cpp:382
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:101
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition: RONet.h:326
unsigned int myDiscardedRouteNo
The number of discarded routes.
Definition: RONet.h:368
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
Definition: RONet.h:353
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition: RONet.h:362
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition: RONet.cpp:191
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition: RONet.cpp:214
const std::map< std::string, ROEdge * > & getEdgeMap() const
Definition: RONet.cpp:388
void openOutput(const std::string &filename, const std::string altFilename, const std::string typeFilename)
Opens the output for computed routes.
Definition: RONet.cpp:106
T get(const std::string &id) const
Retrieves an item.
void checkFlows(SUMOTime time)
Definition: RONet.cpp:285
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition: RONet.cpp:204
A vehicle as used by router.
Definition: ROVehicle.h:57
void closeOutput()
closes the file output for computed routes
Definition: RONet.cpp:125
bool addRouteDef(RORouteDef *def)
Definition: RONet.cpp:100
bool myHaveRestrictions
Whether the network contains edges which not all vehicles may pass.
Definition: RONet.h:374
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition: RONet.h:356
friend class RouteAggregator
Definition: RONet.h:66
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition: RONet.h:329
void addPerson(const SUMOTime depart, const std::string desc)
Definition: RONet.cpp:240
virtual bool furtherStored()
Returns the information whether further vehicles are stored.
Definition: RONet.cpp:376
ROVehicleCont myVehicles
Known vehicles.
Definition: RONet.h:343
unsigned int myReadRouteNo
The number of read routes.
Definition: RONet.h:365
bool myDefaultVTypeMayBeDeleted
Whether no vehicle type was loaded.
Definition: RONet.h:337
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition: RONet.h:340
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&#39;s network representation.
Definition: RONet.h:65
Structure representing possible vehicle parameter.
void setRestrictionFound()
Definition: RONet.cpp:400
PersonMap myPersons
Definition: RONet.h:350
std::map< std::string, RandomDistributor< SUMOVTypeParameter * > * > VTypeDistDictType
Vehicle type distribution dictionary type.
Definition: RONet.h:332
A storage for options typed value containers)
Definition: OptionsCont.h:108
bool hasRestrictions() const
Definition: RONet.cpp:394
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability-&gt;vehicle type)
Definition: RONet.h:334
Base class for a vehicle&#39;s route definition.
Definition: RORouteDef.h:63
int SUMOTime
Definition: SUMOTime.h:43
RONode * getNode(const std::string &id) const
Retrieves an node from the network.
Definition: RONet.h:123
virtual bool addEdge(ROEdge *edge)
Definition: RONet.cpp:80
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:320
virtual ~RONet()
Destructor.
Definition: RONet.cpp:70
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:143
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:349
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition: RONet.h:323
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition: RONet.cpp:226
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition: RONet.cpp:322
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition: RONet.h:205
RONet & operator=(const RONet &src)
Invalidated assignment operator.
bool computeRoute(OptionsCont &options, SUMOAbstractRouter< ROEdge, ROVehicle > &router, const ROVehicle *const veh)
Definition: RONet.cpp:246
unsigned int myWrittenRouteNo
The number of written routes.
Definition: RONet.h:371