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-2018 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 
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(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
129 
132 
141  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
142 
151  bool notifyLeave(SUMOVehicle& 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) 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 
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:36
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.
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:85
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:75
MSTriggeredRerouter & operator=(const MSTriggeredRerouter &)
Invalidated assignment operator.
virtual void myEndElement(int element)
Called when a closing tag occurs.
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:60
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
MSParkingArea * rerouteParkingArea(const MSTriggeredRerouter::RerouteInterval *rerouteDef, SUMOVehicle &veh, bool &newDestination) const
Something on a lane to be noticed about vehicle movement.
static MSEdge mySpecialDest_terminateRoute
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Tries to reroute the vehicle.
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Removes the reminder.
RandomDistributor< MSEdge * > myCurrentEdgeProb
new destinations with probabilities
Reroutes vehicles passing an edge.
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:71
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Triggers rerouting (once) for vehicles that are already on the edge when the rerouter activates...
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:71
MSEdgeVector closedLanesAffected
The list of edges that are affect by closed lanes.