72 for (std::vector<MEVehicle*>::const_iterator i = vehs.begin(); i != vehs.end(); ++i) {
84 if (onSegment !=
nullptr) {
94 if (onSegment !=
nullptr) {
96 toSegment->
receive(veh, leaveTime,
false, ignoreLink);
103 toSegment->
receive(veh, leaveTime,
false,
true);
116 const bool teleporting = (onSegment ==
nullptr);
127 if (leaveTime < toSegment->getEntryBlockTime()) {
149 const bool teleporting = (onSegment ==
nullptr);
152 while (teleSegment !=
nullptr && !teleSegment->
hasSpaceFor(veh, leaveTime)) {
156 if (teleSegment !=
nullptr) {
206 if (link !=
nullptr) {
220 cands.erase(find(cands.begin(), cands.end(), v));
228 auto it = find(cands.begin(), cands.end(), v);
229 if (it != cands.end()) {
238 if (next !=
nullptr) {
245 if (nextEdge ==
nullptr) {
255 int no = (int)floor(length / sLength + 0.5);
268 const double slength = length / (double)no;
271 bool multiQueue = oc.
getBool(
"meso-multi-queue");
273 for (
int s = no - 1; s >= 0; s--) {
276 new MESegment(
id, e, nextSegment, slength,
277 e.
getLanes()[0]->getSpeedLimit(), s,
280 oc.
getFloat(
"meso-jam-threshold"), multiQueue, junctionControl);
282 junctionControl =
false;
283 nextSegment = newSegment;
312 if (succ->isRoundabout()) {
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
bool changeSegment(MEVehicle *veh, SUMOTime leaveTime, MESegment *const toSegment, const bool ignoreLink=false)
change to the next segment this handles combinations of the following cases: (ending / continuing rou...
MELoop(const SUMOTime recheckInterval)
SUMO constructor.
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
MESegment * nextSegment(MESegment *s, MEVehicle *v)
Retrieve next segment.
A vehicle from the mesoscopic point of view.
double getLength() const
Returns the length of the segment in meters.
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
The vehicle arrived at a junction.
bool mayProceed() const
Returns whether the vehicle is allowed to pass the next junction.
SUMOTime getEntryBlockTime() const
return the next time at which a vehicle my enter this segment
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
const SUMOTime myFullRecheckInterval
the interval at which to recheck at full segments (<=0 means asap)
std::vector< MESegment * > myEdges2FirstSegments
mapping from internal edge ids to their initial segments
void buildSegmentsFor(const MSEdge &e, const OptionsCont &oc)
Build the segments for a given edge.
std::string time2string(SUMOTime t)
void teleportVehicle(MEVehicle *veh, MESegment *const toSegment)
teleports a vehicle or continues a teleport
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves his current cell.
The vehicle got vaporized.
The vehicle changes the segment (meso only)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
SUMOTime getEventTime() const
Returns the (planned) time at which the next vehicle leaves this segment.
double getLength() const
return the length of the edge
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...
void setBlockTime(const SUMOTime t)
Sets the time at which the vehicle was blocked.
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const double arrivalSpeed, const double leaveSpeed, const bool setRequest, const SUMOTime arrivalTimeBraking, const double arrivalSpeedBraking, const SUMOTime waitingTime, double dist)
Sets the information about an approaching vehicle.
#define WRITE_WARNING(msg)
LinkState getState() const
Returns the current state of the link.
bool hasSpaceFor(const MEVehicle *veh, SUMOTime entryTime, bool init=false) const
Returns whether the given vehicle would still fit into the segment.
void setEntryBlockTime(SUMOTime entryBlockTime)
set the next time at which a vehicle my enter this segment
void removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
A road/street connecting two junctions.
void send(MEVehicle *veh, MESegment *next, SUMOTime time, const MSMoveReminder::Notification reason)
Removes the vehicle from the segment, adapting its parameters.
void receive(MEVehicle *veh, SUMOTime time, bool isDepart=false, bool afterTeleport=false)
Adds the vehicle to the segment, adapting its parameters.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
MESegment * getSegment() const
Returns the current segment the vehicle is on.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
static bool isInvalid(const MESegment *segment)
whether the given segment is 0 or encodes vaporization
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
The vehicle arrived at its destination (is deleted)
SUMOTime string2time(const std::string &r)
std::map< SUMOTime, std::vector< MEVehicle * > > myLeaderCars
leader cars in the segments sorted by exit time
static bool isEnteringRoundabout(const MSEdge &e)
whether the given edge is entering a roundabout
void registerTeleportJam()
register one non-collision-related teleport
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
static void setApproaching(MEVehicle *veh, MSLink *link)
registers vehicle with the given link
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
MSLink * getLink(const MEVehicle *veh, bool tlsPenalty=false) const
Returns the link the given car will use when passing the next junction.
A single mesoscopic segment (cell)
A storage for options typed value containers)
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
const SUMOTime myLinkRecheckInterval
the interval at which to recheck at blocked junctions (<=0 means asap)
void checkCar(MEVehicle *veh)
Check whether the vehicle may move.
static SUMOTime gTimeToGridlock
void setEventTime(SUMOTime t, bool hasDelay=true)
Sets the (planned) time at which the vehicle leaves his current cell.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
double getSpeed() const
Returns the vehicle's estimated speed assuming no delays.
static int numSegmentsFor(const double length, const double slength)
Compute number of segments per edge (best value stay close to the configured segment length) ...
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
const std::string & getID() const
Returns the name of the vehicle.
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
void vaporizeCar(MEVehicle *v)
remove the given car and clean up the relevant data structures
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
The vehicle is being teleported.
SUMOTime getBlockTime() const
Returns the time at which the vehicle was blocked.