52 oc.
addSynonyme(
"device.rerouting.period",
"device.routing.period",
true);
53 oc.
addDescription(
"device.rerouting.period",
"Routing",
TL(
"The period with which the vehicle shall be rerouted"));
56 oc.
addSynonyme(
"device.rerouting.pre-period",
"device.routing.pre-period",
true);
57 oc.
addDescription(
"device.rerouting.pre-period",
"Routing",
TL(
"The rerouting period before depart"));
60 oc.
addSynonyme(
"device.rerouting.adaptation-weight",
"device.routing.adaptation-weight",
true);
61 oc.
addDescription(
"device.rerouting.adaptation-weight",
"Routing",
TL(
"The weight of prior edge weights for exponential moving average"));
64 oc.
addSynonyme(
"device.rerouting.adaptation-steps",
"device.routing.adaptation-steps",
true);
65 oc.
addDescription(
"device.rerouting.adaptation-steps",
"Routing",
TL(
"The number of steps for moving average weight of prior edge weights"));
68 oc.
addSynonyme(
"device.rerouting.adaptation-interval",
"device.routing.adaptation-interval",
true);
69 oc.
addDescription(
"device.rerouting.adaptation-interval",
"Routing",
TL(
"The interval for updating the edge weights"));
72 oc.
addSynonyme(
"device.rerouting.with-taz",
"device.routing.with-taz",
true);
73 oc.
addSynonyme(
"device.rerouting.with-taz",
"with-taz");
74 oc.
addDescription(
"device.rerouting.with-taz",
"Routing",
TL(
"Use zones (districts) as routing start- and endpoints"));
77 oc.
addDescription(
"device.rerouting.mode",
"Routing",
TL(
"Set routing flags (8 ignores temporary blockages)"));
80 oc.
addDescription(
"device.rerouting.init-with-loaded-weights",
"Routing",
TL(
"Use weight files given with option --weight-files for initializing edge weights"));
83 oc.
addSynonyme(
"device.rerouting.threads",
"routing-threads");
84 oc.
addDescription(
"device.rerouting.threads",
"Routing",
TL(
"The number of parallel execution threads used for rerouting"));
87 oc.
addDescription(
"device.rerouting.synchronize",
"Routing",
TL(
"Let rerouting happen at the same time for all vehicles"));
90 oc.
addDescription(
"device.rerouting.railsignal",
"Routing",
TL(
"Allow rerouting triggered by rail signals."));
93 oc.
addDescription(
"device.rerouting.bike-speeds",
"Routing",
TL(
"Compute separate average speeds for bicycles"));
96 oc.
addDescription(
"device.rerouting.output",
"Routing",
TL(
"Save adapting weights to FILE"));
103 if (!oc.
isDefault(
"device.rerouting.adaptation-steps") && !oc.
isDefault(
"device.rerouting.adaptation-weight")) {
104 WRITE_ERROR(
TL(
"Only one of the options 'device.rerouting.adaptation-steps' or 'device.rerouting.adaptation-weight' may be given."));
107 if (oc.
getFloat(
"weights.random-factor") < 1) {
108 WRITE_ERROR(
TL(
"weights.random-factor cannot be less than 1"));
112 WRITE_ERROR(
TL(
"Negative value for device.rerouting.adaptation-interval!"));
115 if (oc.
getFloat(
"device.rerouting.adaptation-weight") < 0. ||
116 oc.
getFloat(
"device.rerouting.adaptation-weight") > 1.) {
117 WRITE_ERROR(
TL(
"The value for device.rerouting.adaptation-weight must be between 0 and 1!"));
121 if (oc.
getInt(
"device.rerouting.threads") > 1) {
122 WRITE_ERROR(
TL(
"Parallel routing is only possible when compiled with Fox."));
126 if (oc.
getInt(
"threads") > 1 && oc.
getInt(
"device.rerouting.threads") > 1 && oc.
getInt(
"threads") != oc.
getInt(
"device.rerouting.threads")) {
127 WRITE_WARNING(
TL(
"Adapting number of routing threads to number of simulation threads."));
143 oc.
isDefault(
"device.rerouting.probability") &&
161 myPreInsertionPeriod(preInsertionPeriod),
164 myRerouteCommand(nullptr),
165 myRerouteRailSignal(holder.getBoolParam(
"device.rerouting.railsignal", true)),
166 myLastLaneEntryTime(-1),
167 myRerouteAfterStop(false),
255 if (cached !=
nullptr && cached->size() > 2) {
305 const std::string edgeID = key.substr(5);
307 if (edge ==
nullptr) {
311 }
else if (key ==
"period") {
327 const std::string edgeID = key.substr(5);
329 if (edge ==
nullptr) {
333 }
else if (key ==
"period") {
347 std::vector<std::string> internals;
#define WRITE_WARNING(msg)
std::shared_ptr< const MSRoute > ConstMSRoutePtr
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const long long int VEHPARS_FORCE_REROUTE
@ BEST_FREE
The least occupied lane from best lanes.
@ SUMO_ATTR_STATE
The state of a link.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A device that performs vehicle rerouting based on current edge speeds.
const std::string deviceName() const
return the name for this type of device
void rebuildRerouteCommand()
rebuild reroute command according to period
void saveState(OutputDevice &out) const
Saves the state of the device.
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
bool myActive
Whether the equipped vehicle may perform rerouting.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
void reroute(const SUMOTime currentTime, const bool onInit=false)
initiate the rerouting, create router / thread pool on first use
static bool checkOptions(OptionsCont &oc)
checks MSDevice_Routing-options
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
~MSDevice_Routing()
Destructor.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
SUMOTime myLastLaneEntryTime
the previous time that a vehicle entered a lane
SUMOTime myLastRouting
The last time a routing took place.
void notifyStopEnded()
called to do the rerouting we missed whuile stopping
bool myRerouteAfterStop
Whether the equipped vehicle missed a reroute while stopping and should do so after the stop has ende...
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
SUMOTime preInsertionReroute(const SUMOTime currentTime)
Performs rerouting before insertion into the network.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
A road/street connecting two junctions.
bool isTazConnector() const
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....
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static double gWeightsSeparateTurns
Whether turning specific weights are estimated (and how much)
Representation of a lane in the micro simulation.
MSEdge & getEdge() const
Returns the lane's edge.
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
MSEventControl * getInsertionEvents()
Returns the event control for insertion events.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
const MSEdge * getLastEdge() const
returns the destination edge
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
static void setEdgeTravelTime(const MSEdge *const edge, const double travelTime)
adapt the known travel time for an edge
static void reroute(SUMOVehicle &vehicle, const SUMOTime currentTime, const std::string &info, const bool onInit=false, const bool silent=false, const MSEdgeVector &prohibited=MSEdgeVector())
initiate the rerouting, create router / thread pool on first use
static SUMOTime getLastAdaptation()
Information when the last edge weight adaptation occurred.
static bool withTaz()
whether taz-routing is enabled
static bool hasEdgeUpdates()
returns whether any edge weight updates will take place
static void addEdgeTravelTime(const MSEdge &edge, const SUMOTime travelTime)
record actual travel time for an edge
static void initWeightUpdate()
intialize period edge weight update
static void initEdgeWeights(SUMOVehicleClass svc)
initialize the edge weights if not done before
static MSVehicleRouter & getRouterTT(const int rngIndex, SUMOVehicleClass svc, const MSEdgeVector &prohibited=MSEdgeVector())
return the vehicle router instance
static ConstMSRoutePtr getCachedRoute(const std::pair< const MSEdge *, const MSEdge * > &key)
return the cached route or nullptr on miss
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void doRegister(const std::string &name, Option *o)
Adds an option under the given name.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
Representation of a vehicle, person, or container.
virtual int getRNGIndex() const =0
SUMOTime getTimeParam(const std::string ¶mName, const bool required=false, const SUMOTime deflt=SUMOTime_MIN) const
Retrieve a time parameter for the traffic object.
virtual bool replaceRoute(ConstMSRoutePtr route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true, std::string *msgReturn=nullptr)=0
Replaces the current route by the given one.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
double getFloatParam(const std::string ¶mName, const bool required=false, const double deflt=INVALID_DOUBLE) const
Retrieve a floating point parameter for the traffic object.
Representation of a vehicle.
virtual bool reroute(SUMOTime t, const std::string &info, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false, const bool silent=false, const MSEdge *sink=nullptr)=0
Performs a rerouting using the given router.
virtual bool isStopped() const =0
Returns whether the vehicle is at a stop and waiting for a person or container to continue.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual bool hasValidRouteStart(std::string &msg)=0
checks wether the vehicle can depart on the first edge
virtual SUMOTime getDepartDelay() const =0
virtual const MSRoute & getRoute() const =0
Returns the current route.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
A wrapper for a Command function.
void deschedule()
Marks this Command as being descheduled.