Eclipse SUMO - Simulation of Urban MObility
MSTriggeredRerouter.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 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 /****************************************************************************/
18 // Reroutes vehicles passing an edge
19 /****************************************************************************/
20 #ifndef MSTriggeredRerouter_h
21 #define MSTriggeredRerouter_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <vector>
31 #include <utils/common/Command.h>
33 #include "MSTrigger.h"
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class MSNet;
42 class MSLane;
43 class MSRoute;
44 class SUMOVehicle;
45 class MSParkingArea;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
63  public MSTrigger, public MSMoveReminder,
64  public SUMOSAXHandler {
65 
66  friend class GUIEdge; // dynamic instantiation
67 
68 public:
76  MSTriggeredRerouter(const std::string& id,
77  const MSEdgeVector& edges,
78  double prob, const std::string& file, bool off,
79  SUMOTime timeThreshold,
80  const std::string& vTypes);
81 
82 
84  virtual ~MSTriggeredRerouter();
85 
86  typedef std::pair<MSParkingArea*, bool> ParkingAreaVisible;
87 
92  struct RerouteInterval {
94  long long id;
102  std::vector<MSLane*> closedLanes;
113  };
114 
129  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
130 
133 
142  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
143 
152  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
153 
155  const RerouteInterval* getCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
156 
158  SUMOTime setPermissions(const SUMOTime currentTime);
159 
161  const RerouteInterval* getCurrentReroute(SUMOTime time) const;
162 
164  void setUserMode(bool val);
165 
167  void setUserUsageProbability(double prob);
168 
170  bool inUserMode() const;
171 
173  double getProbability() const;
174 
176  double getUserProbability() const;
177 
178  double getWeight(SUMOVehicle& veh, const std::string param, const double defaultWeight) const;
179 
181  SUMOVehicle& veh, bool& newDestination, ConstMSEdgeVector& newRoute) const;
182 
183 
184 protected:
186 
187 
195  virtual void myStartElement(int element,
196  const SUMOSAXAttributes& attrs);
197 
198 
205  virtual void myEndElement(int element);
207 
213  bool vehicleApplies(const SUMOVehicle& veh) const;
214 
215 
216 protected:
218  std::vector<RerouteInterval> myIntervals;
219 
222 
225 
226  // @brief waiting time threshold for activation
228 
230  std::set<std::string> myVehicleTypes;
231 
233 
234 
240  std::vector<MSLane*> myCurrentClosedLanes;
250 
251 
255 
256 private:
259 
262 
263 
264 };
265 
266 
267 #endif
268 
269 /****************************************************************************/
270 
MSTriggeredRerouter::myCurrentIntervalBegin
SUMOTime myCurrentIntervalBegin
The first and the last time steps of the interval.
Definition: MSTriggeredRerouter.h:236
MSTriggeredRerouter::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Triggers rerouting (once) for vehicles that are already on the edge when the rerouter activates.
Definition: MSTriggeredRerouter.cpp:350
MSTriggeredRerouter::getCurrentReroute
const RerouteInterval * getCurrentReroute(SUMOTime time, SUMOVehicle &veh) const
Returns the rerouting definition valid for the given time and vehicle, 0 if none.
Definition: MSTriggeredRerouter.cpp:314
MSTriggeredRerouter::RerouteInterval::routeProbs
RandomDistributor< const MSRoute * > routeProbs
The distributions of new routes to use.
Definition: MSTriggeredRerouter.h:108
MSTriggeredRerouter::RerouteInterval
Definition: MSTriggeredRerouter.h:92
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
MSParkingArea
A lane area vehicles can halt at.
Definition: MSParkingArea.h:59
MSTriggeredRerouter::ParkingAreaVisible
std::pair< MSParkingArea *, bool > ParkingAreaVisible
Definition: MSTriggeredRerouter.h:86
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
SUMOSAXHandler
SAX-handler base for SUMO-files.
Definition: SUMOSAXHandler.h:42
MSTriggeredRerouter::RerouteInterval::permissions
SVCPermissions permissions
The permissions to use.
Definition: MSTriggeredRerouter.h:110
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:92
MSTriggeredRerouter::myCurrentIntervalEnd
SUMOTime myCurrentIntervalEnd
Definition: MSTriggeredRerouter.h:236
SUMOSAXHandler.h
MSTriggeredRerouter::myUserProbability
double myUserProbability
Definition: MSTriggeredRerouter.h:221
MSTriggeredRerouter::getUserProbability
double getUserProbability() const
Returns the rerouting probability given by the user.
Definition: MSTriggeredRerouter.cpp:557
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
MSTriggeredRerouter::myCurrentPermissions
SVCPermissions myCurrentPermissions
List of permissions for closed edges.
Definition: MSTriggeredRerouter.h:242
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
MSTriggeredRerouter::myCurrentClosedLanes
std::vector< MSLane * > myCurrentClosedLanes
List of closed lanes.
Definition: MSTriggeredRerouter.h:240
MSTriggeredRerouter::myVehicleTypes
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
Definition: MSTriggeredRerouter.h:230
MSTriggeredRerouter
Reroutes vehicles passing an edge.
Definition: MSTriggeredRerouter.h:62
MSTriggeredRerouter::rerouteParkingArea
MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute) const
Definition: MSTriggeredRerouter.cpp:587
MSTriggeredRerouter::operator=
MSTriggeredRerouter & operator=(const MSTriggeredRerouter &)
Invalidated assignment operator.
MSTriggeredRerouter::setPermissions
SUMOTime setPermissions(const SUMOTime currentTime)
Sets the edge permission if there are any defined in the closingEdge.
Definition: MSTriggeredRerouter.cpp:278
MSTriggeredRerouter::MSTriggeredRerouter
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, const std::string &file, bool off, SUMOTime timeThreshold, const std::string &vTypes)
Constructor.
Definition: MSTriggeredRerouter.cpp:72
MSTriggeredRerouter::RerouteInterval::edgeProbs
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.
Definition: MSTriggeredRerouter.h:106
MSRoute
Definition: MSRoute.h:67
MSTriggeredRerouter::myTimeThreshold
SUMOTime myTimeThreshold
Definition: MSTriggeredRerouter.h:227
MSTriggeredRerouter::myCurrentParkProb
RandomDistributor< ParkingAreaVisible > myCurrentParkProb
new destinations with probabilities
Definition: MSTriggeredRerouter.h:244
MSMoveReminder
Something on a lane to be noticed about vehicle movement.
Definition: MSMoveReminder.h:64
MSTriggeredRerouter::setUserMode
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
Definition: MSTriggeredRerouter.cpp:533
MSTriggeredRerouter::myProbability
double myProbability
The probability and the user-given probability.
Definition: MSTriggeredRerouter.h:221
MSMoveReminder.h
MSTriggeredRerouter::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes the reminder.
Definition: MSTriggeredRerouter.cpp:357
MSTriggeredRerouter::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Tries to reroute the vehicle.
Definition: MSTriggeredRerouter.cpp:364
MSTriggeredRerouter::getWeight
double getWeight(SUMOVehicle &veh, const std::string param, const double defaultWeight) const
Definition: MSTriggeredRerouter.cpp:563
RandomDistributor.h
MSTriggeredRerouter::mySpecialDest_keepDestination
static MSEdge mySpecialDest_keepDestination
special destination values
Definition: MSTriggeredRerouter.h:253
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:219
MSTriggeredRerouter::setUserUsageProbability
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
Definition: MSTriggeredRerouter.cpp:539
MSTriggeredRerouter::myEndElement
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: MSTriggeredRerouter.cpp:237
MSTriggeredRerouter::myCurrentRouteProb
RandomDistributor< const MSRoute * > myCurrentRouteProb
new routes with probabilities
Definition: MSTriggeredRerouter.h:248
MSTriggeredRerouter::RerouteInterval::closedLanes
std::vector< MSLane * > closedLanes
The list of closed lanes.
Definition: MSTriggeredRerouter.h:102
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
MSTrigger.h
MSTriggeredRerouter::~MSTriggeredRerouter
virtual ~MSTriggeredRerouter()
Destructor.
Definition: MSTriggeredRerouter.cpp:105
MSTriggeredRerouter::myCurrentEdgeProb
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
Definition: MSTriggeredRerouter.h:246
RandomDistributor< MSEdge * >
MSTriggeredRerouter::RerouteInterval::id
long long id
unique ID for this interval
Definition: MSTriggeredRerouter.h:94
MSTrigger
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:41
MSTriggeredRerouter::RerouteInterval::begin
SUMOTime begin
The begin time these definitions are valid.
Definition: MSTriggeredRerouter.h:96
MSTriggeredRerouter::mySpecialDest_terminateRoute
static MSEdge mySpecialDest_terminateRoute
Definition: MSTriggeredRerouter.h:254
GUIEdge
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
MSTriggeredRerouter::inUserMode
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
Definition: MSTriggeredRerouter.cpp:545
MSTriggeredRerouter::myAmInUserMode
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
Definition: MSTriggeredRerouter.h:224
MSEdgeVector
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:72
MSTriggeredRerouter::myIntervals
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
Definition: MSTriggeredRerouter.h:218
config.h
Command.h
MSTriggeredRerouter::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: MSTriggeredRerouter.cpp:110
MSTriggeredRerouter::RerouteInterval::end
SUMOTime end
The end time these definitions are valid.
Definition: MSTriggeredRerouter.h:98
MSTriggeredRerouter::RerouteInterval::closed
MSEdgeVector closed
The list of closed edges.
Definition: MSTriggeredRerouter.h:100
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:89
MSTriggeredRerouter::RerouteInterval::closedLanesAffected
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.
Definition: MSTriggeredRerouter.h:104
MSTriggeredRerouter::RerouteInterval::parkProbs
RandomDistributor< ParkingAreaVisible > parkProbs
The distributions of new parking areas to use as destinations.
Definition: MSTriggeredRerouter.h:112
MSTriggeredRerouter::myCurrentClosed
MSEdgeVector myCurrentClosed
List of closed edges.
Definition: MSTriggeredRerouter.h:238
MSTriggeredRerouter::vehicleApplies
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
Definition: MSTriggeredRerouter.cpp:882
MSTriggeredRerouter::getProbability
double getProbability() const
Returns the rerouting probability.
Definition: MSTriggeredRerouter.cpp:551