SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSTriggeredRerouter.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // Reroutes vehicles passing an edge
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef MSTriggeredRerouter_h
23 #define MSTriggeredRerouter_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <vector>
37 #include <utils/common/Command.h>
39 #include "MSTrigger.h"
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class MSNet;
48 class MSLane;
49 class MSRoute;
50 class SUMOVehicle;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
68  public MSTrigger, public MSMoveReminder,
69  public SUMOSAXHandler {
70 public:
78  MSTriggeredRerouter(const std::string& id,
79  const std::vector<MSEdge*>& edges,
80  SUMOReal prob, const std::string& file, bool off);
81 
82 
84  virtual ~MSTriggeredRerouter();
85 
86 
91  struct RerouteInterval {
97  std::vector<MSEdge*> closed;
102  };
103 
119 
121  bool hasCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
122 
124  const RerouteInterval& getCurrentReroute(SUMOTime time, SUMOVehicle& veh) const;
125 
127  bool hasCurrentReroute(SUMOTime time) const;
128 
130  const RerouteInterval& getCurrentReroute(SUMOTime time) const;
131 
133  void setUserMode(bool val);
134 
137 
139  bool inUserMode() const;
140 
142  SUMOReal getProbability() const;
143 
146 
147 protected:
149 
150 
158  virtual void myStartElement(int element,
159  const SUMOSAXAttributes& attrs);
160 
161 
168  void myEndElement(int element);
170 
171 protected:
173  std::vector<RerouteInterval> myIntervals;
174 
177 
180 
182 
183 
187  std::vector<MSEdge*> myCurrentClosed;
193 
194 
198 
199 private:
202 
205 
206 
207 };
208 
209 
210 #endif
211 
212 /****************************************************************************/
213 
bool hasCurrentReroute(SUMOTime time, SUMOVehicle &veh) const
Returns whether a rerouting definition is valid for the given time and vehicle.
std::vector< MSEdge * > closed
The list of closed edges.
RandomDistributor< MSEdge * > edgeProbs
The distributions of new destinations to use.
SUMOTime myCurrentIntervalBegin
The first and the last time steps of the interval.
Notification
Definition of a vehicle state.
const RerouteInterval & getCurrentReroute(SUMOTime time, SUMOVehicle &veh) const
Returns the rerouting definition valid for the given time and vehicle.
void setUserUsageProbability(SUMOReal prob)
Sets the probability with which a vehicle is rerouted given by the user.
SUMOReal getUserProbability() const
Returns the rerouting probability given by the user.
void setUserMode(bool val)
Sets whether the process is currently steered by the user.
SAX-handler base for SUMO-files.
The simulated network and simulation perfomer.
Definition: MSNet.h:89
SUMOReal myProbability
The probability and the user-given probability.
A road/street connecting two junctions.
Definition: MSEdge.h:73
MSTriggeredRerouter & operator=(const MSTriggeredRerouter &)
Invalidated assignment operator.
void myEndElement(int element)
Called when a closing tag occurs.
An abstract device that changes the state of the micro simulation.
Definition: MSTrigger.h:48
Representation of a vehicle.
Definition: SUMOVehicle.h:63
Encapsulated SAX-Attributes.
virtual ~MSTriggeredRerouter()
Destructor.
SUMOTime begin
The begin time these definitions are valid.
std::vector< MSEdge * > myCurrentClosed
List of closed edges.
RandomDistributor< const MSRoute * > myCurrentRouteProb
new routes with probabilities
static MSEdge mySpecialDest_keepDestination
special destination values
SUMOReal getProbability() const
Returns the rerouting probability.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
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.
bool inUserMode() const
Returns whether the user is setting the rerouting probability.
SUMOTime end
The end time these definitions are valid.
RandomDistributor< const MSRoute * > routeProbs
The distributions of new routes to use.
std::vector< RerouteInterval > myIntervals
List of rerouting definition intervals.
bool myAmInUserMode
Information whether the current rerouting probability is the user-given.
#define SUMOReal
Definition: config.h:215
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
MSTriggeredRerouter(const std::string &id, const std::vector< MSEdge * > &edges, SUMOReal prob, const std::string &file, bool off)
Constructor.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77