SUMOReal MSEdge::getMeanSpeed() const { SUMOReal v = 0; SUMOReal no = 0; if (MSGlobals::gUseMesoSim) { for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { const SUMOReal vehNo = (SUMOReal) segment->getCarNumber(); v += vehNo * segment->getMeanSpeed(); no += vehNo; } if (no == 0) { return getLength() / myEmptyTraveltime; // may include tls-penalty } } else { for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { const SUMOReal vehNo = (SUMOReal)(*i)->getVehicleNumber(); v += vehNo * (*i)->getMeanSpeed(); no += vehNo; } if (no == 0) { return getSpeedLimit(); } } return v / no; }
SUMOReal MSEdge::getCurrentTravelTime(SUMOReal minSpeed) const { assert(minSpeed > 0); if (!myAmDelayed) { return myEmptyTraveltime; } SUMOReal v = 0; #ifdef HAVE_INTERNAL if (MSGlobals::gUseMesoSim) { MESegment* first = MSGlobals::gMesoNet->getSegmentForEdge(*this); unsigned segments = 0; do { v += first->getMeanSpeed(); first = first->getNextSegment(); segments++; } while (first != 0); v /= (SUMOReal) segments; } else { #endif for (std::vector<MSLane*>::const_iterator i = myLanes->begin(); i != myLanes->end(); ++i) { v += (*i)->getMeanSpeed(); } v /= (SUMOReal) myLanes->size(); #ifdef HAVE_INTERNAL } #endif return getLength() / MAX2(minSpeed, v); }
SUMOReal GUIEdge::getFlow() const { SUMOReal flow = 0; for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { flow += (SUMOReal) segment->getCarNumber() * segment->getMeanSpeed(); } return 3600 * flow / (*myLanes)[0]->getLength(); }
bool GUIEdge::setMultiColor(const GUIColorer& c) const { const int activeScheme = c.getActive(); mySegmentColors.clear(); switch (activeScheme) { case 10: // alternating segments for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { mySegmentColors.push_back(c.getScheme().getColor(segment->getIndex() % 2)); } //std::cout << getID() << " scheme=" << c.getScheme().getName() << " schemeCols=" << c.getScheme().getColors().size() << " thresh=" << toString(c.getScheme().getThresholds()) << " segmentColors=" << mySegmentColors.size() << " [0]=" << mySegmentColors[0] << " [1]=" << mySegmentColors[1] << "\n"; return true; case 11: // by segment jammed state for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { mySegmentColors.push_back(c.getScheme().getColor(segment->free() ? 0 : 1)); } return true; case 12: // by segment occupancy for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { mySegmentColors.push_back(c.getScheme().getColor(segment->getRelativeOccupancy())); } return true; case 13: // by segment speed for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed())); } return true; case 14: // by segment flow for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { mySegmentColors.push_back(c.getScheme().getColor(3600 * segment->getCarNumber() * segment->getMeanSpeed() / segment->getLength())); } return true; case 15: // by segment relative speed for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { mySegmentColors.push_back(c.getScheme().getColor(segment->getMeanSpeed() / getAllowedSpeed())); } return true; default: return false; } }
SUMOReal GUIEdge::getMeanSpeed() const { SUMOReal v = 0; SUMOReal no = 0; for (MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this); segment != 0; segment = segment->getNextSegment()) { SUMOReal vehNo = (SUMOReal) segment->getCarNumber(); v += vehNo * segment->getMeanSpeed(); no += vehNo; } if (no == 0) { return getSpeedLimit(); } return v / no; }