58 #ifdef CHECK_MEMORY_LEAKS 60 #endif // CHECK_MEMORY_LEAKS 68 :
Named(id), myLaneID(laneID), myPosition(pos), myType(type), myRoutes(0) {}
96 length += (*i)->getLength();
98 return (distance / length);
110 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
111 std::vector<RODFEdge*> nextDetEdges;
112 std::set<ROEdge*> preSplitEdges;
113 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
115 bool hadSplit =
false;
118 if (find(nextDetEdges.begin(), nextDetEdges.end(), *j) == nextDetEdges.end()) {
119 nextDetEdges.push_back(static_cast<RODFEdge*>(*j));
125 preSplitEdges.insert(*j);
127 if ((*j)->getNumSuccessors() > 1) {
132 std::map<ROEdge*, SUMOReal> inFlows;
134 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
135 std::set<ROEdge*> seen(preSplitEdges);
137 pending.push_back(*i);
139 while (!pending.empty()) {
140 ROEdge* e = pending.back();
148 pending.push_back(e2);
158 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, ++index) {
162 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
168 if (overallProb > 0) {
169 for (std::vector<RODFEdge*>::const_iterator i = nextDetEdges.begin(); i != nextDetEdges.end(); ++i) {
188 std::vector<RODFRouteDesc>& descs =
myRoutes->
get();
190 for (
SUMOTime time = startTime; time < endTime; time += stepOffset) {
192 std::map<ROEdge*, SUMOReal> flowMap;
195 for (std::vector<RODFRouteDesc>::iterator ri = descs.begin(); ri != descs.end(); ++ri, index++) {
197 for (ROEdgeVector::iterator j = (*ri).edges2Pass.begin(); j != (*ri).edges2Pass.end() && prob > 0;) {
204 if (probs.size() == 0) {
209 const std::map<RODFEdge*, SUMOReal>& tprobs = probs[(time - startTime) / stepOffset];
211 for (std::map<RODFEdge*, SUMOReal>::const_iterator k = tprobs.begin(); k != tprobs.end(); ++k) {
212 if (find(j, (*ri).edges2Pass.end(), (*k).first) != (*ri).edges2Pass.end()) {
214 splitEdge = (*k).first;
218 if (splitEdge != 0) {
219 j = find(j, (*ri).edges2Pass.end(), splitEdge);
224 into[time]->add(prob, index);
225 (*ri).overallProb = prob;
231 const std::vector<RODFRouteDesc>&
249 const std::set<const RODFDetector*>&
255 const std::set<const RODFDetector*>&
290 bool includeUnusedRoutes,
301 const std::vector<RODFRouteDesc>& routes =
myRoutes->
get();
303 bool isEmptyDist =
true;
304 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
305 if ((*i).overallProb > 0) {
309 for (std::vector<RODFRouteDesc>::const_iterator i = routes.begin(); i != routes.end(); ++i) {
310 if ((*i).overallProb > 0 || includeUnusedRoutes) {
323 if (insertionsOnly || flows.
knows(
myID)) {
328 for (
SUMOTime time = startTime; time < endTime; time += stepOffset, index++) {
330 assert(index < (
int)mflows.size());
331 const FlowDef& srcFD = mflows[index];
335 int carNo = (int)((srcFD.qPKW + srcFD.qLKW) * scale);
336 for (
int car = 0; car < carNo; ++car) {
340 int destIndex = destDist != 0 && destDist->
getOverallProb() > 0 ? (int) destDist->
get() : -1;
341 if (srcFD.isLKW >= 1) {
342 srcFD.isLKW = srcFD.isLKW - (
SUMOReal) 1.;
350 if (v <= 0 || v > 250) {
369 if (oc.
isSet(
"departlane")) {
374 if (oc.
isSet(
"departpos")) {
375 std::string posDesc = oc.
getString(
"departpos");
376 if (posDesc.substr(0, 8) ==
"detector") {
378 if (posDesc.length() > 8) {
379 if (posDesc[8] ==
'+') {
381 }
else if (posDesc[8] ==
'-') {
394 if (oc.
isSet(
"departspeed")) {
399 if (oc.
isSet(
"arrivallane")) {
402 if (oc.
isSet(
"arrivalpos")) {
405 if (oc.
isSet(
"arrivalspeed")) {
408 if (destIndex >= 0) {
414 srcFD.isLKW += srcFD.fLKW;
444 for (
SUMOTime t = startTime; t < endTime; t += stepOffset, index++) {
445 assert(index < (
int)mflows.size());
446 const FlowDef& srcFD = mflows[index];
448 if (speed <= 0 || speed > 250) {
449 speed = defaultSpeed;
471 for (std::vector<RODFDetector*>::iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
479 if (myDetectorMap.find(dfd->
getID()) != myDetectorMap.end()) {
482 myDetectorMap[dfd->
getID()] = dfd;
483 myDetectors.push_back(dfd);
485 if (myDetectorEdgeMap.find(edgeid) == myDetectorEdgeMap.end()) {
486 myDetectorEdgeMap[edgeid] = std::vector<RODFDetector*>();
488 myDetectorEdgeMap[edgeid].push_back(dfd);
495 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
506 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
507 if ((*i)->hasRoutes()) {
515 const std::vector< RODFDetector*>&
525 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
527 switch ((*i)->getType()) {
553 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
555 switch ((*i)->getType()) {
581 std::vector<std::string> saved;
583 bool lastWasSaved =
true;
584 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
592 lastWasSaved = (*i)->writeRoutes(saved, out);
601 return *(myDetectorMap.find(
id)->second);
607 return *(myDetectorMap.find(
id)->second);
613 return myDetectorMap.find(
id) != myDetectorMap.end();
622 bool writeCalibrators,
623 bool includeUnusedRoutes,
625 bool insertionsOnly) {
627 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
628 (*i)->computeSplitProbabilities(&net, *
this, flows, startTime, endTime, stepOffset);
632 out.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/additional_file.xsd\"");
636 if (separateVTypeOutput) {
637 vTypeOut.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/additional_file.xsd\"");
646 pkwType.
write(vTypeOut);
650 lkwType.
write(vTypeOut);
656 type.
write(vTypeOut);
661 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
665 std::string defFileName;
677 std::map<SUMOTime, RandomDistributor<int>* > dists;
678 if (!insertionsOnly && flows.
knows(det->
getID())) {
682 if (!det->
writeEmitterDefinition(defFileName, dists, flows, startTime, endTime, stepOffset, includeUnusedRoutes, scale, insertionsOnly, defaultSpeed)) {
695 if (separateVTypeOutput) {
721 out.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/additional_file.xsd\"");
722 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
725 const unsigned char col =
static_cast<unsigned char>(128 * flow / flows.
getMaxDetectorFlow() + 128);
727 switch ((*i)->getType()) {
760 assert(myDetectorEdgeMap.find(edge->
getID()) != myDetectorEdgeMap.end());
761 const std::vector<FlowDef>& flows =
static_cast<const RODFEdge*
>(edge)->getFlows();
763 for (std::vector<FlowDef>::const_iterator i = flows.begin(); i != flows.end(); ++i) {
765 if (srcFD.
qLKW >= 0) {
768 if (srcFD.
qPKW >= 0) {
795 const std::string& file,
800 out.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/additional_file.xsd\"");
801 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
818 out.
writeXMLHeader(
"additional",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/additional_file.xsd\"");
819 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
834 bool singleFile,
bool friendly) {
837 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
865 std::map<std::string, RODFDetector*>::iterator ri1 = myDetectorMap.find(
id);
867 myDetectorMap.erase(ri1);
869 std::vector<RODFDetector*>::iterator ri2 =
870 find(myDetectors.begin(), myDetectors.end(), oldDet);
871 myDetectors.erase(ri2);
874 for (std::map<std::string, std::vector<RODFDetector*> >::iterator rr3 = myDetectorEdgeMap.begin(); !found && rr3 != myDetectorEdgeMap.end(); ++rr3) {
875 std::vector<RODFDetector*>& dets = (*rr3).second;
876 for (std::vector<RODFDetector*>::iterator ri3 = dets.begin(); !found && ri3 != dets.end();) {
877 if (*ri3 == oldDet) {
879 ri3 = dets.erase(ri3);
894 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
898 int noFollowerWithRoutes = 0;
899 int noPriorWithRoutes = 0;
901 std::set<const RODFDetector*>::const_iterator j;
902 for (j = prior.begin(); j != prior.end(); ++j) {
903 if (flows.
knows((*j)->getID())) {
907 for (j = follower.begin(); j != follower.end(); ++j) {
908 if (flows.
knows((*j)->getID())) {
909 ++noFollowerWithRoutes;
919 if (noPriorWithRoutes == (
int)prior.size()) {
925 if (noFollowerWithRoutes == (
int)follower.size()) {
936 for (std::vector<RODFDetector*>::const_iterator i = myDetectors.begin(); i != myDetectors.end(); ++i) {
937 if ((*i)->getEdgeID() == edge->
getID()) {
955 const std::vector<std::string>& oldids) {
957 const RODFDetector& first = getDetector(*(oldids.begin()));
961 for (std::vector<std::string>::const_iterator i = oldids.begin(); i != oldids.end(); ++i) {
RODFDetector & getModifiableDetector(const std::string &id) const
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static const RGBColor BLUE
void close()
Closes the device and removes it from the dictionary.
bool writeEmitterDefinition(const std::string &file, const std::map< SUMOTime, RandomDistributor< int > * > &dists, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, bool includeUnusedRoutes, SUMOReal scale, bool insertionsOnly, SUMOReal defaultSpeed) const
const ROEdgeVector & getPredecessors() const
Returns the edge at the given position from the list of incoming edges.
bool detectorsHaveRoutes() const
void addRoute(RODFRouteDesc &nrd)
std::string getEdgeID() const
Returns the id of the edge this detector is placed on.
void removeDetector(const std::string &id)
void saveRoutes(const std::string &file) const
int getNumSuccessors() const
Returns the number of edges this edge is connected to.
RODFDetectorType
Numerical representation of different detector types.
void save(const std::string &file) const
Represents a generic random distribution.
static SUMOReal _2SUMOReal(const E *const data)
converts a char-type array into the SUMOReal value described by it
SUMOReal getAvgSpeedFactorPKW() const
Structure representing possible vehicle parameter.
bool addDetector(RODFDetector *dfd)
void addRoutes(RODFRouteCont *routes)
const RODFDetector & getDetector(const std::string &id) const
SUMOReal speedDev
The standard deviation for speed variations.
RODFDetector(const std::string &id, const std::string &laneID, SUMOReal pos, const RODFDetectorType type)
Constructor.
static std::string escapeXML(const std::string &orig)
Replaces the standard escapes by their XML entities.
std::string time2string(SUMOTime t)
ROEdgeVector edges2Pass
The edges the route is made of.
int getAggFlowFor(const ROEdge *edge, SUMOTime time, SUMOTime period, const RODFDetectorFlows &flows) const
SUMOReal getMaxSpeedFactorPKW() const
void addPriorDetector(const RODFDetector *det)
bool hasDetector(ROEdge *edge) const
const std::vector< RODFDetector * > & getDetectors() const
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
SUMOReal getAvgSpeedFactorLKW() const
const std::string & getID() const
Returns the id.
void writeSpeedTrigger(const RODFNet *const net, const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
RODFDetectorType getType() const
Returns the type of the detector.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
const std::vector< RODFRouteDesc > & getRouteVector() const
bool knows(const std::string &det_id) const
const std::string DEFAULT_VTYPE_ID
std::vector< RODFRouteDesc > & get()
Returns the container of stored routes.
A container for RODFDetectors.
#define UNUSED_PARAMETER(x)
const std::set< const RODFDetector * > & getFollowerDetectors() const
void computeSplitProbabilities(const RODFNet *net, const RODFDetectorCon &detectors, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
static OptionsCont & getOptions()
Retrieves the options.
SUMOReal getMaxSpeedFactorLKW() const
vehicle is a large transport vehicle
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
SUMOReal getFlowSumSecure(const std::string &id) const
void writeEmitters(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, const RODFNet &net, bool writeCalibrators, bool includeUnusedRoutes, SUMOReal scale, bool insertionsOnly)
A not yet defined detector.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
bool writeRoutes(std::vector< std::string > &saved, OutputDevice &out)
SUMOReal speedFactor
The factor by which the maximum speed may deviate from the allowed max speed on the street...
static const RGBColor GREEN
SUMOReal getMaxDetectorFlow() const
SUMOReal getPos() const
Returns the position at which the detector lies.
OutputDevice & writeNonEmptyAttr(const SumoXMLAttr attr, const std::string &val)
writes a string attribute only if it is not the empty string and not the string "default" ...
bool knows(const std::string &id) const
const std::set< const RODFDetector * > & getPriorDetectors() const
std::vector< ROEdge * > ROEdgeVector
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
A detector which had to be discarded (!!!)
const RODFDetector & getAnyDetectorForEdge(const RODFEdge *const edge) const
void writeValidationDetectors(const std::string &file, bool includeSources, bool singleFile, bool friendly)
~RODFDetector()
Destructor.
void setSpeedFactorAndDev(SUMOVTypeParameter &type, SUMOReal maxFactor, SUMOReal avgFactor, SUMOReal dev, bool forceDev)
void clearDists(std::map< SUMOTime, RandomDistributor< int > * > &dists) const
Clears the given distributions map, deleting the timed distributions.
void saveAsPOIs(const std::string &file) const
const int VTYPEPARS_SPEEDDEVIATION_SET
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void writeSingleSpeedTrigger(const std::string &file, const RODFDetectorFlows &flows, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, SUMOReal defaultSpeed)
Definition of the traffic during a certain time containing the flows and speeds.
vehicle is a passenger car (a "normal" car)
A route within the DFROUTER.
A basic edge for routing applications.
std::vector< std::map< RODFEdge *, SUMOReal > > mySplitProbabilities
Base class for objects which have an id.
const int VTYPEPARS_SPEEDFACTOR_SET
T get(MTRand *which=0) const
Draw a sample of the distribution.
SUMOReal computeDistanceFactor(const RODFRouteDesc &rd) const
const std::string & getLaneID() const
Returns the id of the lane this detector is placed on.
int setParameter
Information for the router which parameter were set.
bool detectorsHaveCompleteTypes() const
static int _2int(const E *const data)
converts a char-type array into the integer value described by it
std::string myID
The name of the object.
void write(OutputDevice &dev) const
Writes the vtype.
static const RGBColor RED
const std::vector< std::map< RODFEdge *, SUMOReal > > & getSplitProbabilities() const
std::map< std::string, RODFEdge * > myRoute2Edge
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
void guessEmptyFlows(RODFDetectorFlows &flows)
Class representing a detector within the DFROUTER.
A storage for options typed value containers)
A container for DFROUTER-routes.
std::string routename
The name of the route.
void buildDestinationDistribution(const RODFDetectorCon &detectors, SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset, const RODFNet &net, std::map< SUMOTime, RandomDistributor< int > * > &into) const
const std::vector< FlowDef > & getFlowDefs(const std::string &id) const
void writeEmitterPOIs(const std::string &file, const RODFDetectorFlows &flows)
void setType(RODFDetectorType type)
std::set< const RODFDetector * > myPriorDetectors
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
std::set< const RODFDetector * > myFollowingDetectors
void writeEndRerouterDetectors(const std::string &file)
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
void mesoJoin(const std::string &nid, const std::vector< std::string > &oldids)
void addRouteDesc(RODFRouteDesc &desc)
Adds a route to the container.
const int VTYPEPARS_VEHICLECLASS_SET
void addFollowingDetector(const RODFDetector *det)
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool save(std::vector< std::string > &saved, const std::string &prependix, OutputDevice &out)
Saves routes.
SUMOReal getFloat(const std::string &name) const
Returns the SUMOReal-value of the named option (only for Option_Float)
SUMOReal getOverallProb() const
Return the sum of the probabilites assigned to the members.