SUMO - Simulation of Urban MObility
ODDistrict.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A district (origin/destination)
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2002-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <string>
35 #include <utility>
37 #include <utils/common/Named.h>
39 #include "ODDistrict.h"
40 
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
46 ODDistrict::ODDistrict(const std::string& id)
47  : Named(id) {}
48 
49 
51 
52 
53 void
54 ODDistrict::addSource(const std::string& id, double weight) {
55  mySources.add(id, weight);
56 }
57 
58 
59 void
60 ODDistrict::addSink(const std::string& id, double weight) {
61  mySinks.add(id, weight);
62 }
63 
64 
65 std::string
67  return mySources.get();
68 }
69 
70 
71 std::string
73  return mySinks.get();
74 }
75 
76 
77 int
79  return (int) mySinks.getVals().size();
80 }
81 
82 
83 int
85  return (int) mySources.getVals().size();
86 }
87 
88 
89 
90 /****************************************************************************/
91 
std::string getRandomSource() const
Returns the id of a source to use.
Definition: ODDistrict.cpp:66
std::string getRandomSink() const
Returns the id of a sink to use.
Definition: ODDistrict.cpp:72
void addSink(const std::string &id, double weight)
Adds a sink connection.
Definition: ODDistrict.cpp:60
~ODDistrict()
Destructor.
Definition: ODDistrict.cpp:50
int sourceNumber() const
Returns the number of sources.
Definition: ODDistrict.cpp:84
ODDistrict(const std::string &id)
Constructor.
Definition: ODDistrict.cpp:46
const std::vector< T > & getVals() const
Returns the members of the distribution.
RandomDistributor< std::string > mySinks
Container of weighted sinks.
Definition: ODDistrict.h:138
RandomDistributor< std::string > mySources
Container of weighted sources.
Definition: ODDistrict.h:135
Base class for objects which have an id.
Definition: Named.h:46
T get(MTRand *which=0) const
Draw a sample of the distribution.
void addSource(const std::string &id, double weight)
Adds a source connection.
Definition: ODDistrict.cpp:54
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:78