59 #define BEST_LANE_LOOKAHEAD 3000.0 73 const std::string& streetName,
74 const std::string& edgeType,
76 Named(id), myNumericalID(numericalID), myLanes(0),
77 myLaneChanger(0), myFunction(function), myVaporizationRequests(0),
78 myLastFailedInsertionTime(-1),
79 myFromJunction(0), myToJunction(0),
80 myStreetName(streetName),
85 myEmptyTraveltime(-1.),
87 myAmRoundabout(false),
98 for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
114 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
117 double widthBefore = 0;
118 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
119 (*i)->setRightSideOnEdge(widthBefore, (
int)
mySublaneSides.size());
124 widthBefore += (*i)->getWidth();
139 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
142 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
145 if (minPenalty == -1) {
146 minPenalty = linkPenalty;
148 minPenalty =
MIN2(minPenalty, linkPenalty);
152 if (minPenalty > 0) {
161 myAllowed[0] =
new std::vector<MSLane*>();
162 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
165 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
166 (*j)->initParallelLinks();
167 MSLane* toL = (*j)->getLane();
179 myAllowed[&to] =
new std::vector<MSLane*>();
186 toL = (*j)->getViaLane();
228 for (std::vector<MSLane*>::const_iterator it =
myLanes->begin(); it !=
myLanes->end(); ++it) {
251 for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
260 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
283 if (index == (
int)
myLanes->size()) {
286 const int resultIndex = index + offset;
287 if (resultIndex >= (
int)
myLanes->size() || resultIndex < 0) {
290 return (*
myLanes)[resultIndex];
295 const std::vector<MSLane*>*
301 const std::vector<MSLane*>*
307 const std::vector<MSLane*>*
309 AllowedLanesCont::const_iterator it = c.find(dest);
317 const std::vector<MSLane*>*
333 if (MSDevice_Routing::isParallel()) {
334 MSDevice_Routing::lock();
337 for (AllowedLanesCont::const_iterator i1 =
myAllowed.begin(); i1 !=
myAllowed.end(); ++i1) {
338 const MSEdge* edge = i1->first;
339 const std::vector<MSLane*>* lanes = i1->second;
342 for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
344 if ((*i2)->allowsVehicleClass(vclass)) {
350 for (MSLinkCont::const_iterator it_link = lc.begin(); it_link != lc.end(); ++it_link) {
351 const MSLane* targetLane = (*it_link)->getLane();
368 if (MSDevice_Routing::isParallel()) {
369 MSDevice_Routing::unlock();
399 double largestGap = 0;
402 for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
403 const double occupancy = (*i)->getBruttoOccupancy();
404 if (occupancy < leastOccupancy) {
406 leastOccupancy = occupancy;
408 const MSVehicle* last = (*i)->getLastFullVehicle();
410 if (lastGap > largestGap) {
411 largestGap = lastGap;
447 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
448 MSVehicle* last = (*i)->getLastFullVehicle();
487 const std::vector<MSVehicle::LaneQ>& bl = veh.
getBestLanes();
488 double bestLength = -1;
489 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
490 if ((*i).length > bestLength) {
491 bestLength = (*i).length;
497 double departPos = 0;
502 std::vector<MSLane*>* bestLanes =
new std::vector<MSLane*>();
503 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
504 if (((*i).length - departPos) >= bestLength) {
505 bestLanes->push_back((*i).lane);
514 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
540 if (speedFactorParams[1] > 0.) {
548 "' is too high for the departure edge '" +
getID() +
"'.");
565 v.
getID() +
"'. Inserting at lane end instead.");
580 while (segment != 0 && !result) {
603 if (insertionLane == 0) {
611 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
612 const double occupancy = (*i)->getBruttoOccupancy();
621 if (insertionLane == 0) {
637 bool success = insertionLane->
insertVehicle(static_cast<MSVehicle&>(v));
659 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
662 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
678 assert(followerAfterInternal != 0);
692 const MSEdge* result =
this;
706 const double vehNo = (double) segment->getCarNumber();
707 v += vehNo * segment->getMeanSpeed();
714 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
715 const double vehNo = (double)(*i)->getVehicleNumber();
716 v += vehNo * (*i)->getMeanSpeed();
729 assert(minSpeed > 0);
746 DictType::iterator it =
myDict.find(
id);
762 DictType::iterator it =
myDict.find(
id);
773 return (
int)
myDict.size();
785 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
795 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
796 into.push_back((*i).first);
803 const std::string& rid) {
805 std::istringstream in(desc, std::ios::binary);
818 const std::string& rid) {
819 for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
823 throw ProcessError(
"The edge '" + *i +
"' within the route " + rid +
" is not known." 824 +
"\n The route can not be build.");
826 into.push_back(edge);
855 return myLanes->empty() ? 1 :
getLanes()[0]->getLengthGeometryFactor();
868 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
869 (*i)->setMaxSpeed(val);
876 std::vector<MSTransportable*>
880 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
882 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
883 const std::vector<MSTransportable*>& persons = (*j)->getPersons();
884 result.insert(result.end(), persons.begin(), persons.end());
886 (*i)->releaseVehicles();
894 std::vector<MSTransportable*>
933 if (MSDevice_Routing::isParallel()) {
934 MSDevice_Routing::lock();
944 if ((*it)->isTazConnector()) {
945 i->second.push_back(*it);
947 const std::vector<MSLane*>* allowed =
allowedLanes(*it, vClass);
948 if (allowed != 0 && allowed->size() > 0) {
949 i->second.push_back(*it);
956 if (MSDevice_Routing::isParallel()) {
957 MSDevice_Routing::unlock();
966 return (!
myLanes->empty() &&
myLanes->back()->getOpposite() != 0 &&
974 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
976 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
977 if (!(*j)->havePriority()) {
992 for (ConstMSEdgeVector::const_iterator it = candidates.begin(); it != candidates.end(); it++) {
1008 std::vector<MSLane*>::const_iterator it1 =
myLanes->begin();
1009 std::vector<MSLane*>::const_reverse_iterator it2 = other->
getLanes().rbegin();
1011 if ((*it1)->getShape().reverse() != (*it2)->getShape()) {
1016 }
while (it1 !=
myLanes->end());
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge'e lanes.
const SumoXMLEdgeFunc myFunction
the purpose of the edge
double getInternalFollowingLengthTo(const MSEdge *followerAfterInternal) const
returns the length of all internal edges on the junction until reaching the non-internal edge followe...
bool myAmDelayed
whether this edge had a vehicle with less than max speed on it
double getLength() const
return the length of the edge
static double gLateralResolution
bool allowsLaneChanging()
MSEdge & getEdge() const
Returns the lane's edge.
virtual double getChosenSpeedFactor() const =0
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.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
Sorts edges by their ids.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
A vehicle from the mesoscopic point of view.
void addSuccessor(MSEdge *edge)
Adds an edge to the list of edges which may be reached from this edge and to the incoming of the othe...
MSEdge(const std::string &id, int numericalID, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, int priority)
Constructor.
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
static double gMesoTLSPenalty
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static int dictSize()
Returns the number of edges.
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
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.
bool isTazConnector() const
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.
static MSEdgeVector myEdges
Static list of edges.
std::vector< double > & getParameter()
Returns the parameters of this distribution.
MSLane * getViaLane() const
Returns the following inner lane.
double getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
ClassedAllowedLanesCont myClassedAllowed
From vehicle class to lanes allowed to be used by it.
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
The least occupied lane is used.
The link is a 180 degree turn.
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
std::string time2string(SUMOTime t)
virtual ~MSEdge()
Destructor.
const MSEdge * myOppositingSuperposableEdge
the oppositing superposble edge
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
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
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...
std::vector< double > mySublaneSides
the right side for each sublane on this edge
double getPositionOnLane() const
Get the vehicle's position along the lane.
This is an uncontrolled, right-before-left link.
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
The lane is chosen randomly.
std::vector< const MSEdge * > ConstMSEdgeVector
bool hasMinorLink() const
whether any lane has a minor link
const SVCPermissions SVCAll
all VClasses are allowed
int myVaporizationRequests
Vaporizer counter.
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.
#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.
double computeChosenSpeedDeviation(std::mt19937 *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
SumoXMLEdgeFunc getFunction() const
Returns the edge type (SumoXMLEdgeFunc)
void checkAndRegisterBiDirEdge()
check and register the opposite superposable edge if any
The link is a straight direction.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
Performs lane changing of vehicles.
double departSpeed
(optional) The initial speed of the vehicle
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()
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the maximum speed the vehicle may use on this edge.
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
#define BEST_LANE_LOOKAHEAD
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
bool allowsVehicleClass(SUMOVehicleClass vclass) const
virtual void setChosenSpeedFactor(const double factor)=0
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
double myLength
the length of the edge (cached value for speedup)
std::vector< MSTransportable * > getSortedContainers(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's containers sorted by pos.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
double getDepartPosBound(const MSVehicle &veh, bool upper=true) const
return upper bound for the depart position on this edge
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.
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.
double getDistanceTo(const MSEdge *other) const
optimistic air distance heuristic for use in routing
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.
MSJunction * myToJunction
MSLaneChanger * myLaneChanger
This member will do the lane-change.
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.
bool myAmFringe
whether this edge is at the network fringe
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.
const ConstMSEdgeVector & getOutgoing() const
int getIndex() const
Returns the lane's index.
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.
std::vector< MSVehicle * > VehCont
Container for vehicles.
bool isSuperposable(const MSEdge *other)
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.
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.
No information given; use default.
const MSEdge * getNormalBefore() const
if this edge is an internal edge, return its first normal predecessor, otherwise the edge itself ...
void buildLaneChanger()
Has to be called after all sucessors and predecessors have been set (after closeBuilding()) ...
double getLength() const
Get vehicle's length [m].
double departPos
(optional) The position the vehicle shall depart from
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
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...
double distanceTo2D(const Position &p) const
returns the euclidean distance in the x-y-plane
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
static const T & getRandomFrom(const std::vector< T > &v, std::mt19937 *rng=0)
Returns a random element from the given vector.
A single mesoscopic segment (cell)
MSLane * getFreeLane(const std::vector< MSLane * > *allowed, const SUMOVehicleClass vclass, double departPos) const
Finds the emptiest lane allowing the vehicle class.
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.
double myWidth
Edge width [m].
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
MSJunction * myFromJunction
the junctions for this edge
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)
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)
void setMaxSpeed(double val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
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.
Sorts transportables by their positions.
const MSJunction * getFromJunction() const
const MSEdgeVector & getSuccessors() const
Returns the following edges.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
No information given; use default.
A free position is chosen.
double getLengthGeometryFactor() const
return shape.length() / myLength
std::vector< MSEdge * > MSEdgeVector
MSLane * rightLane(const MSLane *const lane) const
Returns the lane right to the one given, 0 if the given lane is rightmost.
Insert behind the last vehicle as close as possible to still allow the specified departSpeed. Fallback to DEPART_POS_BASE if there is no vehicle on the departLane yet.
static double getAssumedSpeed(const MSEdge *edge)
return current travel speed assumption
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
int operator()(const MSTransportable *const c1, const MSTransportable *const c2) const
comparing operator
Boundary myTazBoundary
The bounding rectangle of incoming or outgoing edges for taz connectors.
double getMeanSpeed() const
get the mean speed
const std::vector< MSLane * > * getAllowedLanesWithDefault(const AllowedLanesCont &c, const MSEdge *dest) const
lookup in map and return 0 if not found
static SUMOTime gLaneChangeDuration
MSEdgeVector myPredecessors
The preceeding edges.
Representation of a lane in the micro simulation.
double myEmptyTraveltime
the traveltime on the empty edge (cached value for speedup)
double getCurrentTravelTime(const double 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
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
std::string id
The vehicle's id.
virtual double getEdgePos(SUMOTime now) const =0
std::set< int > myFailedInsertionMemory
A cache for the rejected insertion attempts. Used to assure that no further insertion attempts are ma...
const MSJunction * getToJunction() const
const Position & getPosition() const
std::set< MSTransportable * > myPersons
Persons on the edge for drawing and pushbutton.