SUMO - Simulation of Urban MObility
ODDistrict.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2002-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A district (origin/destination)
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <vector>
33 #include <string>
34 #include <utility>
36 #include <utils/common/Named.h>
38 #include "ODDistrict.h"
39 
40 
41 
42 // ===========================================================================
43 // method definitions
44 // ===========================================================================
45 ODDistrict::ODDistrict(const std::string& id)
46  : Named(id) {}
47 
48 
50 
51 
52 void
53 ODDistrict::addSource(const std::string& id, double weight) {
54  mySources.add(id, weight);
55 }
56 
57 
58 void
59 ODDistrict::addSink(const std::string& id, double weight) {
60  mySinks.add(id, weight);
61 }
62 
63 
64 std::string
66  return mySources.get();
67 }
68 
69 
70 std::string
72  return mySinks.get();
73 }
74 
75 
76 int
78  return (int) mySinks.getVals().size();
79 }
80 
81 
82 int
84  return (int) mySources.getVals().size();
85 }
86 
87 
88 
89 /****************************************************************************/
90 
std::string getRandomSource() const
Returns the id of a source to use.
Definition: ODDistrict.cpp:65
std::string getRandomSink() const
Returns the id of a sink to use.
Definition: ODDistrict.cpp:71
void addSink(const std::string &id, double weight)
Adds a sink connection.
Definition: ODDistrict.cpp:59
~ODDistrict()
Destructor.
Definition: ODDistrict.cpp:49
int sourceNumber() const
Returns the number of sources.
Definition: ODDistrict.cpp:83
ODDistrict(const std::string &id)
Constructor.
Definition: ODDistrict.cpp:45
const std::vector< T > & getVals() const
Returns the members of the distribution.
RandomDistributor< std::string > mySinks
Container of weighted sinks.
Definition: ODDistrict.h:137
RandomDistributor< std::string > mySources
Container of weighted sources.
Definition: ODDistrict.h:134
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
Base class for objects which have an id.
Definition: Named.h:45
void addSource(const std::string &id, double weight)
Adds a source connection.
Definition: ODDistrict.cpp:53
bool add(T val, double prob, bool checkDuplicates=true)
Adds a value with an assigned probability to the distribution.
int sinkNumber() const
Returns the number of sinks.
Definition: ODDistrict.cpp:77