36 #include <xercesc/sax/SAXException.hpp> 37 #include <xercesc/sax/SAXParseException.hpp> 98 if (oc.
isSet(
"weight-files")) {
101 if (oc.
isSet(
"lane-weight-files")) {
118 std::ofstream outFile(oc.
getString(
"all-pairs-output").c_str(), std::ios::binary);
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");
182 if (measure ==
"traveltime") {
183 if (routingAlgorithm ==
"dijkstra") {
185 if (oc.
getInt(
"paths") > 1) {
193 if (oc.
getInt(
"paths") > 1) {
201 }
else if (routingAlgorithm ==
"astar") {
203 if (oc.
getInt(
"paths") > 1) {
211 if (oc.
getInt(
"paths") > 1) {
219 }
else if (routingAlgorithm ==
"CH") {
222 std::numeric_limits<int>::max());
230 }
else if (routingAlgorithm ==
"CHWrapper") {
233 std::numeric_limits<int>::max());
236 begin, end, weightPeriod, oc.
getInt(
"routing-threads"));
238 throw ProcessError(
"Unknown routing Algorithm '" + routingAlgorithm +
"'!");
243 if (measure ==
"CO") {
244 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO>;
245 }
else if (measure ==
"CO2") {
246 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO2>;
247 }
else if (measure ==
"PMx") {
248 op = &ROEdge::getEmissionEffort<PollutantsInterface::PM_X>;
249 }
else if (measure ==
"HC") {
250 op = &ROEdge::getEmissionEffort<PollutantsInterface::HC>;
251 }
else if (measure ==
"NOx") {
252 op = &ROEdge::getEmissionEffort<PollutantsInterface::NO_X>;
253 }
else if (measure ==
"fuel") {
254 op = &ROEdge::getEmissionEffort<PollutantsInterface::FUEL>;
255 }
else if (measure ==
"electricity") {
256 op = &ROEdge::getEmissionEffort<PollutantsInterface::ELEC>;
257 }
else if (measure ==
"noise") {
260 throw ProcessError(
"Unknown measure (weight attribute '" + measure +
"')!");
263 if (oc.
getInt(
"paths") > 1) {
271 if (oc.
getInt(
"paths") > 1) {
285 if (oc.
isSet(
"timeline")) {
293 const int maxNumThreads = oc.
getInt(
"routing-threads");
294 while ((
int)net.getThreadPool().size() < maxNumThreads) {
295 new RONet::WorkerThread(net.getThreadPool(), provider);
298 std::string assignMethod = oc.
getString(
"assignment-method");
299 if (assignMethod ==
"UE") {
300 WRITE_WARNING(
"Deterministic user equilibrium ('UE') is not implemented yet, using stochastic method ('SUE').");
301 assignMethod =
"SUE";
303 if (assignMethod ==
"incremental") {
304 a.incremental(oc.
getInt(
"max-iterations"), oc.
getBool(
"verbose"));
305 }
else if (assignMethod ==
"SUE") {
306 a.sue(oc.
getInt(
"max-iterations"), oc.
getInt(
"max-inner-iterations"),
310 bool haveOutput =
false;
312 if (dev !=
nullptr) {
313 std::vector<std::string> tazParamKeys;
314 if (oc.
isSet(
"taz-param")) {
317 std::map<SUMOTime, std::string> sortedOut;
320 for (
const ODCell*
const c : matrix.getCells()) {
321 if (c->begin >= end || c->end <= begin ||
322 c->pathsVector.empty() || c->pathsVector.front()->getEdgeVector().empty()) {
325 if (lastEnd >= 0 && lastEnd <= c->begin) {
326 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
331 if (c->departures.empty()) {
334 const int numVehs = int(c->vehicleNumber * (e - b) / (c->end - c->begin));
339 matrix.writeDefaultAttrs(od, oc.
getBool(
"ignore-vehicle-type"), c);
341 for (
RORoute*
const r : c->pathsVector) {
347 sortedOut[c->begin] += od.getString();
349 for (std::map<
SUMOTime, std::vector<std::string> >::const_iterator deps = c->departures.begin(); deps != c->departures.end(); ++deps) {
350 if (deps->first >= end || deps->first < begin) {
353 const std::string routeDistId = c->origin +
"_" + c->destination +
"_" +
time2string(c->begin) +
"_" +
time2string(c->end);
354 for (
const std::string&
id : deps->second) {
357 matrix.writeDefaultAttrs(od, oc.
getBool(
"ignore-vehicle-type"), c);
359 for (
RORoute*
const r : c->pathsVector) {
364 if (!tazParamKeys.empty()) {
366 if (tazParamKeys.size() > 1) {
371 sortedOut[deps->first] += od.getString();
375 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
378 if (c->end > lastEnd) {
382 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
388 if (oc.
getBool(
"additive-traffic")) {
392 for (std::vector<ODCell*>::const_iterator i = matrix.getCells().begin(); i != matrix.getCells().end(); ++i) {
393 if ((*i)->end > lastCell) {
394 lastCell = (*i)->end;
398 for (
SUMOTime start = begin; start <
MIN2(end, lastCell); start += interval) {
410 for (std::vector<ODCell*>::const_iterator i = matrix.
getCells().begin(); i != matrix.
getCells().end(); ++i) {
411 for (std::vector<RORoute*>::const_iterator j = (*i)->pathsVector.begin(); j != (*i)->pathsVector.end(); ++j) {
430 RONet* net =
nullptr;
450 if (oc.
isSet(
"all-pairs-output")) {
456 std::cout <<
"Success." << std::endl;
484 }
catch (XERCES_CPP_NAMESPACE::SAXParseException& e) {
487 }
catch (XERCES_CPP_NAMESPACE::SAXException& e) {
495 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
505 std::cout <<
"Success." << std::endl;
Computes the shortest path through a contracted network.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
const std::vector< ODCell * > & getCells()
static void init()
Initialises the xml-subsystem.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
OutputDevice * getRouteOutput(const bool alternative=false)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void computeRoutes(RONet &net, OptionsCont &oc, ODMatrix &matrix)
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
a flow definitio nusing a from-to edges instead of a route (used by router)
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme)
Enables or disables validation.
Interface for building instances of duarouter-edges.
void makeDistricts(const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > &districts)
create districts from description
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
int main(int argc, char **argv)
static std::ostream & writeFloat(std::ostream &strm, double value)
Writes a float binary.
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed ...
std::string time2string(SUMOTime t)
Computes the shortest path through a network using the A* algorithm.
weights: time range begin
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter...
const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > & getDistricts() const
Retrieves all TAZ (districts) from the network.
void computeAllPairs(RONet &net, OptionsCont &oc)
bool hasPermissions() const
double getLength() const
Returns the length of the edge.
std::vector< const ROEdge * > ConstROEdgeVector
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Parser and container for routes during their loading.
const std::string & getID() const
Returns the id.
const std::string DEFAULT_VTYPE_ID
static void close()
Closes all of an applications subsystems.
#define WRITE_WARNING(msg)
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static OptionsCont & getOptions()
Retrieves the options.
void loadMatrix(OptionsCont &oc)
read a matrix in one of several formats
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...
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
A vehicle as used by router.
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary ...
static double getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the travel time for the given edge.
A single O/D-matrix cell.
void initNet(RONet &net, ROLoader &loader, OptionsCont &oc)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Computes the shortest path through a network using the Dijkstra algorithm.
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
parameter associated to a certain key
An O/D (origin/destination) matrix.
SumoXMLEdgeFunc getFunction() const
Returns the function of the edge.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
double getTravelTime(const ROEdge *const edge, const ROVehicle *const, double)
void loadRoutes(OptionsCont &oc, SUMOSAXHandler &handler)
read SUMO routes
SUMOTime string2time(const std::string &r)
A container for districts.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
static bool checkOptions()
checks shared options and sets StdDefs
void writeInterval(OutputDevice &dev, const SUMOTime begin, const SUMOTime end, const RONet &net, const ROVehicle *const veh)
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static double getCapacity(const ROEdge *edge)
double getNumLoaded() const
Returns the number of loaded vehicles.
virtual void loadNet(RONet &toFill, ROAbstractEdgeBuilder &eb)
Loads the network.
A basic edge for routing applications.
begin/end of the description of an edge
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
static double getPenalizedEffort(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the effort to pass an edge including penalties.
The router's network representation.
Structure representing possible vehicle parameter.
const NamedObjectCont< ROEdge * > & getEdgeMap() const
static double getTravelTime(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the traveltime on an edge without penalties.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
void setCosts(double costs)
Sets the costs of the route.
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
double getSpeedLimit() const
Returns the speed allowed on this edge.
static void initRandGlobal(std::mt19937 *which=0)
Reads the given random number options and initialises the random number generator in accordance...
void applyCurve(const Distribution_Points &ps)
Splits the stored cells dividing them on the given time line.
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
static void setGlobalOptions(const bool interpolate)
an aggreagated-output interval
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.
double getFlow(const double time) const
Static storage of an output device and its base (abstract) implementation.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
double getNumDiscarded() const
Returns the number of discarded vehicles.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
virtual void clear()
Clears information whether an error occurred previously.
#define WRITE_MESSAGE(msg)
static void initOutputOptions()
init output options
A basic edge for routing applications.
bool isBinary() const
Returns whether we have a binary output.
bool loadWeights(RONet &net, const std::string &optionName, const std::string &measure, const bool useLanes, const bool boundariesOverride)
Loads the net weights.
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, const bool withCosts, const bool withExitTimes) const
vehicles ignoring classes
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
A complete router's route.
An output device that encapsulates an ofstream.
static double getPenalizedTT(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the traveltime on an edge including penalties.
Distribution_Points parseTimeLine(const std::vector< std::string > &def, bool timelineDayInHours)
split the given timeline
Computes the shortest path through a contracted network.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.