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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A district (origin/destination)
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <vector>
27 #include <string>
28 #include <utility>
30 #include <utils/common/Named.h>
32 #include "ODDistrict.h"
33 
34 
35 
36 // ===========================================================================
37 // method definitions
38 // ===========================================================================
39 ODDistrict::ODDistrict(const std::string& id)
40  : Named(id) {}
41 
42 
44 
45 
46 void
47 ODDistrict::addSource(const std::string& id, double weight) {
48  mySources.add(id, weight);
49 }
50 
51 
52 void
53 ODDistrict::addSink(const std::string& id, double weight) {
54  mySinks.add(id, weight);
55 }
56 
57 
58 std::string
60  return mySources.get();
61 }
62 
63 
64 std::string
66  return mySinks.get();
67 }
68 
69 
70 int
72  return (int) mySinks.getVals().size();
73 }
74 
75 
76 int
78  return (int) mySources.getVals().size();
79 }
80 
81 
82 
83 /****************************************************************************/
84 
std::string getRandomSource() const
Returns the id of a source to use.
Definition: ODDistrict.cpp:59
std::string getRandomSink() const
Returns the id of a sink to use.
Definition: ODDistrict.cpp:65
void addSink(const std::string &id, double weight)
Adds a sink connection.
Definition: ODDistrict.cpp:53
~ODDistrict()
Destructor.
Definition: ODDistrict.cpp:43
int sourceNumber() const
Returns the number of sources.
Definition: ODDistrict.cpp:77
ODDistrict(const std::string &id)
Constructor.
Definition: ODDistrict.cpp:39
const std::vector< T > & getVals() const
Returns the members of the distribution.
RandomDistributor< std::string > mySinks
Container of weighted sinks.
Definition: ODDistrict.h:131
RandomDistributor< std::string > mySources
Container of weighted sources.
Definition: ODDistrict.h:128
T get(std::mt19937 *which=0) const
Draw a sample of the distribution.
Base class for objects which have an id.
Definition: Named.h:58
void addSource(const std::string &id, double weight)
Adds a source connection.
Definition: ODDistrict.cpp:47
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:71