Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2004-2024 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 ROJTREdge.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Michael Behrisch
17 : /// @author Yun-Pang Floetteroed
18 : /// @date Tue, 20 Jan 2004
19 : ///
20 : // An edge the jtr-router may route through
21 : /****************************************************************************/
22 : #pragma once
23 : #include <config.h>
24 :
25 : #include <string>
26 : #include <map>
27 : #include <vector>
28 : #include <utils/common/ValueTimeLine.h>
29 : #include <router/ROEdge.h>
30 :
31 :
32 : // ===========================================================================
33 : // class declarations
34 : // ===========================================================================
35 : class ROLane;
36 :
37 :
38 : // ===========================================================================
39 : // class definitions
40 : // ===========================================================================
41 : /**
42 : * @class ROJTREdge
43 : * @brief An edge the jtr-router may route through
44 : *
45 : * A router edge extended by the definition about the probability a
46 : * vehicle chooses a certain following edge over time.
47 : */
48 : class ROJTREdge : public ROEdge {
49 : public:
50 : /** @brief Constructor
51 : *
52 : * @param[in] id The id of the edge
53 : * @param[in] from The node the edge begins at
54 : * @param[in] to The node the edge ends at
55 : * @param[in] index The numeric id of the edge
56 : */
57 : ROJTREdge(const std::string& id, RONode* from, RONode* to, int index, const int priority);
58 :
59 :
60 : /// @brief Destructor
61 : ~ROJTREdge();
62 :
63 :
64 : /** @brief Adds information about a connected edge
65 : *
66 : * Makes this edge know the given following edge. Calls ROEdge::addFollower.
67 : *
68 : * Additionally it generates the entry for the given following edge
69 : * in myFollowingDefs.
70 : *
71 : * @param[in] s The following edge
72 : * @see ROEdge::addFollower
73 : */
74 : void addSuccessor(ROEdge* s, ROEdge* via = nullptr, std::string dir = "");
75 :
76 :
77 : /** @brief adds the information about the percentage of using a certain follower
78 : *
79 : * @param[in] follower The following edge
80 : * @param[in] begTime Time begin (in seconds) for which this probability is valid
81 : * @param[in] endTime Time end (in seconds) for which this probability is valid
82 : * @param[in] probability The probability to use the given follower
83 : */
84 : void addFollowerProbability(ROJTREdge* follower,
85 : double begTime, double endTime, double probability);
86 :
87 :
88 : /** @brief Returns the next edge to use
89 : * @param[in] veh The vehicle to choose the next edge for
90 : * @param[in] time The time at which the next edge shall be entered (in seconds)
91 : * @param[in] avoid The set of edges to avoid
92 : * @return The chosen edge
93 : */
94 : ROJTREdge* chooseNext(const ROVehicle* const veh, double time, const std::set<const ROEdge*>& avoid) const;
95 :
96 :
97 : /** @brief Sets the turning definition defaults
98 : * @param[in] def The turning percentage defaults
99 : */
100 : void setTurnDefaults(const std::vector<double>& defs);
101 :
102 : /// @brief register source flow on this edge
103 : int getSourceFlow() const {
104 5577 : return mySourceFlows;
105 : }
106 :
107 : /// @brief register flow on this edge
108 : void changeSourceFlow(int value) {
109 327915 : mySourceFlows += value;
110 184 : }
111 :
112 : private:
113 : /// @brief Definition of a map that stores the probabilities of using a certain follower over time
114 : typedef std::map<ROJTREdge*, ValueTimeLine<double>*, ComparatorIdLess> FollowerUsageCont;
115 :
116 : /// @brief Storage for the probabilities of using a certain follower over time
117 : FollowerUsageCont myFollowingDefs;
118 :
119 : /// @brief The defaults for turnings
120 : std::vector<double> myParsedTurnings;
121 :
122 : /// @brief the flows departing from this edge in the given time
123 : //ValueTimeLine<int> mySourceFlows;
124 : int mySourceFlows;
125 :
126 : private:
127 : /// @brief invalidated copy constructor
128 : ROJTREdge(const ROJTREdge& src);
129 :
130 : /// @brief invalidated assignment operator
131 : ROJTREdge& operator=(const ROJTREdge& src);
132 :
133 :
134 : };
|