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 /****************************************************************************/
17 // Reroutes vehicles passing an edge
18 /****************************************************************************/
19 #ifndef MSTriggeredRerouter_h
20 #define MSTriggeredRerouter_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <vector>
30 #include <utils/common/Command.h>
32 #include "MSTrigger.h"
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MSNet;
41 class MSLane;
42 class MSRoute;
43 class SUMOVehicle;
44 class MSParkingArea;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
62  public MSTrigger, public MSMoveReminder,
63  public SUMOSAXHandler {
64 
65  friend class GUIEdge; // dynamic instantiation
66 
67 public:
75  MSTriggeredRerouter(const std::string& id,
76  const MSEdgeVector& edges,
77  double prob, const std::string& file, bool off,
78  SUMOTime timeThreshold,
79  const std::string& vTypes);
80 
81 
83  virtual ~MSTriggeredRerouter();
84 
85  typedef std::pair<MSParkingArea*, bool> ParkingAreaVisible;
86 
91  struct RerouteInterval {
93  long long id;
101  std::vector<MSLane*> closedLanes;
112  };
113 
128  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
129 
132 
141  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
142 
151  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
152 
154  const RerouteInterval* getCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
155 
157  SUMOTime setPermissions(const SUMOTime currentTime);
158 
160  const RerouteInterval* getCurrentReroute(SUMOTime time) const;
161 
163  void setUserMode(bool val);
164 
166  void setUserUsageProbability(double prob);
167 
169  bool inUserMode() const;
170 
172  double getProbability() const;
173 
175  double getUserProbability() const;
176 
177  double getWeight(SUMOVehicle& veh, const std::string param, const double defaultWeight) const;
178 
180  SUMOVehicle& veh, bool& newDestination, ConstMSEdgeVector& newRoute) const;
181 
182 
183 protected:
185 
186 
194  virtual void myStartElement(int element,
195  const SUMOSAXAttributes& attrs);
196 
197 
204  virtual void myEndElement(int element);
206 
212  bool vehicleApplies(const SUMOVehicle& veh) const;
213 
214 
215 protected:
217  std::vector<RerouteInterval> myIntervals;
218 
221 
224 
225  // @brief waiting time threshold for activation
227 
229  std::set<std::string> myVehicleTypes;
230 
232 
233 
239  std::vector<MSLane*> myCurrentClosedLanes;
249 
250 
254 
255 private:
258 
261 
262 
263 };
264 
265 
266 #endif
267 
268 /****************************************************************************/
269 
MSTriggeredRerouter::myCurrentIntervalBegin
SUMOTime myCurrentIntervalBegin
The first and the last time steps of the interval.
Definition: MSTriggeredRerouter.h:235
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:349
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:313
MSTriggeredRerouter::RerouteInterval::routeProbs
RandomDistributor< const MSRoute * > routeProbs
The distributions of new routes to use.
Definition: MSTriggeredRerouter.h:107
MSTriggeredRerouter::RerouteInterval
Definition: MSTriggeredRerouter.h:91
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
MSParkingArea
A lane area vehicles can halt at.
Definition: MSParkingArea.h:59
MSTriggeredRerouter::ParkingAreaVisible
std::pair< MSParkingArea *, bool > ParkingAreaVisible
Definition: MSTriggeredRerouter.h:85
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
SUMOSAXHandler
SAX-handler base for SUMO-files.
Definition: SUMOSAXHandler.h:41
MSTriggeredRerouter::RerouteInterval::permissions
SVCPermissions permissions
The permissions to use.
Definition: MSTriggeredRerouter.h:109
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:91
MSTriggeredRerouter::myCurrentIntervalEnd
SUMOTime myCurrentIntervalEnd
Definition: MSTriggeredRerouter.h:235
SUMOSAXHandler.h
MSTriggeredRerouter::myUserProbability
double myUserProbability
Definition: MSTriggeredRerouter.h:220
MSTriggeredRerouter::getUserProbability
double getUserProbability() const
Returns the rerouting probability given by the user.
Definition: MSTriggeredRerouter.cpp:564
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSTriggeredRerouter::myCurrentPermissions
SVCPermissions myCurrentPermissions
List of permissions for closed edges.
Definition: MSTriggeredRerouter.h:241
ConstMSEdgeVector
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:75
MSTriggeredRerouter::myCurrentClosedLanes
std::vector< MSLane * > myCurrentClosedLanes
List of closed lanes.
Definition: MSTriggeredRerouter.h:239
MSTriggeredRerouter::myVehicleTypes
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
Definition: MSTriggeredRerouter.h:229
MSTriggeredRerouter
Reroutes vehicles passing an edge.
Definition: MSTriggeredRerouter.h:61
MSTriggeredRerouter::rerouteParkingArea
MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute) const
Definition: MSTriggeredRerouter.cpp:594
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:277
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:71
MSTriggeredRerouter::RerouteInterval::edgeProbs
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.
Definition: MSTriggeredRerouter.h:105
MSRoute
Definition: MSRoute.h:66
MSTriggeredRerouter::myTimeThreshold
SUMOTime myTimeThreshold
Definition: MSTriggeredRerouter.h:226
MSTriggeredRerouter::myCurrentParkProb
RandomDistributor< ParkingAreaVisible > myCurrentParkProb
new destinations with probabilities
Definition: MSTriggeredRerouter.h:243
MSMoveReminder
Something on a lane to be noticed about vehicle movement.
Definition: MSMoveReminder.h:66
MSTriggeredRerouter::setUserMode
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
Definition: MSTriggeredRerouter.cpp:540
MSTriggeredRerouter::myProbability
double myProbability
The probability and the user-given probability.
Definition: MSTriggeredRerouter.h:220
MSMoveReminder.h
MSTriggeredRerouter::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes the reminder.
Definition: MSTriggeredRerouter.cpp:356
MSTriggeredRerouter::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Tries to reroute the vehicle.
Definition: MSTriggeredRerouter.cpp:363
MSTriggeredRerouter::getWeight
double getWeight(SUMOVehicle &veh, const std::string param, const double defaultWeight) const
Definition: MSTriggeredRerouter.cpp:570
RandomDistributor.h
MSTriggeredRerouter::mySpecialDest_keepDestination
static MSEdge mySpecialDest_keepDestination
special destination values
Definition: MSTriggeredRerouter.h:252
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
MSTriggeredRerouter::setUserUsageProbability
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
Definition: MSTriggeredRerouter.cpp:546
MSTriggeredRerouter::myEndElement
virtual void myEndElement(int element)
Called when a closing tag occurs.
Definition: MSTriggeredRerouter.cpp:236
MSTriggeredRerouter::myCurrentRouteProb
RandomDistributor< const MSRoute * > myCurrentRouteProb
new routes with probabilities
Definition: MSTriggeredRerouter.h:247
MSTriggeredRerouter::RerouteInterval::closedLanes
std::vector< MSLane * > closedLanes
The list of closed lanes.
Definition: MSTriggeredRerouter.h:101
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSTrigger.h
MSTriggeredRerouter::~MSTriggeredRerouter
virtual ~MSTriggeredRerouter()
Destructor.
Definition: MSTriggeredRerouter.cpp:104
MSTriggeredRerouter::myCurrentEdgeProb
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
Definition: MSTriggeredRerouter.h:245
RandomDistributor< MSEdge * >
MSTriggeredRerouter::RerouteInterval::id
long long id
unique ID for this interval
Definition: MSTriggeredRerouter.h:93
MSTrigger
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:40
MSTriggeredRerouter::RerouteInterval::begin
SUMOTime begin
The begin time these definitions are valid.
Definition: MSTriggeredRerouter.h:95
MSTriggeredRerouter::mySpecialDest_terminateRoute
static MSEdge mySpecialDest_terminateRoute
Definition: MSTriggeredRerouter.h:253
GUIEdge
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:52
MSTriggeredRerouter::inUserMode
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
Definition: MSTriggeredRerouter.cpp:552
MSTriggeredRerouter::myAmInUserMode
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
Definition: MSTriggeredRerouter.h:223
MSEdgeVector
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:74
MSTriggeredRerouter::myIntervals
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
Definition: MSTriggeredRerouter.h:217
config.h
Command.h
MSTriggeredRerouter::myStartElement
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
Definition: MSTriggeredRerouter.cpp:109
MSTriggeredRerouter::RerouteInterval::end
SUMOTime end
The end time these definitions are valid.
Definition: MSTriggeredRerouter.h:97
MSTriggeredRerouter::RerouteInterval::closed
MSEdgeVector closed
The list of closed edges.
Definition: MSTriggeredRerouter.h:99
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSTriggeredRerouter::RerouteInterval::closedLanesAffected
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.
Definition: MSTriggeredRerouter.h:103
MSTriggeredRerouter::RerouteInterval::parkProbs
RandomDistributor< ParkingAreaVisible > parkProbs
The distributions of new parking areas to use as destinations.
Definition: MSTriggeredRerouter.h:111
MSTriggeredRerouter::myCurrentClosed
MSEdgeVector myCurrentClosed
List of closed edges.
Definition: MSTriggeredRerouter.h:237
MSTriggeredRerouter::vehicleApplies
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
Definition: MSTriggeredRerouter.cpp:894
MSTriggeredRerouter::getProbability
double getProbability() const
Returns the rerouting probability.
Definition: MSTriggeredRerouter.cpp:558