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 
A lane area vehicles can halt at.
Definition: MSParkingArea.h:59
double getProbability() const
Returns the rerouting probability.
MSEdgeVector closed
The list of closed edges.
const RerouteInterval * getCurrentReroute(SUMOTime time, SUMOVehicle &veh) const
Returns the rerouting definition valid for the given time and vehicle, 0 if none. ...
long long int SUMOTime
Definition: SUMOTime.h:35
double getUserProbability() const
Returns the rerouting probability given by the user.
Represents a generic random distribution.
SUMOTime setPermissions(const SUMOTime currentTime)
Sets the edge permission if there are any defined in the closingEdge.
SVCPermissions myCurrentPermissions
List of permissions for closed edges.
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.
SUMOTime myCurrentIntervalBegin
The first and the last time steps of the interval.
std::vector< MSLane * > myCurrentClosedLanes
List of closed lanes.
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Notification
Definition of a vehicle state.
MSTriggeredRerouter(const std::string &id, const MSEdgeVector &edges, double prob, const std::string &file, bool off, SUMOTime timeThreshold, const std::string &vTypes)
Constructor.
void setUserUsageProbability(double prob)
Sets the probability with which a vehicle is rerouted given by the user.
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:73
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
SAX-handler base for SUMO-files.
std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
double myProbability
The probability and the user-given probability.
The simulated network and simulation perfomer.
Definition: MSNet.h:92
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes the reminder.
RandomDistributor< ParkingAreaVisible > myCurrentParkProb
new destinations with probabilities
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
A road/street connecting two junctions.
Definition: MSEdge.h:76
MSTriggeredRerouter & operator=(const MSTriggeredRerouter &)
Invalidated assignment operator.
virtual void myEndElement(int element)
Called when a closing tag occurs.
MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination, ConstMSEdgeVector &newRoute) const
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:41
double getWeight(SUMOVehicle &veh, const std::string param, const double defaultWeight) const
Representation of a vehicle.
Definition: SUMOVehicle.h:61
Encapsulated SAX-Attributes.
long long id
unique ID for this interval
virtual ~MSTriggeredRerouter()
Destructor.
SUMOTime begin
The begin time these definitions are valid.
RandomDistributor< const MSRoute * > myCurrentRouteProb
new routes with probabilities
static MSEdge mySpecialDest_keepDestination
special destination values
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Tries to reroute the vehicle.
Something on a lane to be noticed about vehicle movement.
static MSEdge mySpecialDest_terminateRoute
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
Reroutes vehicles passing an edge.
Representation of a vehicle or person.
SUMOTime end
The end time these definitions are valid.
std::vector< MSLane * > closedLanes
The list of closed lanes.
RandomDistributor< const MSRoute * > routeProbs
The distributions of new routes to use.
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
MSEdgeVector myCurrentClosed
List of closed edges.
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:72
std::pair< MSParkingArea *, bool > ParkingAreaVisible
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
SVCPermissions permissions
The permissions to use.
RandomDistributor< ParkingAreaVisible > parkProbs
The distributions of new parking areas to use as destinations.
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
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...
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.