33#include <xercesc/sax/SAXException.hpp>
34#include <xercesc/sax/SAXParseException.hpp>
82 if (oc.
isSet(
"weight-files")) {
85 if (oc.
isSet(
"lane-weight-files")) {
101 const std::string measure = oc.
getString(
"weight-attribute");
102 const std::string routingAlgorithm = oc.
getString(
"routing-algorithm");
103 const double priorityFactor = oc.
getFloat(
"weights.priority-factor");
108 if (oc.
isSet(
"restriction-params") &&
109 (routingAlgorithm ==
"CH" || routingAlgorithm ==
"CHWrapper")) {
110 throw ProcessError(
TLF(
"Routing algorithm '%' does not support restriction-params", routingAlgorithm));
113 if (measure ==
"traveltime" && priorityFactor == 0) {
114 if (routingAlgorithm ==
"dijkstra") {
116 }
else if (routingAlgorithm ==
"astar") {
118 std::shared_ptr<const AStar::LookupTable> lookup;
119 if (oc.
isSet(
"astar.all-distances")) {
121 }
else if (oc.
isSet(
"astar.landmark-distances")) {
126 std::vector<ReversedEdge<ROEdge, ROVehicle>*> reversed;
128 reversed.push_back(edge->getReversedRoutingEdge());
136 lookup = std::make_shared<const AStar::LMLT>(oc.
getString(
"astar.landmark-distances"),
ROEdge::getAllEdges(), &forward, &backward, &defaultVehicle,
137 oc.
isSet(
"astar.save-landmark-distances") ? oc.
getString(
"astar.save-landmark-distances") :
"", oc.
getInt(
"routing-threads"), mapMatcher);
146 }
else if (routingAlgorithm ==
"CHWrapper" || routingAlgorithm ==
"CH") {
154 }
else if (routingAlgorithm ==
"arcflag") {
156 constexpr auto NUMBER_OF_LEVELS = 5;
159 partition->
init(&defaultVehicle);
166 throw ProcessError(
TLF(
"Unknown routing Algorithm '%'!", routingAlgorithm));
169 if (measure ==
"traveltime") {
173 }
else if (measure ==
"CO") {
174 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO>;
175 }
else if (measure ==
"CO2") {
176 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO2>;
177 }
else if (measure ==
"PMx") {
178 op = &ROEdge::getEmissionEffort<PollutantsInterface::PM_X>;
179 }
else if (measure ==
"HC") {
180 op = &ROEdge::getEmissionEffort<PollutantsInterface::HC>;
181 }
else if (measure ==
"NOx") {
182 op = &ROEdge::getEmissionEffort<PollutantsInterface::NO_X>;
183 }
else if (measure ==
"fuel") {
184 op = &ROEdge::getEmissionEffort<PollutantsInterface::FUEL>;
185 }
else if (measure ==
"electricity") {
186 op = &ROEdge::getEmissionEffort<PollutantsInterface::ELEC>;
187 }
else if (measure ==
"noise") {
193 WRITE_WARNINGF(
TL(
"No weight data was loaded for attribute '%'."), measure);
204 oc.
isSet(
"restriction-params"),
205 oc.
getFloat(
"railway.max-train-length"));
230 oc.
setApplicationDescription(
TL(
"Shortest path router and DUE computer for the microscopic, multi-modal traffic simulation SUMO."));
233 RONet* net =
nullptr;
246 if (oc.
getInt(
"routing-threads") > 1) {
263 }
catch (XERCES_CPP_NAMESPACE::SAXParseException& e) {
266 }
catch (XERCES_CPP_NAMESPACE::SAXException& e) {
274 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
280 }
catch (
const std::exception& e) {
281 if (std::string(e.what()) != std::string(
"")) {
294 std::cout <<
"Success." << std::endl;
#define WRITE_WARNINGF(...)
IntermodalRouter< ROEdge, ROLane, RONode, ROVehicle > ROIntermodalRouter
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
const std::string DEFAULT_VTYPE_ID
@ SVC_IGNORING
vehicles ignoring classes
double gWeightsRandomFactor
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Computes the shortest path through a network using the A* algorithm.
Computes the shortest path through a contracted network.
Computes the shortest path through a contracted network.
Computes the shortest path through a network using the Dijkstra algorithm.
The edge type representing backward edges with flipped nodes.
Partitions the router's network wrt a k-d tree subdivision scheme.
void init(const V *const vehicle)
Initialize the k-d tree wrt to the given vehicle's permissions.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
static void initOutputOptions()
init output options
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
static MsgHandler * create(MsgType type)
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
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)
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Interface for building instances of duarouter-edges.
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter.
A basic edge for routing applications.
static double getStoredEffort(const ROEdge *const edge, const ROVehicle *const, double time)
static bool initPriorityFactor(double priorityFactor)
initialize priority factor range
static double getTravelTimeStaticPriorityFactor(const ROEdge *const edge, const ROVehicle *const veh, double time)
Return traveltime weighted by edge priority (scaled penalty for low-priority edges)
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
static double getTravelTimeStaticRandomized(const ROEdge *const edge, const ROVehicle *const veh, double time)
static void setGlobalOptions(const bool interpolate)
static double getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the travel time for the given edge.
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
bool loadWeights(RONet &net, const std::string &optionName, const std::string &measure, const bool useLanes, const bool boundariesOverride)
Loads the net weights.
SUMORouteHandler * getRouteHandler()
void processRoutes(const SUMOTime start, const SUMOTime end, const SUMOTime increment, RONet &net, const RORouterProvider &provider)
Loads routes from all previously build route loaders.
virtual void loadNet(RONet &toFill, ROAbstractEdgeBuilder &eb)
Loads the network.
void openRoutes(RONet &net)
Builds and opens all route loaders.
The router's network representation.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
bool hasBidiEdges() const
return whether the network contains bidirectional rail edges
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
static void adaptIntermodalRouter(ROIntermodalRouter &router)
bool hasPermissions() const
bool hasLoadedEffort() const
whether efforts were loaded from file
A vehicle as used by router.
static void initRandGlobal(SumoRNG *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
the edge type representing backward edges
IntermodalRouter< E, L, N, V > & getIntermodalRouter() const
Structure representing possible vehicle parameter.
static int parseCarWalkTransfer(const OptionsCont &oc, const bool hasTaxi=false)
static std::string transcode(const XMLCh *const data)
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8
static void close()
Closes all of an applications subsystems.
static bool checkOptions(OptionsCont &oc)
checks shared options and sets StdDefs
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
static void init()
Initialises the xml-subsystem.
int main(int argc, char **argv)
void initNet(RONet &net, ROLoader &loader, OptionsCont &oc)
void computeRoutes(RONet &net, ROLoader &loader, OptionsCont &oc)