34#include <xercesc/sax/SAXException.hpp>
35#include <xercesc/sax/SAXParseException.hpp>
93 if (oc.
isSet(
"weight-files")) {
96 if (oc.
isSet(
"lane-weight-files")) {
121 for (
int i = numInternalEdges; i < numTotalEdges; i++) {
122 const Dijkstra::EdgeInfo& ei = router.getEdgeInfo(i);
123 if (!ei.edge->isInternal()) {
124 router.compute(ei.edge,
nullptr,
nullptr, 0, into);
125 double fromEffort = router.getEffort(ei.edge,
nullptr, 0);
126 for (
int j = numInternalEdges; j < numTotalEdges; j++) {
127 double heuTT = router.getEdgeInfo(j).effort - fromEffort;
151 const std::string measure = oc.
getString(
"weight-attribute");
152 const std::string routingAlgorithm = oc.
getString(
"routing-algorithm");
153 const double priorityFactor = oc.
getFloat(
"weights.priority-factor");
163 if (measure ==
"traveltime" && priorityFactor == 0) {
164 if (routingAlgorithm ==
"dijkstra") {
166 }
else if (routingAlgorithm ==
"astar") {
173 }
else if (routingAlgorithm ==
"CHWrapper" || routingAlgorithm ==
"CH") {
181 }
else if (routingAlgorithm ==
"CCH") {
199 throw ProcessError(
TLF(
"Unknown routing Algorithm '%'!", routingAlgorithm));
203 if (measure ==
"traveltime") {
209 }
else if (measure ==
"CO") {
210 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO>;
211 }
else if (measure ==
"CO2") {
212 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO2>;
213 }
else if (measure ==
"PMx") {
214 op = &ROEdge::getEmissionEffort<PollutantsInterface::PM_X>;
215 }
else if (measure ==
"HC") {
216 op = &ROEdge::getEmissionEffort<PollutantsInterface::HC>;
217 }
else if (measure ==
"NOx") {
218 op = &ROEdge::getEmissionEffort<PollutantsInterface::NO_X>;
219 }
else if (measure ==
"fuel") {
220 op = &ROEdge::getEmissionEffort<PollutantsInterface::FUEL>;
221 }
else if (measure ==
"electricity") {
222 op = &ROEdge::getEmissionEffort<PollutantsInterface::ELEC>;
223 }
else if (measure ==
"noise") {
229 WRITE_WARNINGF(
TL(
"No weight data was loaded for attribute '%'."), measure);
238 if (oc.
isSet(
"timeline")) {
245 oc.
getInt(
"max-alternatives"), oc.
getBool(
"capacities.default"), net, matrix, *router,
250 router->
reset(&defaultVehicle);
251 const int maxNumThreads = oc.
getInt(
"routing-threads");
252 while ((
int)net.getThreadPool().size() < maxNumThreads) {
253 new RONet::WorkerThread(net.getThreadPool(), provider);
256 std::string assignMethod = oc.
getString(
"assignment-method");
257 if (assignMethod ==
"UE") {
258 WRITE_WARNING(
TL(
"Deterministic user equilibrium ('UE') is not implemented yet, using stochastic method ('SUE')."));
259 assignMethod =
"SUE";
261 if (assignMethod ==
"incremental") {
262 a.incremental(oc.
getInt(
"max-iterations"), oc.
getBool(
"verbose"));
263 }
else if (assignMethod ==
"SUE") {
264 a.sue(oc.
getInt(
"max-iterations"), oc.
getInt(
"max-inner-iterations"),
269 if (dev !=
nullptr) {
270 std::vector<std::string> tazParamKeys;
271 if (oc.
isSet(
"taz-param")) {
274 std::map<SUMOTime, std::string> sortedOut;
278 if (c->begin >= end || c->end <= begin ||
279 c->pathsVector.empty() || c->pathsVector.front()->getEdgeVector().empty()) {
282 if (lastEnd >= 0 && lastEnd <= c->begin) {
283 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
288 if (c->departures.empty()) {
291 const int numVehs = int(c->vehicleNumber * (
double)(e - b) / (
double)(c->end - c->begin));
298 for (
const std::shared_ptr<RORoute>& r : c->pathsVector) {
299 r->setCosts(router->
recomputeCosts(r->getEdgeVector(), &defaultVehicle, begin));
300 r->writeXMLDefinition(od,
nullptr,
true,
true,
false,
false);
306 const bool ignoreType = oc.
getBool(
"ignore-vehicle-type");
307 for (
auto deps : c->departures) {
308 if (deps.first >= end || deps.first < begin) {
311 const std::string routeDistId = c->origin +
"_" + c->destination +
"_" +
time2string(c->begin) +
"_" +
time2string(c->end);
317 for (
const std::shared_ptr<RORoute>& r : c->pathsVector) {
318 r->setCosts(router->
recomputeCosts(r->getEdgeVector(), &defaultVehicle, begin));
319 r->writeXMLDefinition(od,
nullptr,
true,
true,
false,
false);
322 if (!tazParamKeys.empty()) {
324 if (tazParamKeys.size() > 1) {
333 if (c->end > lastEnd) {
337 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
363 RONet* net =
nullptr;
384 if (oc.
isSet(
"all-pairs-output")) {
390 std::cout <<
"Success." << std::endl;
418 }
catch (XERCES_CPP_NAMESPACE::SAXParseException& e) {
421 }
catch (XERCES_CPP_NAMESPACE::SAXException& e) {
429 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
439 std::cout <<
"Success." << std::endl;
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
CCHGraph< ROEdge, ROVehicle > ROCCHGraph
the ROEdge instantiation of the CCH graph mapping
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.
Metric-independent RoutingKit CCH topology over the PURE road graph.
Contraction-hierarchy router over the edge graph mapped by GRAPH.
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 & 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.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false, const bool escape=false)
writes a named attribute
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.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="", const int maximumDepth=2)
Creates the device using the output definition stored in the named option.
static void reset(const ROVehicle *veh)
the edge weights changed behind the metrics (marouter after an assignment iteration,...
static void init(const ROCCHGraph *graph, ROCCHGraph::EffortOperation effort, SUMOTime begin, SUMOTime weightPeriod)
install the shared graph, effort function and weight-period grid (call once, before routing); weightP...
static const RoutingKit::CustomizableContractionHierarchyMetric * get(SUMOVehicleClass vClass, SUMOTime time, const ROVehicle *veh)
the metric for the vehicle's type at a query time, built on first use; matches CCHRouter::MetricProvi...
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 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 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 std::string transcode(const XMLCh *const data, int length=-1)
converts a 0-terminated XMLCh* array (usually UTF-16, stemming from Xerces) into std::string in UTF-8
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.