Eclipse SUMO - Simulation of Urban MObility
marouter_main.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Main for MAROUTER
22 /****************************************************************************/
23 #include <config.h>
24 
25 #ifdef HAVE_VERSION_H
26 #include <version.h>
27 #endif
28 
29 #include <iostream>
30 #include <string>
31 #include <limits.h>
32 #include <ctime>
33 #include <vector>
34 #include <xercesc/sax/SAXException.hpp>
35 #include <xercesc/sax/SAXParseException.hpp>
42 #include <utils/common/ToString.h>
46 #include <utils/options/Option.h>
52 #include <utils/router/CHRouter.h>
54 #include <utils/xml/XMLSubSys.h>
55 #include <od/ODCell.h>
56 #include <od/ODDistrict.h>
57 #include <od/ODDistrictCont.h>
58 #include <od/ODDistrictHandler.h>
59 #include <od/ODMatrix.h>
60 #include <router/ROEdge.h>
61 #include <router/ROLoader.h>
62 #include <router/RONet.h>
63 #include <router/RORoute.h>
64 #include <router/RORoutable.h>
65 
66 #include "ROMAFrame.h"
67 #include "ROMAAssignments.h"
68 #include "ROMAEdgeBuilder.h"
69 #include "ROMARouteHandler.h"
70 #include "ROMAEdge.h"
71 
72 
73 // ===========================================================================
74 // functions
75 // ===========================================================================
76 /* -------------------------------------------------------------------------
77  * data processing methods
78  * ----------------------------------------------------------------------- */
84 void
85 initNet(RONet& net, ROLoader& loader, OptionsCont& oc) {
86  // load the net
87  ROMAEdgeBuilder builder;
88  ROEdge::setGlobalOptions(oc.getBool("weights.interpolate"));
89  loader.loadNet(net, builder);
90  // initialize the travel times
91  /* const SUMOTime begin = string2time(oc.getString("begin"));
92  const SUMOTime end = string2time(oc.getString("end"));
93  for (std::map<std::string, ROEdge*>::const_iterator i = net.getEdgeMap().begin(); i != net.getEdgeMap().end(); ++i) {
94  (*i).second->addTravelTime(STEPS2TIME(begin), STEPS2TIME(end), (*i).second->getLength() / (*i).second->getSpeedLimit());
95  }*/
96  // load the weights when wished/available
97  if (oc.isSet("weight-files")) {
98  loader.loadWeights(net, "weight-files", oc.getString("weight-attribute"), false, oc.getBool("weights.expand"));
99  }
100  if (oc.isSet("lane-weight-files")) {
101  loader.loadWeights(net, "lane-weight-files", oc.getString("weight-attribute"), true, oc.getBool("weights.expand"));
102  }
103 }
104 
105 
106 double
107 getTravelTime(const ROEdge* const edge, const ROVehicle* const /* veh */, double /* time */) {
108  return edge->getLength() / edge->getSpeedLimit();
109 }
110 
111 
115 void
117  OutputDevice::createDeviceByOption("all-pairs-output");
118  OutputDevice& outFile = OutputDevice::getDeviceByOption("all-pairs-output");
119  // build the router
120  typedef DijkstraRouter<ROEdge, ROVehicle> Dijkstra;
121  Dijkstra router(ROEdge::getAllEdges(), oc.getBool("ignore-errors"), &getTravelTime);
122  ConstROEdgeVector into;
123  const int numInternalEdges = net.getInternalEdgeNumber();
124  const int numTotalEdges = (int)net.getEdgeNumber();
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;
132  outFile << heuTT;
133  /*
134  if (heuTT >
135  ei.edge->getDistanceTo(router.getEdgeInfo(j).edge)
136  && router.getEdgeInfo(j).traveltime != std::numeric_limits<double>::max()
137  ) {
138  std::cout << " heuristic failure: from=" << ei.edge->getID() << " to=" << router.getEdgeInfo(j).edge->getID()
139  << " fromEffort=" << fromEffort << " heuTT=" << heuTT << " airDist=" << ei.edge->getDistanceTo(router.getEdgeInfo(j).edge) << "\n";
140  }
141  */
142  }
143  }
144  }
145 }
146 
147 
151 void
152 writeInterval(OutputDevice& dev, const SUMOTime begin, const SUMOTime end, const RONet& net, const ROVehicle* const veh) {
154  for (std::map<std::string, ROEdge*>::const_iterator i = net.getEdgeMap().begin(); i != net.getEdgeMap().end(); ++i) {
155  ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
156  if (edge->getFunction() == SumoXMLEdgeFunc::NORMAL) {
158  const double traveltime = edge->getTravelTime(veh, STEPS2TIME(begin));
159  const double flow = edge->getFlow(STEPS2TIME(begin));
160  dev.writeAttr("traveltime", traveltime);
161  dev.writeAttr("speed", edge->getLength() / traveltime);
162  dev.writeAttr("entered", flow);
163  dev.writeAttr("flowCapacityRatio", 100. * flow / ROMAAssignments::getCapacity(edge));
164  dev.closeTag();
165  }
166  }
167  dev.closeTag();
168 }
169 
170 
174 void
176  // build the router
177  SUMOAbstractRouter<ROEdge, ROVehicle>* router = nullptr;
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");
181  SUMOTime begin = string2time(oc.getString("begin"));
182  SUMOTime end = string2time(oc.getString("end"));
183  if (oc.isDefault("begin") && matrix.getBegin() >= 0) {
184  begin = matrix.getBegin();
185  }
186  if (oc.isDefault("end") && matrix.getEnd() >= 0) {
187  end = matrix.getEnd();
188  }
190  if (measure == "traveltime" && priorityFactor == 0) {
191  if (routingAlgorithm == "dijkstra") {
192  router = new DijkstraRouter<ROEdge, ROVehicle>(ROEdge::getAllEdges(), oc.getBool("ignore-errors"), ttOp, nullptr, false, nullptr, net.hasPermissions());
193  } else if (routingAlgorithm == "astar") {
194  router = new AStarRouter<ROEdge, ROVehicle>(ROEdge::getAllEdges(), oc.getBool("ignore-errors"), ttOp, nullptr, net.hasPermissions());
195  } else if (routingAlgorithm == "CH") {
196  const SUMOTime weightPeriod = (oc.isSet("weight-files") ?
197  string2time(oc.getString("weight-period")) :
198  SUMOTime_MAX);
199  router = new CHRouter<ROEdge, ROVehicle>(ROEdge::getAllEdges(), oc.getBool("ignore-errors"), &ROEdge::getTravelTimeStatic, SVC_IGNORING, weightPeriod, net.hasPermissions(), false);
200  } else if (routingAlgorithm == "CHWrapper") {
201  const SUMOTime weightPeriod = (oc.isSet("weight-files") ?
202  string2time(oc.getString("weight-period")) :
203  SUMOTime_MAX);
206  begin, end, weightPeriod, oc.getInt("routing-threads"));
207  } else {
208  throw ProcessError("Unknown routing Algorithm '" + routingAlgorithm + "'!");
209  }
210  } else {
212  if (measure == "traveltime") {
213  if (ROEdge::initPriorityFactor(priorityFactor)) {
215  } else {
217  }
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") {
234  } else {
236  }
237  if (measure != "traveltime" && !net.hasLoadedEffort()) {
238  WRITE_WARNING("No weight data was loaded for attribute '" + measure + "'.");
239  }
240  router = new DijkstraRouter<ROEdge, ROVehicle>(ROEdge::getAllEdges(), oc.getBool("ignore-errors"), op, ttOp, false, nullptr, net.hasPermissions());
241  }
242  try {
243  const RORouterProvider provider(router, nullptr, nullptr, nullptr);
244  // prepare the output
245  net.openOutput(oc);
246  // process route definitions
247  if (oc.isSet("timeline")) {
248  matrix.applyCurve(matrix.parseTimeLine(oc.getStringVector("timeline"), oc.getBool("timeline.day-in-hours")));
249  }
250  matrix.sortByBeginTime();
251  ROVehicle defaultVehicle(SUMOVehicleParameter(), nullptr, net.getVehicleTypeSecure(DEFAULT_VTYPE_ID), &net);
252  ROMAAssignments a(begin, end, oc.getBool("additive-traffic"), oc.getFloat("weight-adaption"), oc.getInt("max-alternatives"), net, matrix, *router);
253  a.resetFlows();
254 #ifdef HAVE_FOX
255  // this is just to init the CHRouter with the default vehicle
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);
260  }
261 #endif
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";
266  }
267  if (assignMethod == "incremental") {
268  a.incremental(oc.getInt("max-iterations"), oc.getBool("verbose"));
269  } else if (assignMethod == "SUE") {
270  a.sue(oc.getInt("max-iterations"), oc.getInt("max-inner-iterations"),
271  oc.getInt("paths"), oc.getFloat("paths.penalty"), oc.getFloat("tolerance"), oc.getString("route-choice-method"));
272  }
273  // update path costs and output
274  bool haveOutput = false;
275  OutputDevice* dev = net.getRouteOutput();
276  if (dev != nullptr) {
277  std::vector<std::string> tazParamKeys;
278  if (oc.isSet("taz-param")) {
279  tazParamKeys = oc.getStringVector("taz-param");
280  }
281  std::map<SUMOTime, std::string> sortedOut;
282  SUMOTime lastEnd = -1;
283  int num = 0;
284  for (const ODCell* const c : matrix.getCells()) {
285  if (c->begin >= end || c->end <= begin ||
286  c->pathsVector.empty() || c->pathsVector.front()->getEdgeVector().empty()) {
287  continue;
288  }
289  if (lastEnd >= 0 && lastEnd <= c->begin) {
290  for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
291  dev->writePreformattedTag(desc->second);
292  }
293  sortedOut.clear();
294  }
295  if (c->departures.empty()) {
296  const SUMOTime b = MAX2(begin, c->begin);
297  const SUMOTime e = MIN2(end, c->end);
298  const int numVehs = int(c->vehicleNumber * (e - b) / (c->end - c->begin));
299  OutputDevice_String od(1);
300  od.openTag(SUMO_TAG_FLOW).writeAttr(SUMO_ATTR_ID, oc.getString("prefix") + toString(num++));
302  od.writeAttr(SUMO_ATTR_NUMBER, numVehs);
303  matrix.writeDefaultAttrs(od, oc.getBool("ignore-vehicle-type"), c);
305  for (RORoute* const r : c->pathsVector) {
306  r->setCosts(router->recomputeCosts(r->getEdgeVector(), &defaultVehicle, begin));
307  r->writeXMLDefinition(od, nullptr, true, false);
308  }
309  od.closeTag();
310  od.closeTag();
311  sortedOut[c->begin] += od.getString();
312  } else {
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) {
315  continue;
316  }
317  const std::string routeDistId = c->origin + "_" + c->destination + "_" + time2string(c->begin) + "_" + time2string(c->end);
318  for (const std::string& id : deps->second) {
319  OutputDevice_String od(1);
321  matrix.writeDefaultAttrs(od, oc.getBool("ignore-vehicle-type"), c);
323  for (RORoute* const r : c->pathsVector) {
324  r->setCosts(router->recomputeCosts(r->getEdgeVector(), &defaultVehicle, begin));
325  r->writeXMLDefinition(od, nullptr, true, false);
326  }
327  od.closeTag();
328  if (!tazParamKeys.empty()) {
329  od.openTag(SUMO_TAG_PARAM).writeAttr(SUMO_ATTR_KEY, tazParamKeys[0]).writeAttr(SUMO_ATTR_VALUE, c->origin).closeTag();
330  if (tazParamKeys.size() > 1) {
331  od.openTag(SUMO_TAG_PARAM).writeAttr(SUMO_ATTR_KEY, tazParamKeys[1]).writeAttr(SUMO_ATTR_VALUE, c->destination).closeTag();
332  }
333  }
334  od.closeTag();
335  sortedOut[deps->first] += od.getString();
336  }
337  }
338  }
339  if (c->end > lastEnd) {
340  lastEnd = c->end;
341  }
342  }
343  for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
344  dev->writePreformattedTag(desc->second);
345  }
346  haveOutput = true;
347  }
348  if (OutputDevice::createDeviceByOption("netload-output", "meandata")) {
349  if (oc.getBool("additive-traffic")) {
350  writeInterval(OutputDevice::getDeviceByOption("netload-output"), begin, end, net, a.getDefaultVehicle());
351  } else {
352  SUMOTime lastCell = 0;
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;
356  }
357  }
358  const SUMOTime interval = string2time(OptionsCont::getOptions().getString("aggregation-interval"));
359  for (SUMOTime start = begin; start < MIN2(end, lastCell); start += interval) {
360  writeInterval(OutputDevice::getDeviceByOption("netload-output"), start, start + interval, net, a.getDefaultVehicle());
361  }
362  }
363  haveOutput = true;
364  }
365  if (!haveOutput) {
366  throw ProcessError("No output file given.");
367  }
368  // end the processing
369  net.cleanup();
370  } catch (ProcessError&) {
371  net.cleanup();
372  throw;
373  }
374 }
375 
376 
377 /* -------------------------------------------------------------------------
378  * main
379  * ----------------------------------------------------------------------- */
380 int
381 main(int argc, char** argv) {
383  oc.setApplicationDescription("Import O/D-matrices for macroscopic traffic assignment to generate SUMO routes");
384  oc.setApplicationName("marouter", "Eclipse SUMO marouter Version " VERSION_STRING);
385  int ret = 0;
386  RONet* net = nullptr;
387  try {
388  XMLSubSys::init();
390  OptionsIO::setArgs(argc, argv);
392  if (oc.processMetaOptions(argc < 2)) {
394  return 0;
395  }
397  XMLSubSys::setValidation(oc.getString("xml-validation"), oc.getString("xml-validation.net"), oc.getString("xml-validation.routes"));
399  if (!ROMAFrame::checkOptions()) {
400  throw ProcessError();
401  }
403  // load data
404  ROLoader loader(oc, false, false);
405  net = new RONet();
406  initNet(*net, loader, oc);
407  if (oc.isSet("all-pairs-output")) {
408  computeAllPairs(*net, oc);
409  if (net->getDistricts().empty()) {
410  delete net;
412  if (ret == 0) {
413  std::cout << "Success." << std::endl;
414  }
415  return ret;
416  }
417  }
418  if (net->getDistricts().empty()) {
419  WRITE_WARNING("No districts loaded, will use edge ids!");
420  }
421  // load districts
422  ODDistrictCont districts;
423  districts.makeDistricts(net->getDistricts());
424  // load the matrix
425  ODMatrix matrix(districts);
426  matrix.loadMatrix(oc);
427  ROMARouteHandler handler(matrix);
428  matrix.loadRoutes(oc, handler);
429  if (matrix.getNumLoaded() == matrix.getNumDiscarded()) {
430  throw ProcessError("No valid vehicles loaded.");
431  }
432  if (MsgHandler::getErrorInstance()->wasInformed() && !oc.getBool("ignore-errors")) {
433  throw ProcessError("Loading failed.");
434  }
436  WRITE_MESSAGE(toString(matrix.getNumLoaded() - matrix.getNumDiscarded()) + " valid vehicles loaded (total seen: " + toString(matrix.getNumLoaded()) + ").");
437 
438  // build routes and parse the incremental rates if the incremental method is choosen.
439  try {
440  computeRoutes(*net, oc, matrix);
441  } catch (XERCES_CPP_NAMESPACE::SAXParseException& e) {
442  WRITE_ERROR(toString(e.getLineNumber()));
443  ret = 1;
444  } catch (XERCES_CPP_NAMESPACE::SAXException& e) {
445  WRITE_ERROR(StringUtils::transcode(e.getMessage()));
446  ret = 1;
447  }
448  if (MsgHandler::getErrorInstance()->wasInformed() || ret != 0) {
449  throw ProcessError();
450  }
451  } catch (const ProcessError& e) {
452  if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
453  WRITE_ERROR(e.what());
454  }
455  MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
456  ret = 1;
457  }
458 
459  delete net;
461  if (ret == 0) {
462  std::cout << "Success." << std::endl;
463  }
464  return ret;
465 }
466 
467 
468 /****************************************************************************/
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:54
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
#define SUMOTime_MAX
Definition: SUMOTime.h:32
long long int SUMOTime
Definition: SUMOTime.h:31
@ 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_NUMBER
@ SUMO_ATTR_DEPART
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
@ SUMO_ATTR_KEY
T MIN2(T a, T b)
Definition: StdDefs.h:73
T MAX2(T a, T b)
Definition: StdDefs.h:79
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
Computes the shortest path through a network using the A* algorithm.
Definition: AStarRouter.h:76
Computes the shortest path through a contracted network.
Definition: CHRouter.h:59
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.
Definition: MsgHandler.cpp:80
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:117
static void initOutputOptions()
init output options
Definition: MsgHandler.cpp:217
virtual void clear(bool resetInformed=true)
Clears information whether an error occurred previously and print aggregated message summary.
Definition: MsgHandler.cpp:159
const std::string & getID() const
Returns the id.
Definition: Named.h:73
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.
Definition: ODMatrix.h:67
double getNumLoaded() const
Returns the number of loaded vehicles.
Definition: ODMatrix.cpp:582
void sortByBeginTime()
Definition: ODMatrix.cpp:717
const std::vector< ODCell * > & getCells()
Definition: ODMatrix.h:246
void applyCurve(const Distribution_Points &ps)
Splits the stored cells dividing them on the given time line.
Definition: ODMatrix.cpp:616
SUMOTime getEnd() const
Definition: ODMatrix.h:256
Distribution_Points parseTimeLine(const std::vector< std::string > &def, bool timelineDayInHours)
split the given timeline
Definition: ODMatrix.cpp:692
void writeDefaultAttrs(OutputDevice &dev, const bool noVtype, const ODCell *const cell)
Helper function for flow and trip output writing the depart and arrival attributes.
Definition: ODMatrix.cpp:187
SUMOTime getBegin() const
Definition: ODMatrix.h:252
void loadMatrix(OptionsCont &oc)
read a matrix in one of several formats
Definition: ODMatrix.cpp:629
void loadRoutes(OptionsCont &oc, SUMOSAXHandler &handler)
read SUMO routes
Definition: ODMatrix.cpp:675
double getNumDiscarded() const
Returns the number of discarded vehicles.
Definition: ODMatrix.cpp:594
A storage for options typed value containers)
Definition: OptionsCont.h:89
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.
Definition: OptionsCont.cpp:58
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.
Definition: OptionsIO.cpp:58
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition: OptionsIO.cpp:79
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.
Definition: OutputDevice.h:60
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
Definition: OutputDevice.h:277
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
Definition: OutputDevice.h:239
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.
Definition: ROEdge.h:70
static double getStoredEffort(const ROEdge *const edge, const ROVehicle *const, double time)
Definition: ROEdge.h:472
static bool initPriorityFactor(double priorityFactor)
initialize priority factor range
Definition: ROEdge.cpp:439
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)
Definition: ROEdge.h:432
double getSpeedLimit() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:225
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
Definition: ROEdge.cpp:211
SumoXMLEdgeFunc getFunction() const
Returns the function of the edge.
Definition: ROEdge.h:194
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:186
double getLength() const
Returns the length of the edge.
Definition: ROEdge.h:210
static void setGlobalOptions(const bool interpolate)
Definition: ROEdge.h:492
static double getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the travel time for the given edge.
Definition: ROEdge.h:418
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition: ROEdge.cpp:347
The data loader.
Definition: ROLoader.h:53
bool loadWeights(RONet &net, const std::string &optionName, const std::string &measure, const bool useLanes, const bool boundariesOverride)
Loads the net weights.
Definition: ROLoader.cpp:256
virtual void loadNet(RONet &toFill, ROAbstractEdgeBuilder &eb)
Loads the network.
Definition: ROLoader.cpp:112
assignment methods
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.
Definition: ROMAEdge.h:55
double getFlow(const double time) const
Definition: ROMAEdge.h:83
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
Definition: ROMAFrame.cpp:44
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter.
Definition: ROMAFrame.cpp:291
Parser and container for routes during their loading.
The router's network representation.
Definition: RONet.h:62
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:334
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary
Definition: RONet.cpp:310
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
Definition: RONet.cpp:270
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
Definition: RONet.cpp:716
bool hasPermissions() const
Definition: RONet.cpp:763
OutputDevice * getRouteOutput(const bool alternative=false)
Definition: RONet.h:417
const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > & getDistricts() const
Retrieves all TAZ (districts) from the network.
Definition: RONet.h:145
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
Definition: RONet.cpp:710
const NamedObjectCont< ROEdge * > & getEdgeMap() const
Definition: RONet.h:399
bool hasLoadedEffort() const
whether efforts were loaded from file
Definition: RONet.cpp:774
A complete router's route.
Definition: RORoute.h:52
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
Definition: RORoute.h:152
void setCosts(double costs)
Sets the costs of the route.
Definition: RORoute.cpp:64
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, const bool withCosts, const bool withExitTimes) const
Definition: RORoute.cpp:87
A vehicle as used by router.
Definition: ROVehicle.h:50
static void initRandGlobal(std::mt19937 *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
Definition: RandHelper.cpp:76
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
Definition: StringUtils.h:133
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.
Definition: XMLSubSys.cpp:65
static void init()
Initialises the xml-subsystem.
Definition: XMLSubSys.cpp:54
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.
Definition: ODCell.h:48