60 #ifdef CHECK_MEMORY_LEAKS 62 #endif // CHECK_MEMORY_LEAKS 77 const std::string& streetName,
78 const std::string& edgeType,
80 Named(id), myNumericalID(numericalID), myLanes(0),
81 myLaneChanger(0), myFunction(function), myVaporizationRequests(0),
82 myLastFailedInsertionTime(-1),
83 myFromJunction(0), myToJunction(0),
84 myStreetName(streetName),
89 myEmptyTraveltime(-1.),
91 myAmRoundabout(false) {}
100 for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
116 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
121 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
122 (*i)->setRightSideOnEdge(widthBefore, (
int)
mySublaneSides.size());
127 widthBefore += (*i)->getWidth();
143 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
146 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
149 if (minPenalty == -1) {
150 minPenalty = linkPenalty;
152 minPenalty =
MIN2(minPenalty, linkPenalty);
156 if (minPenalty > 0) {
165 myAllowed[0] =
new std::vector<MSLane*>();
166 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
169 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
170 (*j)->initParallelLinks();
171 MSLane* toL = (*j)->getLane();
183 myAllowed[&to] =
new std::vector<MSLane*>();
187 #ifdef HAVE_INTERNAL_LANES 188 toL = (*j)->getViaLane();
231 for (std::vector<MSLane*>::const_iterator it =
myLanes->begin(); it !=
myLanes->end(); ++it) {
254 for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
263 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
286 if (index == (
int)
myLanes->size()) {
289 const int resultIndex = index + offset;
290 if (resultIndex >= (
int)
myLanes->size() || resultIndex < 0) {
293 return (*
myLanes)[resultIndex];
298 const std::vector<MSLane*>*
304 const std::vector<MSLane*>*
310 const std::vector<MSLane*>*
312 AllowedLanesCont::const_iterator it = c.find(dest);
320 const std::vector<MSLane*>*
336 if (MSDevice_Routing::isParallel()) {
337 MSDevice_Routing::lock();
340 for (AllowedLanesCont::const_iterator i1 =
myAllowed.begin(); i1 !=
myAllowed.end(); ++i1) {
341 const MSEdge* edge = i1->first;
342 const std::vector<MSLane*>* lanes = i1->second;
345 for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
347 if ((*i2)->allowsVehicleClass(vclass)) {
353 for (MSLinkCont::const_iterator it_link = lc.begin(); it_link != lc.end(); ++it_link) {
354 const MSLane* targetLane = (*it_link)->getLane();
371 if (MSDevice_Routing::isParallel()) {
372 MSDevice_Routing::unlock();
403 for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
404 const SUMOReal occupancy = (*i)->getBruttoOccupancy();
405 if (occupancy < leastOccupancy) {
407 leastOccupancy = occupancy;
435 const std::vector<MSVehicle::LaneQ>& bl = veh.
getBestLanes();
437 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
438 if ((*i).length > bestLength) {
439 bestLength = (*i).length;
442 std::vector<MSLane*>* bestLanes =
new std::vector<MSLane*>();
443 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
444 if ((*i).length == bestLength) {
445 bestLanes->push_back((*i).lane);
454 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
476 if (
isTaz() && checkOnly) {
490 "' is too high for the departure edge '" +
getID() +
"'.");
499 WRITE_WARNING(
"Removing vehicle '" + pars.
id +
"' which has no valid route.");
516 v.
getID() +
"'. Inserting at lane end instead.");
531 while (segment != 0 && !result) {
554 if (insertionLane == 0) {
562 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
563 const SUMOReal occupancy = (*i)->getBruttoOccupancy();
572 if (insertionLane == 0) {
588 bool success = insertionLane->
insertVehicle(static_cast<MSVehicle&>(v));
605 for (std::vector<MSLane*>::const_iterator it =
myLanes->begin(); it !=
myLanes->end(); ++it) {
625 #ifdef HAVE_INTERNAL_LANES 627 MSEdge::getInternalFollowingEdge(
const MSEdge* followerAfterInternal)
const {
629 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
632 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
635 if (link->getViaLane() != 0) {
636 return &link->getViaLane()->getEdge();
655 v += vehNo * segment->getMeanSpeed();
662 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
664 v += vehNo * (*i)->getMeanSpeed();
677 assert(minSpeed > 0);
694 DictType::iterator it =
myDict.find(
id);
710 DictType::iterator it =
myDict.find(
id);
721 return (
int)
myDict.size();
733 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
742 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
743 into.push_back((*i).first);
750 const std::string& rid) {
752 std::istringstream in(desc, std::ios::binary);
765 const std::string& rid) {
766 for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
770 throw ProcessError(
"The edge '" + *i +
"' within the route " + rid +
" is not known." 771 +
"\n The route can not be build.");
773 into.push_back(edge);
791 return getLanes()[0]->getSpeedLimit();
798 return getLanes()[0]->getVehicleMaxSpeed(veh);
805 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
806 (*i)->setMaxSpeed(val);
813 std::vector<MSTransportable*>
821 std::vector<MSTransportable*>
845 if (MSDevice_Routing::isParallel()) {
846 MSDevice_Routing::lock();
857 i->second.push_back(*it);
859 const std::vector<MSLane*>* allowed =
allowedLanes(*it, vClass);
860 if (allowed != 0 && allowed->size() > 0) {
861 i->second.push_back(*it);
868 if (MSDevice_Routing::isParallel()) {
869 MSDevice_Routing::unlock();
878 return (!
myLanes->empty() &&
myLanes->back()->getOpposite() != 0 &&
886 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
888 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
889 if (!(*j)->havePriority()) {
static const T & getRandomFrom(const std::vector< T > &v)
Returns a random element from the given vector.
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge'e lanes.
bool myAmDelayed
whether this edge had a vehicle with less than max speed on it
bool allowsLaneChanging()
MSEdge & getEdge() const
Returns the lane's edge.
std::set< MSTransportable * > myContainers
Containers on the edge.
Representation of a vehicle in the micro simulation.
static void insertIDs(std::vector< std::string > &into)
Inserts IDs of all known edges into the given vector.
SUMOReal myLength
the length of the edge (cached value for speedup)
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
Sorts edges by their ids.
A vehicle from the mesoscopic point of view.
virtual SUMOReal getEdgePos(SUMOTime now) const =0
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
SUMOReal getDistanceTo(const MSEdge *other) const
optimistic air distance heuristic for use in routing
static int dictSize()
Returns the number of edges.
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
bool initialise(MEVehicle *veh, SUMOTime time)
Inserts (emits) vehicle into the segment.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
SUMOTime getMesoTLSPenalty() const
Returns the time penalty for passing a tls-controlled link (meso)
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
void recalcCache()
Recalculates the cached values.
This is an uncontrolled, minor link, has to stop.
SUMOReal departSpeed
(optional) The initial speed of the vehicle
static MSEdgeVector myEdges
Static list of edges.
const EdgeBasicFunction myFunction
the purpose of the edge
ClassedAllowedLanesCont myClassedAllowed
From vehicle class to lanes allowed to be used by it.
The least occupied lane is used.
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
static SUMOReal rand()
Returns a random real number in [0, 1)
std::string time2string(SUMOTime t)
virtual ~MSEdge()
Destructor.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const MSRoute & getRoute() const
Returns the current route.
const std::string & getID() const
returns the id of the transportable
SUMOReal computeChosenSpeedDeviation(MTRand *rng, const SUMOReal minDevFactor=0.2) const
Computes and returns the speed deviation.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
This is an uncontrolled, right-before-left link.
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
MSLane * getFreeLane(const std::vector< MSLane * > *allowed, const SUMOVehicleClass vclass) const
Finds the emptiest lane allowing the vehicle class.
The lane is chosen randomly.
std::vector< const MSEdge * > ConstMSEdgeVector
bool hasMinorLink() const
whether any lane has a minor link
const SVCPermissions SVCAll
int myVaporizationRequests
Vaporizer counter.
EdgeBasicFunction
Defines possible edge types.
The least occupied lane from best lanes.
The position is chosen randomly.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
This is an uncontrolled, all-way stop link.
virtual bool hasValidRoute(std::string &msg, const MSRoute *route=0) const =0
Validates the current or given route.
This is an uncontrolled, zipper-merge link.
#define WRITE_WARNING(msg)
std::map< std::string, MSEdge * > DictType
definition of the static dictionary type
The car-following model and parameter.
static OptionsCont & getOptions()
Retrieves the options.
Performs lane changing of vehicles.
The link is a straight direction.
Performs lane changing of vehicles.
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
SUMOTime myLastFailedInsertionTime
The time of last insertion failure.
std::map< SUMOVehicleClass, MSEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
void rebuildAllowedLanes()
SUMOReal getLength() const
return the length of the edge
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
SUMOReal getSpeedDeviation() const
Returns this type's speed deviation.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
The edge is a district edge.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual void setChosenSpeedFactor(const SUMOReal factor)=0
Representation of a vehicle.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
The least occupied lane from lanes which allow the continuation.
virtual SUMOReal getChosenSpeedFactor() const =0
This is an uncontrolled, minor link, has to brake.
AllowedLanesCont myAllowed
Associative container from destination-edge to allowed-lanes.
MSLane * getLane() const
Returns the connected lane.
void updateBestLanes(bool forceRebuild=false, const MSLane *startLane=0)
computes the best lanes to use in order to continue the route
static void clear()
Clears the dictionary.
SVCPermissions myMinimumPermissions
The intersection of lane permissions for this edge.
int size() const
Returns the number of edges to pass.
MSEdgeVector mySuccessors
The succeeding edges.
MSLane * leftLane(const MSLane *const lane) const
Returns the lane left to the one given, 0 if the given lane is leftmost.
MSLaneChanger * myLaneChanger
This member will do the lane-change.
MSEdge(const std::string &id, int numericalID, const EdgeBasicFunction function, const std::string &streetName, const std::string &edgeType, int priority)
Constructor.
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
static SUMOTime gMesoMinorPenalty
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
std::vector< SUMOReal > mySublaneSides
the right side for each sublane on this edge
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false, const bool forceCheck=false) const
Tries to insert the given vehicle into the network.
const std::vector< MSLane * > * myLanes
Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane...
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
int getIndex() const
Returns the lane's index.
SUMOReal getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
bool isInternal() const
return whether this edge is an internal edge
If a fixed number of random choices fails, a free position is chosen.
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
bool canChangeToOpposite()
whether this edge allows changing to the opposite direction edge
MSLane * getDepartLane(MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
Base class for objects which have an id.
The rightmost lane the vehicle may use.
std::vector< MSTransportable * > getSortedContainers(SUMOTime timestep) const
Returns this edge's containers sorted by pos.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::vector< std::string > getVector()
SVCPermissions myCombinedPermissions
The union of lane permissions for this edge.
SUMOReal getSpeedFactor() const
Returns this type's speed factor.
No information given; use default.
void buildLaneChanger()
Has to be called after all sucessors and predecessors have been set (after closeBuilding()) ...
static SUMOReal getAssumedSpeed(const MSEdge *edge)
return current travel speed assumption
EdgeBasicFunction getPurpose() const
Returns the edge type (EdgeBasicFunction)
Structure representing possible vehicle parameter.
bool havePriority() const
Returns whether this link is a major link.
int getNumericalID() const
Returns the numerical id of the edge.
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
MSLane * parallelLane(const MSLane *const lane, int offset) const
Returns the lane with the given offset parallel to the given lane one or 0 if it does not exist...
MSInsertionControl & getInsertionControl()
Returns the insertion control.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
SUMOReal myEmptyTraveltime
the traveltime on the empty edge (cached value for speedup)
SUMOReal getMeanSpeed() const
get the mean speed
A single mesoscopic segment (cell)
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
bool hasSpaceFor(const MEVehicle *veh, SUMOTime entryTime, bool init=false) const
Returns whether the given vehicle would still fit into the segment.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
static SUMOReal gLateralResolution
MESegment * getSegmentForEdge(const MSEdge &e, SUMOReal pos=0)
Get the segment for a given edge at a given position.
virtual const std::string & getID() const =0
Get the vehicle's ID.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
SUMOReal departPos
(optional) The position the vehicle shall depart from
std::map< const MSEdge *, std::vector< MSLane * > * > AllowedLanesCont
Suceeding edges (keys) and allowed lanes to reach these edges (values).
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
SUMOReal distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
static DictType myDict
Static dictionary to associate string-ids with objects.
static void readEdgeVector(std::istream &in, std::vector< const E * > &edges, const std::string &rid)
Reads an edge vector binary.
LinkState getState() const
Returns the current state of the link.
SUMOReal getRoutingSpeed() const
Returns the averaged speed used by the routing device.
Sorts transportables by their positions.
const MSJunction * getFromJunction() const
const MSEdgeVector & getSuccessors() const
Returns the following edges.
SUMOReal getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the maximum speed the vehicle may use on this edge.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
A free position is chosen.
std::vector< MSEdge * > MSEdgeVector
SUMOReal myWidth
Edge width [m].
MSLane * rightLane(const MSLane *const lane) const
Returns the lane right to the one given, 0 if the given lane is rightmost.
int operator()(const MSTransportable *const c1, const MSTransportable *const c2) const
comparing operator
static SUMOReal gMesoTLSPenalty
The edge is an internal edge.
const std::vector< MSLane * > * getAllowedLanesWithDefault(const AllowedLanesCont &c, const MSEdge *dest) const
lookup in map and return 0 if not found
SUMOReal getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
static SUMOTime gLaneChangeDuration
MSEdgeVector myPredecessors
The preceeding edges.
Representation of a lane in the micro simulation.
SUMOReal getCurrentTravelTime(const SUMOReal minSpeed=NUMERICAL_EPS) const
Computes and returns the current travel time for this edge.
static void parseEdgesList(const std::string &desc, ConstMSEdgeVector &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
vehicles ignoring classes
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep) const
Returns this edge's persons sorted by pos.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
std::string id
The vehicle's id.
std::set< int > myFailedInsertionMemory
A cache for the rejected insertion attempts. Used to assure that no further insertion attempts are ma...
void setMaxSpeed(SUMOReal val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
const MSJunction * getToJunction() const
const Position & getPosition() const
std::set< MSTransportable * > myPersons
Persons on the edge for drawing and pushbutton.