34#include <xercesc/sax/SAXException.hpp>
35#include <xercesc/sax/SAXParseException.hpp>
91 if (oc.
isSet(
"weight-files")) {
94 if (oc.
isSet(
"lane-weight-files")) {
119 for (
int i = numInternalEdges; i < numTotalEdges; i++) {
120 const Dijkstra::EdgeInfo& ei = router.getEdgeInfo(i);
121 if (!ei.edge->isInternal()) {
122 router.compute(ei.edge,
nullptr,
nullptr, 0, into);
123 double fromEffort = router.getEffort(ei.edge,
nullptr, 0);
124 for (
int j = numInternalEdges; j < numTotalEdges; j++) {
125 double heuTT = router.getEdgeInfo(j).effort - fromEffort;
149 const std::string measure = oc.
getString(
"weight-attribute");
150 const std::string routingAlgorithm = oc.
getString(
"routing-algorithm");
151 const double priorityFactor = oc.
getFloat(
"weights.priority-factor");
161 if (measure ==
"traveltime" && priorityFactor == 0) {
162 if (routingAlgorithm ==
"dijkstra") {
164 }
else if (routingAlgorithm ==
"astar") {
171 }
else if (routingAlgorithm ==
"CHWrapper" || routingAlgorithm ==
"CH") {
180 throw ProcessError(
TLF(
"Unknown routing Algorithm '%'!", routingAlgorithm));
184 if (measure ==
"traveltime") {
190 }
else if (measure ==
"CO") {
191 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO>;
192 }
else if (measure ==
"CO2") {
193 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO2>;
194 }
else if (measure ==
"PMx") {
195 op = &ROEdge::getEmissionEffort<PollutantsInterface::PM_X>;
196 }
else if (measure ==
"HC") {
197 op = &ROEdge::getEmissionEffort<PollutantsInterface::HC>;
198 }
else if (measure ==
"NOx") {
199 op = &ROEdge::getEmissionEffort<PollutantsInterface::NO_X>;
200 }
else if (measure ==
"fuel") {
201 op = &ROEdge::getEmissionEffort<PollutantsInterface::FUEL>;
202 }
else if (measure ==
"electricity") {
203 op = &ROEdge::getEmissionEffort<PollutantsInterface::ELEC>;
204 }
else if (measure ==
"noise") {
210 WRITE_WARNINGF(
TL(
"No weight data was loaded for attribute '%'."), measure);
219 if (oc.
isSet(
"timeline")) {
226 oc.
getInt(
"max-alternatives"), oc.
getBool(
"capacities.default"), net, matrix, *router,
231 router->
reset(&defaultVehicle);
232 const int maxNumThreads = oc.
getInt(
"routing-threads");
233 while ((
int)net.getThreadPool().size() < maxNumThreads) {
234 new RONet::WorkerThread(net.getThreadPool(), provider);
237 std::string assignMethod = oc.
getString(
"assignment-method");
238 if (assignMethod ==
"UE") {
239 WRITE_WARNING(
TL(
"Deterministic user equilibrium ('UE') is not implemented yet, using stochastic method ('SUE')."));
240 assignMethod =
"SUE";
242 if (assignMethod ==
"incremental") {
243 a.incremental(oc.
getInt(
"max-iterations"), oc.
getBool(
"verbose"));
244 }
else if (assignMethod ==
"SUE") {
245 a.sue(oc.
getInt(
"max-iterations"), oc.
getInt(
"max-inner-iterations"),
250 if (dev !=
nullptr) {
251 std::vector<std::string> tazParamKeys;
252 if (oc.
isSet(
"taz-param")) {
255 std::map<SUMOTime, std::string> sortedOut;
259 if (c->begin >= end || c->end <= begin ||
260 c->pathsVector.empty() || c->pathsVector.front()->getEdgeVector().empty()) {
263 if (lastEnd >= 0 && lastEnd <= c->begin) {
264 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
269 if (c->departures.empty()) {
272 const int numVehs = int(c->vehicleNumber * (
double)(e - b) / (
double)(c->end - c->begin));
279 for (
RORoute*
const r : c->pathsVector) {
280 r->setCosts(router->
recomputeCosts(r->getEdgeVector(), &defaultVehicle, begin));
281 r->writeXMLDefinition(od,
nullptr,
true,
true,
false,
false);
287 const bool ignoreType = oc.
getBool(
"ignore-vehicle-type");
288 for (
auto deps : c->departures) {
289 if (deps.first >= end || deps.first < begin) {
292 const std::string routeDistId = c->origin +
"_" + c->destination +
"_" +
time2string(c->begin) +
"_" +
time2string(c->end);
298 for (
RORoute*
const r : c->pathsVector) {
299 r->setCosts(router->
recomputeCosts(r->getEdgeVector(), &defaultVehicle, begin));
300 r->writeXMLDefinition(od,
nullptr,
true,
true,
false,
false);
303 if (!tazParamKeys.empty()) {
305 if (tazParamKeys.size() > 1) {
314 if (c->end > lastEnd) {
318 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
344 RONet* net =
nullptr;
365 if (oc.
isSet(
"all-pairs-output")) {
371 std::cout <<
"Success." << std::endl;
399 }
catch (XERCES_CPP_NAMESPACE::SAXParseException& e) {
402 }
catch (XERCES_CPP_NAMESPACE::SAXException& e) {
410 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
420 std::cout <<
"Success." << std::endl;
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
std::vector< const ROEdge * > ConstROEdgeVector
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 std::string DEFAULT_VTYPE_ID
@ SVC_IGNORING
vehicles ignoring classes
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_FLOW
a flow definition using from and to edges or a route
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
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.
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
virtual void clear(bool resetInformed=true)
Clears information whether an error occurred previously and print aggregated message summary.
A container for districts.
void makeDistricts(const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > &districts)
create districts from description
An O/D (origin/destination) matrix.
const std::vector< ODCell * > & getCells()
double getNumLoaded() const
Returns the number of loaded vehicles.
void applyCurve(const Distribution_Points &ps)
Splits the stored cells dividing them on the given time line.
Distribution_Points parseTimeLine(const std::vector< std::string > &def, bool timelineDayInHours)
split the given timeline
void writeDefaultAttrs(OutputDevice &dev, const bool noVtype, const ODCell *const cell)
Helper function for flow and trip output writing the depart and arrival attributes.
SUMOTime getBegin() const
void loadMatrix(OptionsCont &oc)
read a matrix in one of several formats
void loadRoutes(OptionsCont &oc, SUMOSAXHandler &handler)
read SUMO routes
double getNumDiscarded() const
Returns the number of discarded vehicles.
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)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
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.
An output device that encapsulates an ofstream.
std::string getString() const
Returns the current content as a string.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
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)
double getSpeedLimit() const
Returns the speed allowed on this edge.
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
double getLength() const
Returns the length of the edge.
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.
virtual void loadNet(RONet &toFill, ROAbstractEdgeBuilder &eb)
Loads the network.
static double getPenalizedTT(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the traveltime on an edge including penalties.
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.
Parser and container for routes during their loading.
The router's network representation.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
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.
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
OutputDevice * getRouteOutput(const bool alternative=false)
bool hasPermissions() const
const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > & getDistricts() const
Retrieves all TAZ (districts) from the network.
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
bool hasLoadedEffort() const
whether efforts were loaded from file
A complete router's route.
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.
virtual void reset(const V *const vehicle)
reset internal caches, used by CHRouter
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
Structure representing possible vehicle parameter.
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 computeAllPairs(RONet &net, OptionsCont &oc)
void computeRoutes(RONet &net, OptionsCont &oc, ODMatrix &matrix)
double getTravelTime(const ROEdge *const edge, const ROVehicle *const, double)
A single O/D-matrix cell.