 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
53 oc.
addSynonyme(
"device.rerouting.period",
"device.routing.period",
true);
54 oc.
addDescription(
"device.rerouting.period",
"Routing",
"The period with which the vehicle shall be rerouted");
57 oc.
addSynonyme(
"device.rerouting.pre-period",
"device.routing.pre-period",
true);
58 oc.
addDescription(
"device.rerouting.pre-period",
"Routing",
"The rerouting period before depart");
61 oc.
addSynonyme(
"device.rerouting.adaptation-weight",
"device.routing.adaptation-weight",
true);
62 oc.
addDescription(
"device.rerouting.adaptation-weight",
"Routing",
"The weight of prior edge weights for exponential moving average");
65 oc.
addSynonyme(
"device.rerouting.adaptation-steps",
"device.routing.adaptation-steps",
true);
66 oc.
addDescription(
"device.rerouting.adaptation-steps",
"Routing",
"The number of steps for moving average weight of prior edge weights");
69 oc.
addSynonyme(
"device.rerouting.adaptation-interval",
"device.routing.adaptation-interval",
true);
70 oc.
addDescription(
"device.rerouting.adaptation-interval",
"Routing",
"The interval for updating the edge weights");
73 oc.
addSynonyme(
"device.rerouting.with-taz",
"device.routing.with-taz",
true);
74 oc.
addSynonyme(
"device.rerouting.with-taz",
"with-taz");
75 oc.
addDescription(
"device.rerouting.with-taz",
"Routing",
"Use zones (districts) as routing start- and endpoints");
78 oc.
addDescription(
"device.rerouting.init-with-loaded-weights",
"Routing",
"Use weight files given with option --weight-files for initializing edge weights");
81 oc.
addDescription(
"device.rerouting.threads",
"Routing",
"The number of parallel execution threads used for rerouting");
84 oc.
addDescription(
"device.rerouting.synchronize",
"Routing",
"Let rerouting happen at the same time for all vehicles");
87 oc.
addDescription(
"device.rerouting.output",
"Routing",
"Save adapting weights to FILE");
94 if (!oc.
isDefault(
"device.rerouting.adaptation-steps") && !oc.
isDefault(
"device.rerouting.adaptation-weight")) {
95 WRITE_ERROR(
"Only one of the options 'device.rerouting.adaptation-steps' or 'device.rerouting.adaptation-weight' may be given.");
98 if (oc.
getFloat(
"weights.random-factor") < 1) {
99 WRITE_ERROR(
"weights.random-factor cannot be less than 1");
103 WRITE_ERROR(
"Negative value for device.rerouting.adaptation-interval!");
106 if (oc.
getFloat(
"device.rerouting.adaptation-weight") < 0. ||
107 oc.
getFloat(
"device.rerouting.adaptation-weight") > 1.) {
108 WRITE_ERROR(
"The value for device.rerouting.adaptation-weight must be between 0 and 1!");
112 if (oc.
getInt(
"device.rerouting.threads") > 1) {
113 WRITE_ERROR(
"Parallel routing is only possible when compiled with Fox.");
117 if (oc.
getInt(
"threads") > 1 && oc.
getInt(
"device.rerouting.threads") > 1 && oc.
getInt(
"threads") != oc.
getInt(
"device.rerouting.threads")) {
118 WRITE_WARNING(
"Adapting number of routing threads to number of simulation threads.");
147 :
MSVehicleDevice(holder, id), myPeriod(period), myPreInsertionPeriod(preInsertionPeriod), myLastRouting(-1), mySkipRouting(-1), myRerouteCommand(nullptr) {
204 if (cached !=
nullptr && cached->
size() > 2) {
247 const std::string edgeID = key.substr(5);
249 if (edge ==
nullptr) {
253 }
else if (key ==
"period") {
269 const std::string edgeID = key.substr(5);
271 if (edge ==
nullptr) {
275 }
else if (key ==
"period") {
280 }
else if (oldPeriod <= 0) {
294 std::vector<std::string> internals;
Representation of a vehicle or person.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
bool wasSet(int what) const
Returns whether the given parameter was set.
virtual SUMOTime getDepartDelay() const =0
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
#define WRITE_WARNING(msg)
Representation of a lane in the micro simulation.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
Static storage of an output device and its base (abstract) implementation.
static SUMOTime getLastAdaptation()
Information when the last edge weight adaptation occurred.
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.
virtual const std::string & getID() const =0
Get the vehicle's ID.
const int VEHPARS_FORCE_REROUTE
~MSDevice_Routing()
Destructor.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void deschedule()
Marks this Command as being descheduled.
const std::string deviceName() const
return the name for this type of device
The least occupied lane from best lanes.
const MSEdge * getLastEdge() const
returns the destination edge
Representation of a vehicle.
SUMOTime myLastRouting
The last time a routing took place.
WrappingCommand< MSDevice_Routing > * myRerouteCommand
The (optional) command responsible for rerouting.
static OptionsCont & getOptions()
Retrieves the options.
SUMOVehicle & myHolder
The vehicle that stores the device.
static void setEdgeTravelTime(const MSEdge *const edge, const double travelTime)
adapt the known travel time for an edge
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const MSRoute & getRoute() const =0
Returns the current route.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
int size() const
Returns the number of edges to pass.
static bool checkOptions(OptionsCont &oc)
checks MSDevice_Routing-options
static void initEdgeWeights()
initialize the edge weights if not done before
void addDescription(const std::string &name, const std::string &subtopic, const std::string &description)
Adds a description for an option.
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass 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 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.
void addSynonyme(const std::string &name1, const std::string &name2, bool isDeprecated=false)
Adds a synonyme for an options name (any order)
void saveState(OutputDevice &out) const
Saves the state of the device.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
void setParameter(const std::string &key, const std::string &value)
try to set the given parameter for this device. Throw exception for unsupported key
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 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.
SUMOTime wrappedRerouteCommandExecute(SUMOTime currentTime)
Performs rerouting after a period.
void doRegister(const std::string &name, Option *v)
Adds an option under the given name.
std::string time2string(SUMOTime t)
A storage for options typed value containers)
A road/street connecting two junctions.
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
The vehicle has departed (was inserted into the network)
SUMOTime string2time(const std::string &r)
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
static void initWeightUpdate()
intialize period edge weight update
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
static bool hasEdgeUpdates()
returns whether any routing actions take place
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
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.
SUMOTime myPreInsertionPeriod
The period with which a vehicle shall be rerouted before insertion.
MSEventControl * getInsertionEvents()
Returns the event control for insertion events.
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Routing-options.
SUMOTime myPeriod
The period with which a vehicle shall be rerouted.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
void reroute(const SUMOTime currentTime, const bool onInit=false)
initiate the rerouting, create router / thread pool on first use
SUMOTime mySkipRouting
The time for which routing may be skipped because we cannot be inserted.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
static const MSRoute * getCachedRoute(const std::pair< const MSEdge *, const MSEdge * > &key)
return the cached route or nullptr on miss
Encapsulated SAX-Attributes.
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
MSDevice_Routing(SUMOVehicle &holder, const std::string &id, SUMOTime period, SUMOTime preInsertionPeriod)
Constructor.
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.
Abstract in-vehicle device.