45 #ifdef CHECK_MEMORY_LEAKS
47 #endif // CHECK_MEMORY_LEAKS
74 oc.
addSynonyme(
"device.rerouting.period",
"device.routing.period",
true);
75 oc.
addDescription(
"device.rerouting.period",
"Routing",
"The period with which the vehicle shall be rerouted");
78 oc.
addSynonyme(
"device.rerouting.pre-period",
"device.routing.pre-period",
true);
79 oc.
addDescription(
"device.rerouting.pre-period",
"Routing",
"The rerouting period before depart");
82 oc.
addSynonyme(
"device.rerouting.adaptation-weight",
"device.routing.adaptation-weight",
true);
83 oc.
addDescription(
"device.rerouting.adaptation-weight",
"Routing",
"The weight of prior edge weights");
86 oc.
addSynonyme(
"device.rerouting.adaptation-interval",
"device.routing.adaptation-interval",
true);
87 oc.
addDescription(
"device.rerouting.adaptation-interval",
"Routing",
"The interval for updating the edge weights");
90 oc.
addSynonyme(
"device.rerouting.with-taz",
"device.routing.with-taz",
true);
91 oc.
addDescription(
"device.rerouting.with-taz",
"Routing",
"Use zones (districts) as routing end points");
94 oc.
addDescription(
"device.rerouting.init-with-loaded-weights",
"Routing",
"Use given weight files for initializing edge weights");
105 if (!needRerouting && oc.
getFloat(
"device.rerouting.probability") == 0 && !oc.
isSet(
"device.rerouting.explicit")) {
117 into.push_back(device);
121 const bool useLoaded = oc.
getBool(
"device.rerouting.init-with-loaded-weights");
123 for (std::vector<MSEdge*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
130 myEdgeEfforts[(*i)->getNumericalID()] = (*i)->getCurrentTravelTime();
161 :
MSDevice(holder, id), myPeriod(period), myPreInsertionPeriod(preInsertionPeriod), myRerouteCommand(0) {
207 if (source && dest) {
208 const std::pair<const MSEdge*, const MSEdge*> key = std::make_pair(source, dest);
240 std::map<std::pair<const MSEdge*, const MSEdge*>,
const MSRoute*>::iterator it =
myCachedRoutes.begin();
242 it->second->release();
247 for (std::vector<MSEdge*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
248 const int id = (*i)->getNumericalID();
259 if (routingAlgorithm ==
"dijkstra") {
262 }
else if (routingAlgorithm ==
"astar") {
266 throw ProcessError(
"Unknown routing Algorithm '" + routingAlgorithm +
"'!");
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
const int VEHPARS_FORCE_REROUTE
static size_t numericalDictSize()
Returns the number of edges with a numerical id.
virtual const MSRoute & getRoute() const =0
Returns the current route.
static SUMOTime adaptEdgeEfforts(SUMOTime currentTime)
Adapt edge efforts by the current edge states.
MSEventControl & getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
SUMOVehicle & myHolder
The vehicle that stores the device.
static SUMOTime myAdaptationInterval
Information which weight prior edge efforts have.
virtual void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, bool withTaz=false)=0
Performs a rerouting using the given router.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
SUMOTime preInsertionReroute(SUMOTime currentTime)
Performs rerouting at insertion into the network.
Notification
Definition of a vehicle state.
A device that performs vehicle rerouting based on current edge speeds.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
static Command * myEdgeWeightSettingCommand
The weights adaptation/overwriting command.
Base (microsim) event class.
static OptionsCont & getOptions()
Retrieves the options.
std::string toTaz
The vehicle's destination zone (district)
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
A road/street connecting two junctions.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
static bool myWithTaz
whether taz shall be used at initial rerouting
Representation of a vehicle.
bool wasSet(int what) const
Returns whether the given parameter was set.
static SUMOReal getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, SUMOReal t)
Returns the travel time to pass an edge.
static std::map< std::pair< const MSEdge *, const MSEdge * >, const MSRoute * > myCachedRoutes
The container of pre-calculated routes.
SUMOTime depart
The vehicle's departure time.
A wrapper for a Command function.
SUMOTime string2time(const std::string &r)
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc)
Adds common command options that allow to assign devices to vehicles.
std::string fromTaz
The vehicle's origin zone (district)
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
void addReference() const
increments the reference counter for the route
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
static SUMOReal getEffort(const MSEdge *const e, const SUMOVehicle *const v, SUMOReal t)
Returns the effort to pass an edge.
Abstract in-vehicle device.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, SUMOVehicle &v)
Determines whether a vehicle should get a certain device.
MSEventControl & getInsertionEvents()
Returns the event control for insertion events.
The vehicle has departed (was inserted into the network)
static std::vector< SUMOReal > myEdgeEfforts
The container of edge efforts.
int getNumericalID() const
Returns the numerical id of the edge.
void deschedule()
Marks this Command as being descheduled.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouter
The router to use.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
A storage for options typed value containers)
virtual bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0)=0
Replaces the current route by the given one.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Computes a new route on vehicle insertion.
const std::vector< MSEdge * > & getEdges() const
Returns loaded edges.
~MSDevice_Routing()
Destructor.
Patch the time in a way that it is at least as high as the simulation begin time. ...
static void cleanup()
deletes the router instance
SUMOReal getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
MSEdgeControl & getEdgeControl()
Returns the edge control.
static SUMOReal myAdaptationWeight
Information which weight prior edge efforts have.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
MSEventControl & getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
static SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouter()
get the router, initialize on first use
virtual const std::string & getID() const =0
Get the vehicle's ID.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.