50 #include <mesosim/MELoop.h>
51 #include <mesosim/MESegment.h>
52 #include <mesosim/MEVehicle.h>
55 #ifdef CHECK_MEMORY_LEAKS
57 #endif // CHECK_MEMORY_LEAKS
72 const std::string& streetName) :
73 Named(id), myNumericalID(numericalID), myLanes(0),
74 myLaneChanger(0), myFunction(function), myVaporizationRequests(0),
75 myLastFailedInsertionTime(-1), myStreetName(streetName), myAmRoundabout(false) {}
84 for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
115 for (std::vector<MSLane*>::iterator it =
myLanes->begin(); it !=
myLanes->end(); ++it) {
129 myAllowed[0] =
new std::vector<MSLane*>();
130 for (std::vector<MSLane*>::iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
133 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
134 MSLane* toL = (*j)->getLane();
146 myAllowed[&to] =
new std::vector<MSLane*>();
150 #ifdef HAVE_INTERNAL_LANES
151 toL = (*j)->getViaLane();
169 for (AllowedLanesCont::iterator i1 = (*i2).second.begin(); i1 != (*i2).second.end(); i1++) {
177 for (std::vector<MSLane*>::iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
200 if (index == (
int)
myLanes->size()) {
203 const int resultIndex = index + offset;
204 if (resultIndex >= (
int)
myLanes->size() || resultIndex < 0) {
207 return (*
myLanes)[resultIndex];
212 const std::vector<MSLane*>*
218 const std::vector<MSLane*>*
224 const std::vector<MSLane*>*
226 AllowedLanesCont::const_iterator it = c.find(dest);
234 const std::vector<MSLane*>*
249 for (AllowedLanesCont::const_iterator i1 =
myAllowed.begin(); i1 !=
myAllowed.end(); ++i1) {
250 const MSEdge* edge = i1->first;
251 const std::vector<MSLane*>* lanes = i1->second;
254 for (std::vector<MSLane*>::const_iterator i2 = lanes->begin(); i2 != lanes->end(); ++i2) {
256 if ((*i2)->allowsVehicleClass(vclass)) {
294 unsigned int noCars = INT_MAX;
295 for (std::vector<MSLane*>::const_iterator i = allowed->begin(); i != allowed->end(); ++i) {
296 if ((*i)->getVehicleNumber() < noCars) {
327 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
328 if ((*i).length > bestLength) {
329 bestLength = (*i).length;
332 std::vector<MSLane*>* bestLanes =
new std::vector<MSLane*>();
333 for (std::vector<MSVehicle::LaneQ>::const_iterator i = bl.begin(); i != bl.end(); ++i) {
334 if ((*i).length == bestLength) {
335 bestLanes->push_back((*i).lane);
372 v.
getID() +
"'. Inserting at lane end instead.");
384 MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*
this, pos);
385 MEVehicle* veh =
static_cast<MEVehicle*
>(&v);
387 while (segment != 0 && !result) {
388 result = segment->initialise(veh, time);
389 segment = segment->getNextSegment();
392 result = segment->initialise(veh, time);
400 return insertionLane != 0 && insertionLane->
insertVehicle(static_cast<MSVehicle&>(v));
413 #ifdef HAVE_INTERNAL_LANES
415 MSEdge::getInternalFollowingEdge(
MSEdge* followerAfterInternal)
const {
417 for (std::vector<MSLane*>::const_iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
420 for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
423 if (link->getViaLane() != 0) {
424 return &link->getViaLane()->getEdge();
438 assert(minSpeed > 0);
442 MESegment* first = MSGlobals::gMesoNet->getSegmentForEdge(*
this);
443 unsigned segments = 0;
445 v += first->getMeanSpeed();
446 first = first->getNextSegment();
448 }
while (first != 0);
452 for (std::vector<MSLane*>::iterator i =
myLanes->begin(); i !=
myLanes->end(); ++i) {
453 v += (*i)->getMeanSpeed();
459 v =
MAX2(minSpeed, v);
466 DictType::iterator it =
myDict.find(
id);
482 DictType::iterator it =
myDict.find(
id);
512 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
521 for (DictType::iterator i =
myDict.begin(); i !=
myDict.end(); ++i) {
522 into.push_back((*i).first);
529 const std::string& rid) {
531 std::istringstream in(desc, std::ios::binary);
544 const std::string& rid) {
545 for (std::vector<std::string>::const_iterator i = desc.begin(); i != desc.end(); ++i) {
549 throw ProcessError(
"The edge '" + *i +
"' within the route " + rid +
" is not known."
550 +
"\n The route can not be build.");
552 into.push_back(edge);
560 return getLanes()[0]->getShape()[-1].distanceTo2D(other->
getLanes()[0]->getShape()[0]);
576 return getLanes()[0]->getSpeedLimit();
583 return getLanes()[0]->getVehicleMaxSpeed(veh);
void laneChange(SUMOTime t)
Start lane-change-process for all vehicles on the edge'e lanes.
virtual const std::vector< LaneQ > & getBestLanes(bool forceRebuild=false, MSLane *startLane=0) const
Returns the description of best lanes to use in order to continue the route.
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
std::vector< MSLane * > * myLanes
Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane...
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.
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 size_t numericalDictSize()
Returns the number of edges with a numerical id.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
std::vector< MSEdge * > mySuccessors
The succeeding edges.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
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.
static SUMOReal rand()
Returns a random real number in [0, 1)
virtual ~MSEdge()
Destructor.
SUMOReal getCurrentTravelTime(const SUMOReal minSpeed=0.00001) const
Computes and returns the current travel time for this edge.
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...
SUMOTime incVaporization(SUMOTime t)
Enables vaporization.
MSLane * getFreeLane(const std::vector< MSLane * > *allowed, const SUMOVehicleClass vclass) const
Finds the emptiest lane allowing the vehicle class.
The lane is chosen randomly.
static T getRandomFrom(const std::vector< T > &v)
Returns a random element from the given vector.
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.
#define UNUSED_PARAMETER(x)
#define WRITE_WARNING(msg)
std::map< std::string, MSEdge * > DictType
definition of the static dictionary type
MSEdge(const std::string &id, int numericalID, const EdgeBasicFunction function, const std::string &streetName="")
Constructor.
static OptionsCont & getOptions()
Retrieves the options.
void initialize(std::vector< MSLane * > *lanes)
Initialize the edge.
static std::vector< MSEdge * > myEdges
Static list of edges.
Performs lane changing of vehicles.
A road/street connecting two junctions.
static void parseEdgesList(const std::string &desc, std::vector< const MSEdge * > &into, const std::string &rid)
Parses the given string assuming it contains a list of edge ids divided by spaces.
bool insertVehicle(MSVehicle &v)
Tries to insert the given vehicle.
void rebuildAllowedLanes()
SUMOReal getLength() const
return the length of the edge
MSLane * getLogicalPredecessorLane() const
The edge is a district 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.
AllowedLanesCont myAllowed
Associative container from destination-edge to allowed-lanes.
MSLane * getLane() const
Returns the connected lane.
static void clear()
Clears the dictionary.
SVCPermissions myMinimumPermissions
The intersection of lane permissions for this edge.
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.
bool isVaporizing() const
Returns whether vehicles on this edge shall be vaporized.
std::vector< MSEdge * > myPredeccesors
The preceeding edges.
MSLane * getDepartLane(const MSVehicle &veh) const
Finds a depart lane for the given vehicle parameters.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
SUMOReal getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
If a fixed number of random choices fails, a free position is chosen.
const SVCPermissions SVCFreeForAll
Base class for objects which have an id.
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
std::vector< std::string > getVector()
unsigned int getVehicleNumber() const
Returns the number of vehicles on this lane.
SVCPermissions myCombinedPermissions
The union of lane permissions for this edge.
No information given; use default.
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_UNKNOWN) const
Get the allowed lanes to reach the destination-edge.
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...
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)
static size_t dictSize()
Returns the number of edges.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
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).
unsigned size() const
Returns the number of edges to pass.
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.
static const bool gUseMesoSim
bool laneChangeAllowed() const
whether lane changing may be performed on this edge
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.
MSLane * rightLane(const MSLane *const lane) const
Returns the lane right to the one given, 0 if the given lane is rightmost.
bool insertVehicle(SUMOVehicle &v, SUMOTime time) const
Tries to insert the given vehicle into the network.
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
Representation of a lane in the micro simulation.
virtual const std::string & getID() const =0
Get the vehicle's ID.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.