 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
35 #include <xercesc/sax/SAXException.hpp>
36 #include <xercesc/sax/SAXParseException.hpp>
97 if (oc.
isSet(
"weight-files")) {
100 if (oc.
isSet(
"lane-weight-files")) {
117 std::ofstream outFile(oc.
getString(
"all-pairs-output").c_str(), std::ios::binary);
124 for (
int i = numInternalEdges; i < numTotalEdges; i++) {
125 const Dijkstra::EdgeInfo& ei = router.getEdgeInfo(i);
126 if (!ei.edge->isInternal()) {
127 router.compute(ei.edge,
nullptr,
nullptr, 0, into);
128 double fromEffort = router.getEffort(ei.edge,
nullptr, 0);
129 for (
int j = numInternalEdges; j < numTotalEdges; j++) {
130 double heuTT = router.getEdgeInfo(j).effort - fromEffort;
177 const std::string measure = oc.
getString(
"weight-attribute");
178 const std::string routingAlgorithm = oc.
getString(
"routing-algorithm");
188 if (measure ==
"traveltime") {
189 if (routingAlgorithm ==
"dijkstra") {
191 }
else if (routingAlgorithm ==
"astar") {
193 }
else if (routingAlgorithm ==
"CH") {
196 std::numeric_limits<int>::max());
198 }
else if (routingAlgorithm ==
"CHWrapper") {
201 std::numeric_limits<int>::max());
204 begin, end, weightPeriod, oc.
getInt(
"routing-threads"));
206 throw ProcessError(
"Unknown routing Algorithm '" + routingAlgorithm +
"'!");
210 if (measure ==
"CO") {
211 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO>;
212 }
else if (measure ==
"CO2") {
213 op = &ROEdge::getEmissionEffort<PollutantsInterface::CO2>;
214 }
else if (measure ==
"PMx") {
215 op = &ROEdge::getEmissionEffort<PollutantsInterface::PM_X>;
216 }
else if (measure ==
"HC") {
217 op = &ROEdge::getEmissionEffort<PollutantsInterface::HC>;
218 }
else if (measure ==
"NOx") {
219 op = &ROEdge::getEmissionEffort<PollutantsInterface::NO_X>;
220 }
else if (measure ==
"fuel") {
221 op = &ROEdge::getEmissionEffort<PollutantsInterface::FUEL>;
222 }
else if (measure ==
"electricity") {
223 op = &ROEdge::getEmissionEffort<PollutantsInterface::ELEC>;
224 }
else if (measure ==
"noise") {
227 throw ProcessError(
"Unknown measure (weight attribute '" + measure +
"')!");
236 if (oc.
isSet(
"timeline")) {
244 const int maxNumThreads = oc.
getInt(
"routing-threads");
245 while ((
int)net.getThreadPool().size() < maxNumThreads) {
246 new RONet::WorkerThread(net.getThreadPool(), provider);
249 std::string assignMethod = oc.
getString(
"assignment-method");
250 if (assignMethod ==
"UE") {
251 WRITE_WARNING(
"Deterministic user equilibrium ('UE') is not implemented yet, using stochastic method ('SUE').");
252 assignMethod =
"SUE";
254 if (assignMethod ==
"incremental") {
256 }
else if (assignMethod ==
"SUE") {
261 bool haveOutput =
false;
263 if (dev !=
nullptr) {
264 std::vector<std::string> tazParamKeys;
265 if (oc.
isSet(
"taz-param")) {
268 std::map<SUMOTime, std::string> sortedOut;
272 if (c->begin >= end || c->end <= begin ||
273 c->pathsVector.empty() || c->pathsVector.front()->getEdgeVector().empty()) {
276 if (lastEnd >= 0 && lastEnd <= c->begin) {
277 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
282 if (c->departures.empty()) {
285 const int numVehs = int(c->vehicleNumber * (e - b) / (c->end - c->begin));
292 for (
RORoute*
const r : c->pathsVector) {
300 for (std::map<
SUMOTime, std::vector<std::string> >::const_iterator deps = c->departures.begin(); deps != c->departures.end(); ++deps) {
301 if (deps->first >= end || deps->first < begin) {
304 const std::string routeDistId = c->origin +
"_" + c->destination +
"_" +
time2string(c->begin) +
"_" +
time2string(c->end);
305 for (
const std::string&
id : deps->second) {
310 for (
RORoute*
const r : c->pathsVector) {
315 if (!tazParamKeys.empty()) {
317 if (tazParamKeys.size() > 1) {
322 sortedOut[deps->first] += od.
getString();
326 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
329 if (c->end > lastEnd) {
333 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
339 if (oc.
getBool(
"additive-traffic")) {
343 for (std::vector<ODCell*>::const_iterator i = matrix.
getCells().begin(); i != matrix.
getCells().end(); ++i) {
344 if ((*i)->end > lastCell) {
345 lastCell = (*i)->end;
349 for (
SUMOTime start = begin; start <
MIN2(end, lastCell); start += interval) {
361 for (std::vector<ODCell*>::const_iterator i = matrix.
getCells().begin(); i != matrix.
getCells().end(); ++i) {
362 for (std::vector<RORoute*>::const_iterator j = (*i)->pathsVector.begin(); j != (*i)->pathsVector.end(); ++j) {
381 RONet* net =
nullptr;
401 if (oc.
isSet(
"all-pairs-output")) {
407 std::cout <<
"Success." << std::endl;
435 }
catch (XERCES_CPP_NAMESPACE::SAXParseException& e) {
438 }
catch (XERCES_CPP_NAMESPACE::SAXException& e) {
446 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
456 std::cout <<
"Success." << std::endl;
OutputDevice * getRouteOutput(const bool alternative=false)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
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.
Distribution_Points parseTimeLine(const std::vector< std::string > &def, bool timelineDayInHours)
split the given timeline
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
static void close()
Closes all of an applications subsystems.
#define WRITE_WARNING(msg)
static void initOutputOptions()
init output options
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
void incremental(const int numIter, const bool verbose)
An output device that encapsulates an ofstream.
Static storage of an output device and its base (abstract) implementation.
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_PARAM
parameter associated to a certain key
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter.
void initNet(RONet &net, ROLoader &loader, OptionsCont &oc)
SUMOTime getBegin() const
Interface for building instances of duarouter-edges.
static double getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, double time)
Returns the travel time for the given edge.
bool isBinary() const
Returns whether we have a binary output.
bool hasPermissions() const
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
void setCosts(double costs)
Sets the costs of the route.
void writeInterval(OutputDevice &dev, const SUMOTime begin, const SUMOTime end, const RONet &net, const ROVehicle *const veh)
A basic edge for routing applications.
The router's network representation.
A vehicle as used by router.
Structure representing possible vehicle parameter.
static std::ostream & writeFloat(std::ostream &strm, double value)
Writes a float binary.
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
static double getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, double time)
void loadMatrix(OptionsCont &oc)
read a matrix in one of several formats
Computes the shortest path through a network using the Dijkstra algorithm.
static void setGlobalOptions(const bool interpolate)
std::string getString() const
Returns the current content as a string.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
virtual void clear()
Clears information whether an error occurred previously.
@ SUMO_ATTR_BEGIN
weights: time range begin
double getFlow(const double time) const
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void loadRoutes(OptionsCont &oc, SUMOSAXHandler &handler)
read SUMO routes
const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > & getDistricts() const
Retrieves all TAZ (districts) from the network.
@ SUMO_TAG_FLOW
a flow definitio nusing a from-to edges instead of a route (used by router)
A single O/D-matrix cell.
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme)
Enables or disables validation.
void computeRoutes(RONet &net, OptionsCont &oc, ODMatrix &matrix)
const std::string DEFAULT_VTYPE_ID
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
Computes the shortest path through a contracted network.
void computeAllPairs(RONet &net, OptionsCont &oc)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
std::string time2string(SUMOTime t)
A complete router's route.
Parser and container for routes during their loading.
static void init()
Initialises the xml-subsystem.
A storage for options typed value containers)
int main(int argc, char **argv)
ROVehicle * getDefaultVehicle()
SumoXMLEdgeFunc getFunction() const
Returns the function of the edge.
virtual void loadNet(RONet &toFill, ROAbstractEdgeBuilder &eb)
Loads the network.
@ SUMO_TAG_VEHICLE
description of a vehicle
SUMOTime string2time(const std::string &r)
OutputDevice & writeXMLDefinition(OutputDevice &dev, const ROVehicle *const veh, const bool withCosts, const bool withExitTimes) const
An O/D (origin/destination) matrix.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
static void initRandGlobal(std::mt19937 *which=0)
Reads the given random number options and initialises the random number generator in accordance.
A container for districts.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
const NamedObjectCont< ROEdge * > & getEdgeMap() const
void setApplicationDescription(const std::string &appDesc)
Sets the application description.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
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
double getNumLoaded() const
Returns the number of loaded vehicles.
static double getCapacity(const ROEdge *edge)
Computes the shortest path through a contracted network.
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
double getLength() const
Returns the length of the edge.
Computes the shortest path through a network using the A* algorithm.
A basic edge for routing applications.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
double getNumDiscarded() const
Returns the number of discarded vehicles.
static bool checkOptions()
checks shared options and sets StdDefs
void applyCurve(const Distribution_Points &ps)
Splits the stored cells dividing them on the given time line.
@ SUMO_ATTR_END
weights: time range end
double getSpeedLimit() const
Returns the speed allowed on this edge.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
double getTravelTime(const ROEdge *const edge, const ROVehicle *const, double)
@ SVC_IGNORING
vehicles ignoring classes
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
const std::string & getID() const
Returns the id.
void makeDistricts(const std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > &districts)
create districts from description
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
#define WRITE_MESSAGE(msg)
std::vector< const ROEdge * > ConstROEdgeVector
void writeDefaultAttrs(OutputDevice &dev, const bool noVtype, const ODCell *const cell)
Helper function for flow and trip output writing the depart and arrival attributes.
const std::vector< ODCell * > & getCells()
static double getPenalizedTT(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the traveltime on an edge including penalties.
void sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const double penalty, const double tolerance, const std::string routeChoiceMethod)
bool loadWeights(RONet &net, const std::string &optionName, const std::string &measure, const bool useLanes, const bool boundariesOverride)
Loads the net weights.