34 #include <xercesc/sax/SAXException.hpp>
35 #include <xercesc/sax/SAXParseException.hpp>
97 if (oc.
isSet(
"weight-files")) {
100 if (oc.
isSet(
"lane-weight-files")) {
125 for (
int i = numInternalEdges; i < numTotalEdges; i++) {
126 const Dijkstra::EdgeInfo& ei = router.getEdgeInfo(i);
127 if (!ei.edge->isInternal()) {
128 router.compute(ei.edge,
nullptr,
nullptr, 0, into);
129 double fromEffort = router.getEffort(ei.edge,
nullptr, 0);
130 for (
int j = numInternalEdges; j < numTotalEdges; j++) {
131 double heuTT = router.getEdgeInfo(j).effort - fromEffort;
178 const std::string measure = oc.
getString(
"weight-attribute");
179 const std::string routingAlgorithm = oc.
getString(
"routing-algorithm");
180 const double priorityFactor = oc.
getFloat(
"weights.priority-factor");
190 if (measure ==
"traveltime" && priorityFactor == 0) {
191 if (routingAlgorithm ==
"dijkstra") {
193 }
else if (routingAlgorithm ==
"astar") {
195 }
else if (routingAlgorithm ==
"CH") {
200 }
else if (routingAlgorithm ==
"CHWrapper") {
206 begin, end, weightPeriod, oc.
getInt(
"routing-threads"));
208 throw ProcessError(
"Unknown routing Algorithm '" + routingAlgorithm +
"'!");
212 if (measure ==
"traveltime") {
218 }
else if (measure ==
"CO") {
219 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO>;
220 }
else if (measure ==
"CO2") {
221 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO2>;
222 }
else if (measure ==
"PMx") {
223 op = &ROEdge::getEmissionEffort<PollutantsInterface::PM_X>;
224 }
else if (measure ==
"HC") {
225 op = &ROEdge::getEmissionEffort<PollutantsInterface::HC>;
226 }
else if (measure ==
"NOx") {
227 op = &ROEdge::getEmissionEffort<PollutantsInterface::NO_X>;
228 }
else if (measure ==
"fuel") {
229 op = &ROEdge::getEmissionEffort<PollutantsInterface::FUEL>;
230 }
else if (measure ==
"electricity") {
231 op = &ROEdge::getEmissionEffort<PollutantsInterface::ELEC>;
232 }
else if (measure ==
"noise") {
238 WRITE_WARNING(
"No weight data was loaded for attribute '" + measure +
"'.");
247 if (oc.
isSet(
"timeline")) {
256 router->
reset(&defaultVehicle);
257 const int maxNumThreads = oc.
getInt(
"routing-threads");
258 while ((
int)net.getThreadPool().size() < maxNumThreads) {
259 new RONet::WorkerThread(net.getThreadPool(), provider);
262 std::string assignMethod = oc.
getString(
"assignment-method");
263 if (assignMethod ==
"UE") {
264 WRITE_WARNING(
"Deterministic user equilibrium ('UE') is not implemented yet, using stochastic method ('SUE').");
265 assignMethod =
"SUE";
267 if (assignMethod ==
"incremental") {
269 }
else if (assignMethod ==
"SUE") {
274 bool haveOutput =
false;
276 if (dev !=
nullptr) {
277 std::vector<std::string> tazParamKeys;
278 if (oc.
isSet(
"taz-param")) {
281 std::map<SUMOTime, std::string> sortedOut;
285 if (c->begin >= end || c->end <= begin ||
286 c->pathsVector.empty() || c->pathsVector.front()->getEdgeVector().empty()) {
289 if (lastEnd >= 0 && lastEnd <= c->begin) {
290 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
295 if (c->departures.empty()) {
298 const int numVehs = int(c->vehicleNumber * (e - b) / (c->end - c->begin));
305 for (
RORoute*
const r : c->pathsVector) {
313 for (std::map<
SUMOTime, std::vector<std::string> >::const_iterator deps = c->departures.begin(); deps != c->departures.end(); ++deps) {
314 if (deps->first >= end || deps->first < begin) {
317 const std::string routeDistId = c->origin +
"_" + c->destination +
"_" +
time2string(c->begin) +
"_" +
time2string(c->end);
318 for (
const std::string&
id : deps->second) {
323 for (
RORoute*
const r : c->pathsVector) {
328 if (!tazParamKeys.empty()) {
330 if (tazParamKeys.size() > 1) {
335 sortedOut[deps->first] += od.
getString();
339 if (c->end > lastEnd) {
343 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
349 if (oc.
getBool(
"additive-traffic")) {
353 for (std::vector<ODCell*>::const_iterator i = matrix.
getCells().begin(); i != matrix.
getCells().end(); ++i) {
354 if ((*i)->end > lastCell) {
355 lastCell = (*i)->end;
359 for (
SUMOTime start = begin; start <
MIN2(end, lastCell); start += interval) {
386 RONet* net =
nullptr;
407 if (oc.
isSet(
"all-pairs-output")) {
413 std::cout <<
"Success." << std::endl;
441 }
catch (XERCES_CPP_NAMESPACE::SAXParseException& e) {
444 }
catch (XERCES_CPP_NAMESPACE::SAXException& e) {
452 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
462 std::cout <<
"Success." << std::endl;
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
std::vector< const ROEdge * > ConstROEdgeVector
std::string time2string(SUMOTime t)
convert SUMOTime to string
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
@ SVC_IGNORING
vehicles ignoring classes
const std::string DEFAULT_VTYPE_ID
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ 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.
const std::string & getID() const
Returns the id.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
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.
double getNumLoaded() const
Returns the number of loaded vehicles.
const std::vector< ODCell * > & getCells()
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.
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.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
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.
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)
SumoXMLEdgeFunc getFunction() const
Returns the function of the edge.
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
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.
void sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const double penalty, const double tolerance, const std::string routeChoiceMethod)
ROVehicle * getDefaultVehicle()
void incremental(const int numIter, const bool verbose)
static double getCapacity(const ROEdge *edge)
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.
A basic edge for routing applications.
double getFlow(const double time) const
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.
bool hasPermissions() const
OutputDevice * getRouteOutput(const bool alternative=false)
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.
const NamedObjectCont< ROEdge * > & getEdgeMap() const
bool hasLoadedEffort() const
whether efforts were loaded from file
A complete router's route.
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
void setCosts(double costs)
Sets the costs of the route.
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, const bool withCosts, const bool withExitTimes) const
A vehicle as used by router.
static void initRandGlobal(std::mt19937 *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
virtual void reset(const V *const vehicle)
reset internal caches, used by CHRouter
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()
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 writeInterval(OutputDevice &dev, const SUMOTime begin, const SUMOTime end, const RONet &net, const ROVehicle *const veh)
void computeRoutes(RONet &net, OptionsCont &oc, ODMatrix &matrix)
double getTravelTime(const ROEdge *const edge, const ROVehicle *const, double)
A single O/D-matrix cell.