60 #define BEST_LANE_LOOKAHEAD 3000.0 74 const std::string& streetName,
75 const std::string& edgeType,
77 Named(id), myNumericalID(numericalID), myLanes(0),
78 myLaneChanger(0), myFunction(function), myVaporizationRequests(0),
79 myLastFailedInsertionTime(-1),
80 myFromJunction(0), myToJunction(0),
81 myStreetName(streetName),
86 myEmptyTraveltime(-1.),
88 myAmRoundabout(false) {}
97 for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
113 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
116 double widthBefore = 0;
117 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
118 (*i)->setRightSideOnEdge(widthBefore, (
int)
mySublaneSides.size());
123 widthBefore += (*i)->getWidth();
138 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
141 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
144 if (minPenalty == -1) {
145 minPenalty = linkPenalty;
147 minPenalty =
MIN2(minPenalty, linkPenalty);
151 if (minPenalty > 0) {
160 myAllowed[0] =
new std::vector<MSLane*>();
161 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
164 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
165 (*j)->initParallelLinks();
166 MSLane* toL = (*j)->getLane();
178 myAllowed[&to] =
new std::vector<MSLane*>();
182 toL = (*j)->getViaLane();
224 for (std::vector<MSLane*>::const_iterator it =
myLanes->begin(); it !=
myLanes->end(); ++it) {
247 for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
256 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
279 if (index == (
int)
myLanes->size()) {
282 const int resultIndex = index + offset;
283 if (resultIndex >= (
int)
myLanes->size() || resultIndex < 0) {
286 return (*
myLanes)[resultIndex];
291 const std::vector<MSLane*>*
297 const std::vector<MSLane*>*
303 const std::vector<MSLane*>*
305 AllowedLanesCont::const_iterator it = c.find(dest);
313 const std::vector<MSLane*>*
329 if (MSDevice_Routing::isParallel()) {
330 MSDevice_Routing::lock();
333 for (AllowedLanesCont::const_iterator i1 =
myAllowed.begin(); i1 !=
myAllowed.end(); ++i1) {
334 const MSEdge* edge = i1->first;
335 const std::vector<MSLane*>* lanes = i1->second;
338 for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
340 if ((*i2)->allowsVehicleClass(vclass)) {
346 for (MSLinkCont::const_iterator it_link = lc.begin(); it_link != lc.end(); ++it_link) {
347 const MSLane* targetLane = (*it_link)->getLane();
364 if (MSDevice_Routing::isParallel()) {
365 MSDevice_Routing::unlock();
395 double largestGap = 0;
398 for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
399 const double occupancy = (*i)->getBruttoOccupancy();
400 if (occupancy < leastOccupancy) {
402 leastOccupancy = occupancy;
404 const MSVehicle* last = (*i)->getLastFullVehicle();
406 if (lastGap > largestGap) {
407 largestGap = lastGap;
443 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
444 MSVehicle* last = (*i)->getLastFullVehicle();
483 const std::vector<MSVehicle::LaneQ>& bl = veh.
getBestLanes();
484 double bestLength = -1;
485 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
486 if ((*i).length > bestLength) {
487 bestLength = (*i).length;
493 double departPos = 0;
498 std::vector<MSLane*>* bestLanes =
new std::vector<MSLane*>();
499 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
500 if (((*i).length - departPos) >= bestLength) {
501 bestLanes->push_back((*i).lane);
510 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
536 if (speedFactorParams[1] > 0.) {
544 "' is too high for the departure edge '" +
getID() +
"'.");
558 v.
getID() +
"'. Inserting at lane end instead.");
573 while (segment != 0 && !result) {
596 if (insertionLane == 0) {
604 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
605 const double occupancy = (*i)->getBruttoOccupancy();
614 if (insertionLane == 0) {
630 bool success = insertionLane->
insertVehicle(static_cast<MSVehicle&>(v));
652 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
655 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
671 assert(followerAfterInternal != 0);
689 const double vehNo = (double) segment->getCarNumber();
690 v += vehNo * segment->getMeanSpeed();
697 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
698 const double vehNo = (double)(*i)->getVehicleNumber();
699 v += vehNo * (*i)->getMeanSpeed();
712 assert(minSpeed > 0);
729 DictType::iterator it =
myDict.find(
id);
745 DictType::iterator it =
myDict.find(
id);
756 return (
int)
myDict.size();
768 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
777 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
778 into.push_back((*i).first);
785 const std::string& rid) {
787 std::istringstream in(desc, std::ios::binary);
800 const std::string& rid) {
801 for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
805 throw ProcessError(
"The edge '" + *i +
"' within the route " + rid +
" is not known." 806 +
"\n The route can not be build.");
808 into.push_back(edge);
832 return myLanes->empty() ? 1 :
getLanes()[0]->getLengthGeometryFactor();
845 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
846 (*i)->setMaxSpeed(val);
853 std::vector<MSTransportable*>
857 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
859 for (MSLane::VehCont::const_iterator j = vehs.begin(); j != vehs.end(); ++j) {
860 const std::vector<MSTransportable*>& persons = (*j)->getPersons();
861 result.insert(result.end(), persons.begin(), persons.end());
863 (*i)->releaseVehicles();
871 std::vector<MSTransportable*>
895 if (MSDevice_Routing::isParallel()) {
896 MSDevice_Routing::lock();
907 i->second.push_back(*it);
909 const std::vector<MSLane*>* allowed =
allowedLanes(*it, vClass);
910 if (allowed != 0 && allowed->size() > 0) {
911 i->second.push_back(*it);
918 if (MSDevice_Routing::isParallel()) {
919 MSDevice_Routing::unlock();
928 return (!
myLanes->empty() &&
myLanes->back()->getOpposite() != 0 &&
936 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
938 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
939 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
double getDepartPosBound(const MSVehicle &veh, bool upper=true) const
return upper bound for the depart position on this edge
double getBruttoOccupancy() const
Returns the brutto (including minGaps) occupancy of this lane during the last step.
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
static double gLateralResolution
MSLane * getLogicalPredecessorLane() const
get the most likely precedecessor lane (sorted using by_connections_to_sorter). The result is cached ...
bool allowsLaneChanging()
bool insertVehicle(SUMOVehicle &v, SUMOTime time, const bool checkOnly=false, const bool forceCheck=false) const
Tries to insert the given vehicle into the network.
std::set< MSTransportable * > myContainers
Containers on the edge.
MSEdge & getEdge() const
Returns the lane's 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.
Sorts edges by their ids.
A vehicle from the mesoscopic point of view.
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
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...
MSLane * getLane() const
Returns the connected lane.
SUMOTime getMesoTLSPenalty() const
Returns the time penalty for passing a tls-controlled link (meso)
static double gMesoTLSPenalty
double getLengthGeometryFactor() const
return shape.length() / myLength
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
static int dictSize()
Returns the number of edges.
bool initialise(MEVehicle *veh, SUMOTime time)
Inserts (emits) vehicle into the segment.
double distanceTo2D(const Position &p2) const
returns the euclidean distance in the x-y-plane
static void readEdgeVector(std::istream &in, std::vector< const E *> &edges, const std::string &rid)
Reads an edge vector binary.
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.
const EdgeBasicFunction myFunction
the purpose of the edge
double getPositionOnLane() const
Get the vehicle's position along the lane.
ClassedAllowedLanesCont myClassedAllowed
From vehicle class to lanes allowed to be used by it.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
The least occupied lane is used.
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
std::string time2string(SUMOTime t)
virtual ~MSEdge()
Destructor.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getMeanSpeed() const
get the mean speed
const MSRoute & getRoute() const
Returns the current route.
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
This is an uncontrolled, right-before-left link.
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
The lane is chosen randomly.
std::vector< const MSEdge * > ConstMSEdgeVector
void initialize(const std::vector< MSLane *> *lanes)
Initialize the edge.
const std::string & getID() const
Returns the id.
const SVCPermissions SVCAll
all VClasses are allowed
int myVaporizationRequests
Vaporizer counter.
EdgeBasicFunction
Defines possible edge types.
int operator()(const MSTransportable *const c1, const MSTransportable *const c2) const
comparing operator
double getLength() const
return the length of the edge
int size() const
Returns the number of edges to pass.
const MSJunction * getToJunction() const
std::vector< MSTransportable * > getSortedPersons(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's persons sorted by pos.
The least occupied lane from best lanes.
The position is chosen randomly.
SUMOTime decVaporization(SUMOTime t)
Disables vaporization.
int getNumericalID() const
Returns the numerical id of the edge.
This is an uncontrolled, all-way stop link.
double getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
#define WRITE_WARNING(msg)
std::map< std::string, MSEdge *> DictType
definition of the static dictionary type
The car-following model and parameter.
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
static OptionsCont & getOptions()
Retrieves the options.
Performs lane changing of vehicles.
LinkState getState() const
Returns the current state of the link.
double getCurrentTravelTime(const double minSpeed=NUMERICAL_EPS) const
Computes and returns the current travel time for this edge.
bool hasSpaceFor(const MEVehicle *veh, SUMOTime entryTime, bool init=false) const
Returns whether the given vehicle would still fit into the segment.
The link is a straight direction.
Performs lane changing of vehicles.
double departSpeed
(optional) The initial speed of the vehicle
A road/street connecting two junctions.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
SUMOTime myLastFailedInsertionTime
The time of last insertion failure.
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
std::map< SUMOVehicleClass, MSEdgeVector > myClassesSuccessorMap
The successors available for a given vClass.
void rebuildAllowedLanes()
int getIndex() const
Returns the lane's index.
#define BEST_LANE_LOOKAHEAD
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
virtual void setChosenSpeedFactor(const double factor)=0
double myLength
the length of the edge (cached value for speedup)
The edge is a district edge.
MSLane * getViaLane() const
Returns the following inner lane.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Representation of a vehicle.
virtual double getEdgePos(SUMOTime now) const =0
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.
bool hasMinorLink() const
whether any lane has a minor link
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.
MSEdgeVector mySuccessors
The succeeding edges.
bool havePriority() const
Returns whether this link is a major link.
MSLaneChanger * myLaneChanger
This member will do the lane-change.
double getRoutingSpeed() const
Returns the averaged speed used by the routing device.
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.
MSLane * leftLane(const MSLane *const lane) const
Returns the lane left to the one given, 0 if the given lane is leftmost.
static double rand()
Returns a random real number in [0, 1)
static SUMOTime gMesoMinorPenalty
const Position & getPosition() const
const std::string & getID() const
returns the id of the transportable
MSLane * getDepartLane(MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
const std::vector< MSLane * > * myLanes
Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane...
bool isInternal() const
return whether this edge is an internal edge
virtual double getChosenSpeedFactor() const =0
If a fixed number of random choices fails, a free position is chosen.
std::vector< MSVehicle * > VehCont
Container for vehicles.
bool canChangeToOpposite()
whether this edge allows changing to the opposite direction edge
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)
const MSEdge * getInternalFollowingEdge(const MSEdge *followerAfterInternal) const
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the maximum speed the vehicle may use on this edge.
std::vector< std::string > getVector()
SVCPermissions myCombinedPermissions
The union of lane permissions for this edge.
No information given; use default.
void buildLaneChanger()
Has to be called after all sucessors and predecessors have been set (after closeBuilding()) ...
double departPos
(optional) The position the vehicle shall depart from
Structure representing possible vehicle parameter.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
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...
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
virtual void changeLanes(SUMOTime t)
Performs lane changing on this edge.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
const MSJunction * getFromJunction() const
A single mesoscopic segment (cell)
double myWidth
Edge width [m].
double getInternalFollowingLengthTo(const MSEdge *followerAfterInternal) const
returns the length of all internal edges on the junction until reaching the non-internal edge followe...
const MSEdgeVector & getSuccessors() const
Returns the following edges.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
double getLength() const
Get vehicle's length [m].
void setMaxSpeed(double val) const
Sets a new maximum speed for all lanes (used by TraCI and MSCalibrator)
bool allowsVehicleClass(SUMOVehicleClass vclass) const
std::map< const MSEdge *, std::vector< MSLane * > *> AllowedLanesCont
Suceeding edges (keys) and allowed lanes to reach these edges (values).
static DictType myDict
Static dictionary to associate string-ids with objects.
Sorts transportables by their positions.
double getDistanceTo(const MSEdge *other) const
optimistic air distance heuristic for use in routing
double computeChosenSpeedDeviation(MTRand *rng, const double minDev=-1.) const
Computes and returns the speed deviation.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
No information given; use default.
A free position is chosen.
std::vector< MSEdge * > MSEdgeVector
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.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
const std::vector< LaneQ > & getBestLanes() const
Returns the description of best lanes to use in order to continue the route.
static double getAssumedSpeed(const MSEdge *edge)
return current travel speed assumption
The edge is an internal edge.
static SUMOTime gLaneChangeDuration
MSEdgeVector myPredecessors
The preceeding edges.
std::vector< MSTransportable * > getSortedContainers(SUMOTime timestep, bool includeRiding=false) const
Returns this edge's containers sorted by pos.
Representation of a lane in the micro simulation.
MSLane * rightLane(const MSLane *const lane) const
Returns the lane right to the one given, 0 if the given lane is rightmost.
double myEmptyTraveltime
the traveltime on the empty edge (cached value for speedup)
MSLane * getFreeLane(const std::vector< MSLane *> *allowed, const SUMOVehicleClass vclass, double departPos) const
Finds the emptiest lane allowing the vehicle class.
const Distribution_Parameterized & getSpeedFactor() const
Returns this type's speed factor.
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.
virtual const std::string & getID() const =0
Get the vehicle's ID.
const std::vector< MSLane * > * getAllowedLanesWithDefault(const AllowedLanesCont &c, const MSEdge *dest) const
lookup in map and return 0 if not found
vehicles ignoring classes
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
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...
std::set< MSTransportable * > myPersons
Persons on the edge for drawing and pushbutton.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.