Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/od/ODDistrict.h
169668 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2002-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file ODDistrict.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @date Sept 2002
18
///
19
// A district (origin/destination)
20
/****************************************************************************/
21
#pragma once
22
#include <config.h>
23
24
#include <vector>
25
#include <string>
26
#include <utility>
27
#include <utils/common/Named.h>
28
#include <utils/common/UtilExceptions.h>
29
#include <utils/distribution/RandomDistributor.h>
30
31
32
// ===========================================================================
33
// class definitions
34
// ===========================================================================
35
/**
36
* @class ODDistrict
37
* @brief A district (origin/destination)
38
*
39
* Class representing a district which has some ingoing and outgoing connections
40
* to the road network which may be weighted.
41
*/
42
class ODDistrict : public Named {
43
public:
44
/** @brief Constructor
45
*
46
* @param[in] id The id of the district
47
*/
48
ODDistrict(const std::string& id);
49
50
51
/// @brief Destructor
52
~ODDistrict();
53
54
55
/** @brief Adds a source connection
56
*
57
* A source is an edge where vehicles leave the district from to reach
58
* the network. The weight is used when a random source shall be
59
* chosen.
60
*
61
* BTW, it is possible to add a source twice. In this case it will occure
62
* twice within the distribution so that the behaviour is as adding
63
* both given probabilities.
64
*
65
* @param[in] id The id of the source
66
* @param[in] weight The weight (probability to be chosen) of the source
67
*/
68
void addSource(const std::string& id, double weight);
69
70
71
/** @brief Adds a sink connection
72
*
73
* A sink connection is an edge which is used by vehicles to leave the
74
* network and reach the district. The weight is used when a random
75
* sink shall be chosen.
76
*
77
* BTW, it is possible to add a sink twice. In this case it will occure
78
* twice within the distribution so that the behaviour is as adding
79
* both given probabilities.
80
*
81
* @param[in] id The id of the sink
82
* @param[in] weight The weight (probability to be chosen) of the sink
83
*/
84
void addSink(const std::string& id, double weight);
85
86
87
/** @brief Returns the id of a source to use
88
*
89
* If the list of this district's sources is empty, an OutOfBoundsException
90
* -exception is thrown.
91
*
92
* @return One of this district's sources chosen randomly regarding their weights
93
* @exception OutOfBoundsException If this district has no sources
94
*/
95
std::string getRandomSource() const;
96
97
98
/** @brief Returns the id of a sink to use
99
*
100
* If the list of this district's sinks is empty, an OutOfBoundsException
101
* -exception is thrown.
102
*
103
* @return One of this district's sinks chosen randomly regarding their weights
104
* @exception OutOfBoundsException If this district has no sinks
105
*/
106
std::string getRandomSink() const;
107
108
109
/** @brief Returns the number of sinks
110
*
111
* @return The number of known sinks
112
*/
113
int sinkNumber() const;
114
115
116
/** @brief Returns the number of sources
117
*
118
* @return The number of known sources
119
*/
120
int sourceNumber() const;
121
122
123
private:
124
/// @brief Container of weighted sources
125
RandomDistributor<std::string> mySources;
126
127
/// @brief Container of weighted sinks
128
RandomDistributor<std::string> mySinks;
129
130
131
private:
132
/// @brief invalidated copy constructor
133
ODDistrict(const ODDistrict& s);
134
135
/// @brief invalidated assignment operator
136
ODDistrict& operator=(const ODDistrict& s);
137
138
139
};
140
141