38 #include <xercesc/sax/SAXException.hpp> 39 #include <xercesc/sax/SAXParseException.hpp> 81 #ifdef CHECK_MEMORY_LEAKS 83 #endif // CHECK_MEMORY_LEAKS 110 if (oc.
isSet(
"weight-files")) {
113 if (oc.
isSet(
"lane-weight-files")) {
129 std::ofstream outFile(oc.
getString(
"all-pairs-output").c_str(), std::ios::binary);
135 const int numTotalEdges = (int)net.
getEdgeNo();
136 for (
int i = numInternalEdges; i < numTotalEdges; i++) {
137 const Dijkstra::EdgeInfo& ei = router.getEdgeInfo(i);
139 router.compute(ei.edge, 0, 0, 0, into);
140 for (
int j = numInternalEdges; j < numTotalEdges; j++) {
154 for (std::map<std::string, ROEdge*>::const_iterator i = net.
getEdgeMap().begin(); i != net.
getEdgeMap().end(); ++i) {
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") {
230 }
else if (routingAlgorithm ==
"CHWrapper") {
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 const std::string assignMethod = oc.
getString(
"assignment-method");
299 if (assignMethod ==
"incremental") {
300 a.incremental(oc.
getInt(
"max-iterations"), oc.
getBool(
"verbose"));
301 }
else if (assignMethod ==
"SUE") {
302 a.sue(oc.
getInt(
"max-iterations"), oc.
getInt(
"max-inner-iterations"),
306 bool haveOutput =
false;
309 std::vector<std::string> tazParamKeys;
310 if (oc.
isSet(
"taz-param")) {
313 std::map<SUMOTime, std::string> sortedOut;
316 for (std::vector<ODCell*>::const_iterator i = matrix.getCells().begin(); i != matrix.getCells().end(); ++i) {
317 const ODCell*
const c = *i;
318 if (lastEnd >= 0 && lastEnd <= c->begin) {
319 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
320 (*dev) << desc->second;
329 matrix.writeDefaultAttrs(od, oc.
getBool(
"ignore-vehicle-type"), c);
333 (*j)->writeXMLDefinition(od, 0,
true,
false);
337 sortedOut[c->
begin] += od.getString();
341 for (std::vector<std::string>::const_iterator
id = deps->second.begin();
id != deps->second.end(); ++id) {
344 matrix.writeDefaultAttrs(od, oc.
getBool(
"ignore-vehicle-type"), c);
348 (*j)->writeXMLDefinition(od, 0,
true,
false);
351 if (!tazParamKeys.empty()) {
353 if (tazParamKeys.size() > 1) {
358 sortedOut[deps->first] += od.getString();
365 if (c->
end > lastEnd) {
369 for (std::map<SUMOTime, std::string>::const_iterator desc = sortedOut.begin(); desc != sortedOut.end(); ++desc) {
370 (*dev) << desc->second;
375 if (oc.
getBool(
"additive-traffic")) {
379 for (std::vector<ODCell*>::const_iterator i = matrix.getCells().begin(); i != matrix.getCells().end(); ++i) {
380 if ((*i)->end > lastCell) {
381 lastCell = (*i)->end;
385 for (
SUMOTime start = begin; start <
MIN2(end, lastCell); start += interval) {
397 for (std::vector<ODCell*>::const_iterator i = matrix.
getCells().begin(); i != matrix.
getCells().end(); ++i) {
398 for (std::vector<RORoute*>::const_iterator j = (*i)->pathsVector.begin(); j != (*i)->pathsVector.end(); ++j) {
437 if (oc.
isSet(
"all-pairs-output")) {
443 std::cout <<
"Success." << std::endl;
471 }
catch (XERCES_CPP_NAMESPACE::SAXParseException& e) {
474 }
catch (XERCES_CPP_NAMESPACE::SAXException& e) {
482 if (std::string(e.what()) != std::string(
"Process Error") && std::string(e.what()) != std::string(
"")) {
492 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
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) ...
bool hasPermissions() const
const std::vector< ODCell * > & getCells()
static void init()
Initialises the xml-subsystem.
Computes the shortest path through a network using the Dijkstra algorithm.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
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.
void computeRoutes(RONet &net, OptionsCont &oc, ODMatrix &matrix)
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
SUMOReal getFlow(const SUMOReal time) const
SUMOReal getNumLoaded() const
Returns the number of loaded vehicles.
static SUMOReal getNoiseEffort(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
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.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
int main(int argc, char **argv)
SUMOReal getTravelTime(const ROEdge *const edge, const ROVehicle *const , SUMOReal)
static std::ostream & writeFloat(std::ostream &strm, SUMOReal value)
Writes a float binary.
std::string time2string(SUMOTime t)
Computes the shortest path through a network using the A* algorithm.
EdgeFunc getFunc() const
Returns the function of the edge.
static bool checkOptions()
Checks set options from the OptionsCont-singleton for being valid for usage within duarouter...
void computeAllPairs(RONet &net, OptionsCont &oc)
An internal edge which models vehicles driving across a junction. This is currently not used for rout...
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
std::vector< const ROEdge * > ConstROEdgeVector
Parser and container for routes during their loading.
std::vector< RORoute * > pathsVector
the list of paths / routes
const std::string DEFAULT_VTYPE_ID
static void close()
Closes all of an applications subsystems.
Computes the shortest path through a network using the Dijkstra algorithm.
const std::map< std::string, ROEdge * > & getEdgeMap() const
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static OptionsCont & getOptions()
Retrieves the options.
void openOutput(const OptionsCont &options, const std::string altFilename="")
Opens the output for computed routes.
static void initRandGlobal(MTRand *which=0)
Reads the given random number options and initialises the random number generator in accordance...
void loadMatrix(OptionsCont &oc)
read a matrix in one of several formats
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const std::string & getID() const
Returns the id.
A vehicle as used by router.
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary ...
A single O/D-matrix cell.
void initNet(RONet &net, ROLoader &loader, OptionsCont &oc)
std::string origin
Name of the origin district.
static SUMOReal getPenalizedTT(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the traveltime on an edge including penalties.
An O/D (origin/destination) matrix.
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
void loadRoutes(OptionsCont &oc, SUMOSAXHandler &handler)
read SUMO routes
SUMOTime string2time(const std::string &r)
A container for districts.
SUMOReal vehicleNumber
The number of vehicles.
std::map< SUMOTime, std::vector< std::string > > departures
mapping of departure times to departing vehicles, if already fixed
int getEdgeNo() const
Returns the total number of edges the network contains including internal edges.
void writeInterval(OutputDevice &dev, const SUMOTime begin, const SUMOTime end, const RONet &net, const ROVehicle *const veh)
static SUMOReal getTravelTime(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the traveltime on an edge without penalties.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
static SUMOReal getPenalizedEffort(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the effort to pass an edge including penalties.
SUMOTime begin
The begin time this cell describes.
virtual void loadNet(RONet &toFill, ROAbstractEdgeBuilder &eb)
Loads the network.
A basic edge for routing applications.
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
static void fillOptions()
Inserts options used by duarouter into the OptionsCont-singleton.
static SUMOReal getCapacity(const ROEdge *edge)
The router's network representation.
Structure representing possible vehicle parameter.
SUMOReal getLength() const
Returns the length of the edge.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
void applyCurve(const Distribution_Points &ps)
Splits the stored cells dividing them on the given time line.
static void setGlobalOptions(const bool interpolate)
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.
Static storage of an output device and its base (abstract) implementation.
virtual SUMOReal recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) const =0
std::string destination
Name of the destination district.
bool closeTag()
Closes the most recently opened tag.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
SUMOTime end
The end time this cell describes.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void clear()
Clears information whether an error occured previously.
#define WRITE_MESSAGE(msg)
static void initOutputOptions()
A basic edge for routing applications.
static std::string _2str(const int var)
convert int to string
bool loadWeights(RONet &net, const std::string &optionName, const std::string &measure, const bool useLanes, const bool boundariesOverride)
Loads the net weights.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
vehicles ignoring classes
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
An output device that encapsulates an ofstream.
Distribution_Points parseTimeLine(const std::vector< std::string > &def, bool timelineDayInHours)
split the given timeline
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
bool isBinary() const
Returns whether we have a binary output.
Computes the shortest path through a contracted network.
static SUMOReal getTravelTimeStatic(const ROEdge *const edge, const ROVehicle *const veh, SUMOReal time)
Returns the travel time for the given edge.
void setApplicationName(const std::string &appName, const std::string &fullName)
Sets the application name.