54 oc.
addSynonyme(
"device.rerouting.period",
"device.routing.period",
true);
55 oc.
addDescription(
"device.rerouting.period",
"Routing",
"The period with which the vehicle shall be rerouted");
58 oc.
addSynonyme(
"device.rerouting.pre-period",
"device.routing.pre-period",
true);
59 oc.
addDescription(
"device.rerouting.pre-period",
"Routing",
"The rerouting period before depart");
62 oc.
addSynonyme(
"device.rerouting.adaptation-weight",
"device.routing.adaptation-weight",
true);
63 oc.
addDescription(
"device.rerouting.adaptation-weight",
"Routing",
"The weight of prior edge weights for exponential moving average");
66 oc.
addSynonyme(
"device.rerouting.adaptation-steps",
"device.routing.adaptation-steps",
true);
67 oc.
addDescription(
"device.rerouting.adaptation-steps",
"Routing",
"The number of steps for moving average weight of prior edge weights");
70 oc.
addSynonyme(
"device.rerouting.adaptation-interval",
"device.routing.adaptation-interval",
true);
71 oc.
addDescription(
"device.rerouting.adaptation-interval",
"Routing",
"The interval for updating the edge weights");
74 oc.
addSynonyme(
"device.rerouting.with-taz",
"device.routing.with-taz",
true);
75 oc.
addSynonyme(
"device.rerouting.with-taz",
"with-taz");
76 oc.
addDescription(
"device.rerouting.with-taz",
"Routing",
"Use zones (districts) as routing start- and endpoints");
79 oc.
addDescription(
"device.rerouting.init-with-loaded-weights",
"Routing",
"Use weight files given with option --weight-files for initializing edge weights");
82 oc.
addDescription(
"device.rerouting.threads",
"Routing",
"The number of parallel execution threads used for rerouting");
85 oc.
addDescription(
"device.rerouting.synchronize",
"Routing",
"Let rerouting happen at the same time for all vehicles");
88 oc.
addDescription(
"device.rerouting.output",
"Routing",
"Save adapting weights to FILE");
95 if (!oc.
isDefault(
"device.rerouting.adaptation-steps") && !oc.
isDefault(
"device.rerouting.adaptation-weight")) {
96 WRITE_ERROR(
"Only one of the options 'device.rerouting.adaptation-steps' or 'device.rerouting.adaptation-weight' may be given.");
99 if (oc.
getFloat(
"weights.random-factor") < 1) {
100 WRITE_ERROR(
"weights.random-factor cannot be less than 1");
104 WRITE_ERROR(
"Negative value for device.rerouting.adaptation-interval!");
107 if (oc.
getFloat(
"device.rerouting.adaptation-weight") < 0. ||
108 oc.
getFloat(
"device.rerouting.adaptation-weight") > 1.) {
109 WRITE_ERROR(
"The value for device.rerouting.adaptation-weight must be between 0 and 1!");
113 if (oc.
getInt(
"device.rerouting.threads") > 1) {
114 WRITE_ERROR(
"Parallel routing is only possible when compiled with Fox.");
199 if (cached !=
nullptr && cached->
size() > 2) {
236 const std::string edgeID = key.substr(5);
238 if (edge ==
nullptr) {
242 }
else if (key ==
"period") {
258 const std::string edgeID = key.substr(5);
260 if (edge ==
nullptr) {
264 }
else if (key ==
"period") {
269 }
else if (oldPeriod <= 0) {
283 std::vector<std::string> internals;
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key ...
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static void setEdgeTravelTime(const MSEdge *const edge, const double travelTime)
adapt the known travel time for an edge
const int VEHPARS_FORCE_REROUTE
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
virtual const std::string & getID() const =0
Get the vehicle's ID.
virtual const MSRoute & getRoute() const =0
Returns the current route.
static void initWeightUpdate()
intialize period edge weight update
SUMOTime myLastRouting
The last time a routing took place.
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
Notification
Definition of a vehicle state.
SUMOVehicle & myHolder
The vehicle that stores the device.
std::string time2string(SUMOTime t)
const std::string deviceName() const
return the name for this type of device
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
virtual bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)=0
Replaces the current route by the given one.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
void saveState(OutputDevice &out) const
Saves the state of the device.
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...
const MSEdge * getLastEdge() const
returns the destination edge
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
const std::string & getID() const
Returns the id.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
int size() const
Returns the number of edges to pass.
static void initEdgeWeights()
initialize the edge weights if not done before
static OptionsCont & getOptions()
Retrieves the options.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
A road/street connecting two junctions.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
void reroute(const SUMOTime currentTime, const bool onInit=false)
initiate the rerouting, create router / thread pool on first use
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
static bool hasEdgeUpdates()
returns whether any routing actions take place
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static const MSRoute * getCachedRoute(const std::pair< const MSEdge *, const MSEdge *> &key)
return the cached route or nullptr on miss
Representation of a vehicle.
Encapsulated SAX-Attributes.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static void reroute(SUMOVehicle &vehicle, const SUMOTime currentTime, const bool onInit)
initiate the rerouting, create router / thread pool on first use
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static SUMOTime getLastAdaptation()
Information when the last edge weight adaptation occurred.
The vehicle has departed (was inserted into the network)
Representation of a vehicle or person.
bool isTazConnector() const
void deschedule()
Marks this Command as being descheduled.
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.
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
A storage for options typed value containers)
Abstract in-vehicle device.
MSEventControl * getInsertionEvents()
Returns the event control for insertion events.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
bool wasSet(int what) const
Returns whether the given parameter was set.
~MSDevice_Routing()
Destructor.
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static bool checkOptions(OptionsCont &oc)
checks MSDevice_Routing-options
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into)
Build devices for the given vehicle, if needed.
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
Representation of a lane in the micro simulation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...
SUMOTime preInsertionReroute(const SUMOTime currentTime)
Performs rerouting before insertion into the network.