Eclipse SUMO - Simulation of Urban MObility
MESegment.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // A single mesoscopic segment (cell)
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 #include <algorithm>
24 #include <limits>
25 #include <utils/common/StdDefs.h>
26 #include <microsim/MSGlobals.h>
27 #include <microsim/MSEdge.h>
28 #include <microsim/MSJunction.h>
29 #include <microsim/MSNet.h>
30 #include <microsim/MSLane.h>
31 #include <microsim/MSLinkCont.h>
32 #include <microsim/MSVehicle.h>
41 #include "MEVehicle.h"
42 #include "MELoop.h"
43 #include "MESegment.h"
44 
45 #define DEFAULT_VEH_LENGTH_WITH_GAP (SUMOVTypeParameter::getDefault().length + SUMOVTypeParameter::getDefault().minGap)
46 // avoid division by zero when driving very slowly
47 #define MESO_MIN_SPEED (0.05)
48 
49 //#define DEBUG_OPENED
50 //#define DEBUG_JAMTHRESHOLD
51 //#define DEBUG_COND (getID() == "blocker")
52 //#define DEBUG_COND (true)
53 #define DEBUG_COND (myEdge.isSelected())
54 #define DEBUG_COND2(obj) ((obj != 0 && (obj)->isSelected()))
55 
56 // ===========================================================================
57 // static member defintion
58 // ===========================================================================
59 MSEdge MESegment::myDummyParent("MESegmentDummyParent", -1, EDGEFUNC_UNKNOWN, "", "", -1, 0);
60 MESegment MESegment::myVaporizationTarget("vaporizationTarget");
61 const double MESegment::DO_NOT_PATCH_JAM_THRESHOLD(std::numeric_limits<double>::max());
62 
63 // ===========================================================================
64 // method definitions
65 // ===========================================================================
66 MESegment::MESegment(const std::string& id,
67  const MSEdge& parent, MESegment* next,
68  double length, double speed,
69  int idx,
70  SUMOTime tauff, SUMOTime taufj,
71  SUMOTime taujf, SUMOTime taujj,
72  double jamThresh, bool multiQueue, bool junctionControl) :
73  Named(id), myEdge(parent), myNextSegment(next),
74  myLength(length), myIndex(idx),
75  myTau_ff((SUMOTime)(tauff / parent.getLanes().size())),
76  myTau_fj((SUMOTime)(taufj / parent.getLanes().size())), // Eissfeldt p. 90 and 151 ff.
77  myTau_jf((SUMOTime)(taujf / parent.getLanes().size())),
78  myTau_jj((SUMOTime)(taujj / parent.getLanes().size())),
79  myTau_length(MAX2(MESO_MIN_SPEED, speed) * parent.getLanes().size() / TIME2STEPS(1)),
80  myHeadwayCapacity(length / DEFAULT_VEH_LENGTH_WITH_GAP * parent.getLanes().size())/* Eissfeldt p. 69 */,
81  myCapacity(length * parent.getLanes().size()),
82  myOccupancy(0.f),
83  myJunctionControl(junctionControl),
84  myTLSPenalty(MSGlobals::gMesoTLSPenalty > 0 &&
85  // only apply to the last segment of a tls-controlled edge
86  myNextSegment == nullptr && (
87  parent.getToJunction()->getType() == NODETYPE_TRAFFIC_LIGHT ||
88  parent.getToJunction()->getType() == NODETYPE_TRAFFIC_LIGHT_NOJUNCTION ||
89  parent.getToJunction()->getType() == NODETYPE_TRAFFIC_LIGHT_RIGHT_ON_RED)),
90  myMinorPenalty(MSGlobals::gMesoMinorPenalty > 0 &&
91  // only apply to the last segment of an uncontrolled edge that has at least 1 minor link
92  myNextSegment == nullptr &&
93  parent.getToJunction()->getType() != NODETYPE_TRAFFIC_LIGHT &&
94  parent.getToJunction()->getType() != NODETYPE_TRAFFIC_LIGHT_NOJUNCTION &&
95  parent.getToJunction()->getType() != NODETYPE_TRAFFIC_LIGHT_RIGHT_ON_RED &&
96  parent.hasMinorLink()),
97  myNumCars(0),
98  myEntryBlockTime(SUMOTime_MIN),
99  myLastHeadway(TIME2STEPS(-1)),
100  myMeanSpeed(speed),
101  myLastMeanSpeedUpdate(SUMOTime_MIN) {
102  myCarQues.push_back(std::vector<MEVehicle*>());
103  myBlockTimes.push_back(-1);
104  if (useMultiQueue(multiQueue, parent)) {
105  const std::vector<MSLane*>& lanes = parent.getLanes();
106  while (myCarQues.size() < lanes.size()) {
107  myCarQues.push_back(std::vector<MEVehicle*>());
108  myBlockTimes.push_back(-1);
109  }
110  for (int i = 0; i < (int)parent.getNumSuccessors(); ++i) {
111  const MSEdge* const edge = parent.getSuccessors()[i];
112  const std::vector<MSLane*>* const allowed = parent.allowedLanes(*edge);
113  assert(allowed != 0);
114  assert(allowed->size() > 0);
115  for (std::vector<MSLane*>::const_iterator j = allowed->begin(); j != allowed->end(); ++j) {
116  std::vector<MSLane*>::const_iterator it = std::find(lanes.begin(), lanes.end(), *j);
117  myFollowerMap[edge].push_back((int)distance(lanes.begin(), it));
118  }
119  }
120  }
121  recomputeJamThreshold(jamThresh);
122 }
123 
124 
125 MESegment::MESegment(const std::string& id):
126  Named(id),
127  myEdge(myDummyParent), // arbitrary edge needed to supply the needed reference
128  myNextSegment(nullptr), myLength(0), myIndex(0),
129  myTau_ff(0), myTau_fj(0), myTau_jf(0), myTau_jj(0), myTau_length(1),
130  myHeadwayCapacity(0), myCapacity(0), myJunctionControl(false),
131  myTLSPenalty(false),
132  myMinorPenalty(false) {
133 }
134 
135 
136 bool
137 MESegment::useMultiQueue(bool multiQueue, const MSEdge& parent) {
138  return multiQueue && parent.getLanes().size() > 1 && parent.getNumSuccessors() > 1;
139 }
140 
141 void
143  if (jamThresh == DO_NOT_PATCH_JAM_THRESHOLD) {
144  return;
145  }
146  if (jamThresh < 0) {
147  // compute based on speed
148  double speed = myEdge.getSpeedLimit();
149  if (myTLSPenalty || myMinorPenalty) {
150  double travelTime = myLength / MAX2(speed, NUMERICAL_EPS) + getMaxPenaltySeconds();
151  speed = myLength / travelTime;
152  }
153  myJamThreshold = jamThresholdForSpeed(speed, jamThresh);
154  } else {
155  // compute based on specified percentage
156  myJamThreshold = jamThresh * myCapacity;
157  }
158 
159  // update coefficients for the jam-jam headway function
160  // this function models the effect that "empty space" needs to move
161  // backwards through the downstream segment before the upstream segment may
162  // send annother vehicle.
163  // this allows jams to clear and move upstream.
164  // the headway function f(x) depends on the number of vehicles in the
165  // downstream segment x
166  // f is a linear function that passes through the following fixed points:
167  // f(n_jam_threshold) = tau_jf_withLength (for continuity)
168  // f(myHeadwayCapacity) = myTau_jj * myHeadwayCapacity
169 
171  if (myJamThreshold < myCapacity) {
172  // jamming is possible
173  const double n_jam_threshold = myHeadwayCapacity * myJamThreshold / myCapacity; // number of vehicles above which the segment is jammed
174  // solving f(x) = a * x + b
175  myA = (STEPS2TIME(myTau_jj) * myHeadwayCapacity - STEPS2TIME(tau_jf_withLength)) / (myHeadwayCapacity - n_jam_threshold);
177 
178  // note that the original Eissfeldt model (p. 69) used different fixed points
179  // f(n_jam_threshold) = n_jam_threshold * myTau_jj
180  // f(myHeadwayCapacity) = myTau_jf * myHeadwayCapacity
181  //
182  // However, this systematically underestimates the backpropagation speed of the jam front (see #2244)
183  } else {
184  // dummy values. Should not be used
185  myA = 0;
186  myB = STEPS2TIME(tau_jf_withLength);
187  }
188 }
189 
190 
191 double
192 MESegment::jamThresholdForSpeed(double speed, double jamThresh) const {
193  // vehicles driving freely at maximum speed should not jam
194  // we compute how many vehicles could possible enter the segment until the first vehicle leaves
195  // and multiply by the space these vehicles would occupy
196  // the jamThresh parameter is scale the resulting value
197  if (speed == 0) {
198  return std::numeric_limits<double>::max(); // never jam. Irrelevant at speed 0 anyway
199  }
200 #ifdef DEBUG_JAMTHRESHOLD
201  if (true || DEBUG_COND) {
202  std::cout << "jamThresholdForSpeed seg=" << getID() << " speed=" << speed << " jamThresh=" << jamThresh << " ffVehs=" << std::ceil(myLength / (-jamThresh * speed * STEPS2TIME(tauWithVehLength(myTau_ff, DEFAULT_VEH_LENGTH_WITH_GAP)))) << " thresh=" << std::ceil(myLength / (-jamThresh * speed * STEPS2TIME(tauWithVehLength(myTau_ff, DEFAULT_VEH_LENGTH_WITH_GAP)))) * DEFAULT_VEH_LENGTH_WITH_GAP
203  << "\n";
204  }
205 #endif
207 }
208 
209 
210 void
212  myDetectorData.push_back(data);
213  for (Queues::const_iterator k = myCarQues.begin(); k != myCarQues.end(); ++k) {
214  for (std::vector<MEVehicle*>::const_reverse_iterator i = k->rbegin(); i != k->rend(); ++i) {
215  (*i)->addReminder(data);
216  }
217  }
218 }
219 
220 
221 void
223  std::vector<MSMoveReminder*>::iterator it = std::find(
224  myDetectorData.begin(), myDetectorData.end(), data);
225  if (it != myDetectorData.end()) {
226  myDetectorData.erase(it);
227  }
228  for (Queues::const_iterator k = myCarQues.begin(); k != myCarQues.end(); ++k) {
229  for (std::vector<MEVehicle*>::const_reverse_iterator i = k->rbegin(); i != k->rend(); ++i) {
230  (*i)->removeReminder(data);
231  }
232  }
233 }
234 
235 
236 void
238  const SUMOTime currentTime = MSNet::getInstance()->getCurrentTimeStep();
239  for (Queues::const_iterator k = myCarQues.begin(); k != myCarQues.end(); ++k) {
240  SUMOTime earliestExitTime = currentTime;
241  for (std::vector<MEVehicle*>::const_reverse_iterator i = k->rbegin(); i != k->rend(); ++i) {
242  const SUMOTime exitTime = MAX2(earliestExitTime, (*i)->getEventTime());
243  (*i)->updateDetectorForWriting(&data, currentTime, exitTime);
244  earliestExitTime = exitTime + tauWithVehLength(myTau_ff, (*i)->getVehicleType().getLengthWithGap());
245  }
246  }
247 }
248 
249 
250 bool
251 MESegment::hasSpaceFor(const MEVehicle* veh, SUMOTime entryTime, bool init) const {
252  if (myOccupancy == 0.) {
253  // we have always space for at least one vehicle
254  return true;
255  }
256  const double newOccupancy = myOccupancy + veh->getVehicleType().getLengthWithGap();
257  if (newOccupancy > myCapacity) {
258  // we must ensure that occupancy remains below capacity
259  return false;
260  }
261  // regular insertions and initial insertions must respect different constraints:
262  // - regular insertions must respect entryBlockTime
263  // - initial insertions should not cause additional jamming
264  // - inserted vehicle should be able to continue at the current speed
265  if (init) {
266  if (free() && !hasBlockedLeader()) {
267  return newOccupancy <= myJamThreshold;
268  } else {
269  return newOccupancy <= jamThresholdForSpeed(getMeanSpeed(false), -1);
270  }
271  }
272  // maintain propper spacing between inflow from different lanes
273  return entryTime >= myEntryBlockTime;
274 }
275 
276 
277 bool
279  if (hasSpaceFor(veh, time, true)) {
280  receive(veh, time, true);
281  // we can check only after insertion because insertion may change the route via devices
282  std::string msg;
283  if (MSGlobals::gCheckRoutes && !veh->hasValidRoute(msg)) {
284  throw ProcessError("Vehicle '" + veh->getID() + "' has no valid route. " + msg);
285  }
286  return true;
287  }
288  return false;
289 }
290 
291 
292 double
293 MESegment::getMeanSpeed(bool useCached) const {
294  const SUMOTime currentTime = MSNet::getInstance()->getCurrentTimeStep();
295  if (currentTime != myLastMeanSpeedUpdate || !useCached) {
296  myLastMeanSpeedUpdate = currentTime;
297  const SUMOTime tau = free() ? myTau_ff : myTau_jf;
298  double v = 0;
299  int count = 0;
300  for (Queues::const_iterator k = myCarQues.begin(); k != myCarQues.end(); ++k) {
301  SUMOTime earliestExitTime = currentTime;
302  count += (int)k->size();
303  for (std::vector<MEVehicle*>::const_reverse_iterator veh = k->rbegin(); veh != k->rend(); ++veh) {
304  v += (*veh)->getConservativeSpeed(earliestExitTime); // earliestExitTime is updated!
305  earliestExitTime += tauWithVehLength(tau, (*veh)->getVehicleType().getLengthWithGap());
306  }
307  }
308  if (count == 0) {
310  } else {
311  myMeanSpeed = v / (double) count;
312  }
313  }
314  return myMeanSpeed;
315 }
316 
317 
318 void
320  for (Queues::const_iterator k = myCarQues.begin(); k != myCarQues.end(); ++k) {
321  for (std::vector<MEVehicle*>::const_iterator veh = k->begin(); veh != k->end(); ++veh) {
322  MSXMLRawOut::writeVehicle(of, *(*veh));
323  }
324  }
325 }
326 
327 
328 MEVehicle*
331  std::vector<MEVehicle*>& cars = myCarQues[v->getQueIndex()];
332  assert(std::find(cars.begin(), cars.end(), v) != cars.end());
333  // One could be tempted to do v->setSegment(next); here but position on lane will be invalid if next == 0
334  v->updateDetectors(leaveTime, true, reason);
335  myNumCars--;
336  myEdge.lock();
337  if (v == cars.back()) {
338  cars.pop_back();
339  if (!cars.empty()) {
340  myEdge.unlock();
341  return cars.back();
342  }
343  } else {
344  cars.erase(std::find(cars.begin(), cars.end(), v));
345  }
346  myEdge.unlock();
347  return nullptr;
348 }
349 
350 
351 SUMOTime
353  const SUMOTime tau = (pred->free()
354  ? (free() ? myTau_ff : myTau_fj)
355  : (free() ? myTau_jf : TIME2STEPS(myA * getCarNumber() + myB)));
356  return (SUMOTime)(tauWithVehLength(tau, veh->getVehicleType().getLengthWithGap()) / pred->getTLSCapacity(veh));
357 }
358 
359 
360 SUMOTime
362  // since we do not know which queue will be used we give a conservative estimate
363  SUMOTime earliestLeave = earliestEntry;
364  for (int i = 0; i < (int)myCarQues.size(); ++i) {
365  earliestLeave = MAX2(earliestLeave, myBlockTimes[i]);
366  }
367  if (myEdge.getSpeedLimit() == 0) {
368  return MAX2(earliestEntry, myEntryBlockTime); // FIXME: This line is just an adhoc-fix to avoid division by zero (Leo)
369  } else {
370  return MAX3(earliestEntry, earliestLeave - TIME2STEPS(myLength / myEdge.getSpeedLimit()), myEntryBlockTime);
371  }
372 }
373 
374 
375 MSLink*
376 MESegment::getLink(const MEVehicle* veh, bool penalty) const {
377  if (myJunctionControl || penalty) {
378  const MSEdge* const nextEdge = veh->succEdge(1);
379  if (nextEdge == nullptr) {
380  return nullptr;
381  }
382  // try to find any link leading to our next edge, start with the lane pointed to by the que index
383  const MSLane* const bestLane = myEdge.getLanes()[veh->getQueIndex()];
384  for (MSLink* const link : bestLane->getLinkCont()) {
385  if (&link->getLane()->getEdge() == nextEdge) {
386  return link;
387  }
388  }
389  // this is for the non-multique case, maybe we should use caching here !!!
390  for (const MSLane* const lane : myEdge.getLanes()) {
391  if (lane != bestLane) {
392  for (MSLink* const link : lane->getLinkCont()) {
393  if (&link->getLane()->getEdge() == nextEdge) {
394  return link;
395  }
396  }
397  }
398  }
399  }
400  return nullptr;
401 }
402 
403 
404 bool
405 MESegment::isOpen(const MEVehicle* veh) const {
406 #ifdef DEBUG_OPENED
407  if (DEBUG_COND || DEBUG_COND2(veh)) {
408  std::cout << SIMTIME << " opened seg=" << getID() << " veh=" << Named::getIDSecure(veh)
409  << " tlsPenalty=" << myTLSPenalty;
410  const MSLink* link = getLink(veh);
411  if (link == 0) {
412  std::cout << " link=0";
413  } else {
414  std::cout << " prio=" << link->havePriority()
415  << " override=" << limitedControlOverride(link)
416  << " isOpen=" << link->opened(veh->getEventTime(), veh->getSpeed(), veh->estimateLeaveSpeed(link),
419  << " et=" << veh->getEventTime()
420  << " v=" << veh->getSpeed()
421  << " vLeave=" << veh->estimateLeaveSpeed(link)
422  << " impatience=" << veh->getImpatience()
423  << " tWait=" << veh->getWaitingTime();
424  }
425  std::cout << "\n";
426  }
427 #endif
428  if (myTLSPenalty) {
429  // XXX should limited control take precedence over tls penalty?
430  return true;
431  }
432  const MSLink* link = getLink(veh);
433  return (link == nullptr
434  || link->havePriority()
435  || limitedControlOverride(link)
436  || link->opened(veh->getEventTime(), veh->getSpeed(), veh->estimateLeaveSpeed(link),
439 }
440 
441 
442 bool
444  assert(link != 0);
446  return false;
447  }
448  // if the target segment of this link is not saturated junction control is disabled
449  const MSEdge& targetEdge = link->getLane()->getEdge();
450  const MESegment* target = MSGlobals::gMesoNet->getSegmentForEdge(targetEdge);
451  return (target->myOccupancy * 2 < target->myJamThreshold) && !targetEdge.isRoundabout();
452 }
453 
454 
455 void
457  assert(isInvalid(next) || time >= myBlockTimes[veh->getQueIndex()]);
458  MSLink* link = getLink(veh);
459  if (link != nullptr) {
460  link->removeApproaching(veh);
461  }
462  MEVehicle* lc = removeCar(veh, time, reason); // new leaderCar
463  myBlockTimes[veh->getQueIndex()] = time;
464  if (!isInvalid(next)) {
465  myLastHeadway = next->getTimeHeadway(this, veh);
467  }
468  if (lc != nullptr) {
471  }
472  if (veh->isStopped()) {
473  veh->processStop();
474  }
475 }
476 
477 bool
480 }
481 
482 
483 void
485  for (std::vector<MSMoveReminder*>::const_iterator i = myDetectorData.begin(); i != myDetectorData.end(); ++i) {
486  veh->addReminder(*i);
487  }
488 }
489 
490 void
491 MESegment::receive(MEVehicle* veh, SUMOTime time, bool isDepart, bool afterTeleport) {
492  const double speed = isDepart ? -1 : MAX2(veh->getSpeed(), MESO_MIN_SPEED); // on the previous segment
493  veh->setSegment(this); // for arrival checking
494  veh->setLastEntryTime(time);
496  if (!isDepart && (
497  // arrival on entering a new edge
498  ((myIndex == 0 || afterTeleport) && veh->moveRoutePointer())
499  // arrival on entering a new segment
500  || veh->hasArrived())) {
501  // route has ended
502  veh->setEventTime(time + TIME2STEPS(myLength / speed)); // for correct arrival speed
503  addReminders(veh);
507  return;
508  }
509  // route continues
510  const double maxSpeedOnEdge = veh->getEdge()->getVehicleMaxSpeed(veh);
511  const double uspeed = MAX2(maxSpeedOnEdge, MESO_MIN_SPEED);
512  int nextQueIndex = 0;
513  if (myCarQues.size() > 1) {
514  const MSEdge* succ = veh->succEdge(1);
515  // succ may be invalid if called from initialise() with an invalid route
516  if (succ != nullptr && myFollowerMap.count(succ) > 0) {
517  const std::vector<int>& indices = myFollowerMap[succ];
518  nextQueIndex = indices[0];
519  for (std::vector<int>::const_iterator i = indices.begin() + 1; i != indices.end(); ++i) {
520  if (myCarQues[*i].size() < myCarQues[nextQueIndex].size()) {
521  nextQueIndex = *i;
522  }
523  }
524  }
525  }
526  std::vector<MEVehicle*>& cars = myCarQues[nextQueIndex];
527  MEVehicle* newLeader = nullptr; // first vehicle in the current queue
528  SUMOTime tleave = MAX2(veh->getStoptime(this, time) + TIME2STEPS(myLength / uspeed) + getLinkPenalty(veh), myBlockTimes[nextQueIndex]);
529  if (veh->isStopped()) {
530  myEdge.addWaiting(veh);
531  }
532  myEdge.lock();
533  if (cars.empty()) {
534  cars.push_back(veh);
535  newLeader = veh;
536  } else {
537  SUMOTime leaderOut = cars[0]->getEventTime();
538  if (!isDepart && leaderOut > tleave && overtake()) {
539  if (cars.size() == 1) {
541  newLeader = veh;
542  }
543  cars.insert(cars.begin() + 1, veh);
544  } else {
545  tleave = MAX2(leaderOut + tauWithVehLength(myTau_ff, cars[0]->getVehicleType().getLengthWithGap()), tleave);
546  cars.insert(cars.begin(), veh);
547  }
548  }
549  myEdge.unlock();
550  myNumCars++;
551  if (!isDepart) {
552  // regular departs could take place anywhere on the edge so they should not block regular flow
553  // the -1 facilitates interleaving of multiple streams
555  }
556  veh->setEventTime(tleave);
557  veh->setSegment(this, nextQueIndex);
559  addReminders(veh);
560  if (isDepart) {
561  veh->onDepart();
563  } else if (myIndex == 0 || afterTeleport) {
565  } else {
567  }
568  if (newLeader != nullptr) {
569  MSGlobals::gMesoNet->addLeaderCar(newLeader, getLink(newLeader));
570  }
571 }
572 
573 
574 bool
576  MEVehicle* remove = nullptr;
577  for (Queues::const_iterator k = myCarQues.begin(); k != myCarQues.end(); ++k) {
578  if (!k->empty()) {
579  // remove last in queue
580  remove = k->front();
581  if (k->size() == 1) {
583  }
585  return true;
586  }
587  }
588  return false;
589 }
590 
591 
592 void
593 MESegment::setSpeedForQueue(double newSpeed, SUMOTime currentTime, SUMOTime blockTime, const std::vector<MEVehicle*>& vehs) {
594  MEVehicle* v = vehs.back();
595  v->updateDetectors(currentTime, false);
596  SUMOTime newEvent = MAX2(newArrival(v, newSpeed, currentTime), blockTime);
597  if (v->getEventTime() != newEvent) {
599  v->setEventTime(newEvent);
601  }
602  for (std::vector<MEVehicle*>::const_reverse_iterator i = vehs.rbegin() + 1; i != vehs.rend(); ++i) {
603  (*i)->updateDetectors(currentTime, false);
604  newEvent = MAX2(newArrival(*i, newSpeed, currentTime), newEvent + myTau_ff);
605  //newEvent = MAX2(newArrival(*i, newSpeed, currentTime), newEvent + myTau_ff + (SUMOTime)((*(i - 1))->getVehicleType().getLength() / myTau_length));
606  (*i)->setEventTime(newEvent);
607  }
608 }
609 
610 
611 SUMOTime
612 MESegment::newArrival(const MEVehicle* const v, double newSpeed, SUMOTime currentTime) {
613  // since speed is only an upper bound pos may be to optimistic
614  const double pos = MIN2(myLength, STEPS2TIME(currentTime - v->getLastEntryTime()) * v->getSpeed());
615  // traveltime may not be 0
616  return currentTime + MAX2(TIME2STEPS((myLength - pos) / newSpeed), SUMOTime(1));
617 }
618 
619 
620 void
621 MESegment::setSpeed(double newSpeed, SUMOTime currentTime, double jamThresh) {
622  recomputeJamThreshold(jamThresh);
623  //myTau_length = MAX2(MESO_MIN_SPEED, newSpeed) * myEdge.getLanes().size() / TIME2STEPS(1);
624  for (int i = 0; i < (int)myCarQues.size(); ++i) {
625  if (myCarQues[i].size() != 0) {
626  setSpeedForQueue(newSpeed, currentTime, myBlockTimes[i], myCarQues[i]);
627  }
628  }
629 }
630 
631 
632 SUMOTime
634  SUMOTime result = SUMOTime_MAX;
635  for (int i = 0; i < (int)myCarQues.size(); ++i) {
636  if (myCarQues[i].size() != 0 && myCarQues[i].back()->getEventTime() < result) {
637  result = myCarQues[i].back()->getEventTime();
638  }
639  }
640  if (result < SUMOTime_MAX) {
641  return result;
642  }
643  return -1;
644 }
645 
646 
647 void
650  for (int i = 0; i < (int)myCarQues.size(); ++i) {
653  out.closeTag();
654  }
655  out.closeTag();
656 }
657 
658 
659 void
660 MESegment::loadState(const std::vector<std::string>& vehIds, MSVehicleControl& vc, const SUMOTime block, const int queIdx) {
661  for (const std::string& id : vehIds) {
662  MEVehicle* v = static_cast<MEVehicle*>(vc.getVehicle(id));
663  // vehicle could be removed due to options
664  if (v != nullptr) {
665  assert(v->getSegment() == this);
666  myCarQues[queIdx].push_back(v);
667  myNumCars++;
669  }
670  }
671  if (myCarQues[queIdx].size() != 0) {
672  // add the last vehicle of this queue
673  // !!! one question - what about the previously added vehicle? Is it stored twice?
674  MEVehicle* veh = myCarQues[queIdx].back();
676  }
677  myBlockTimes[queIdx] = block;
679 }
680 
681 
682 std::vector<const MEVehicle*>
684  std::vector<const MEVehicle*> result;
685  for (Queues::const_iterator k = myCarQues.begin(); k != myCarQues.end(); ++k) {
686  result.insert(result.end(), k->begin(), k->end());
687  }
688  return result;
689 }
690 
691 
692 bool
694  for (Queues::const_iterator k = myCarQues.begin(); k != myCarQues.end(); ++k) {
695  if (k->size() > 0 && (*k).back()->getWaitingTime() > 0) {
696  return true;
697  }
698  }
699  return false;
700 }
701 
702 
703 double
705  return 3600 * getCarNumber() * getMeanSpeed() / myLength;
706 }
707 
708 
709 SUMOTime
711  const MSLink* link = getLink(veh, myTLSPenalty || myMinorPenalty);
712  if (link != nullptr) {
713  SUMOTime result = 0;
714  if (link->isTLSControlled()) {
715  result += link->getMesoTLSPenalty();
716  }
717  // minor tls links may get an additional penalty
718  if (!link->havePriority() &&
719  // do not apply penalty if limited control is active
722  }
723  return result;
724  } else {
725  return 0;
726  }
727 }
728 
729 
730 double
732  if (myTLSPenalty) {
733  const MSLink* link = getLink(veh, true);
734  if (link != nullptr) {
735  assert(link->isTLSControlled());
736  assert(link->getGreenFraction() > 0);
737  return link->getGreenFraction();
738  }
739  }
740  return 1;
741 }
742 
743 
744 double
746  double maxPenalty = 0;
747  for (std::vector<MSLane*>::const_iterator i = myEdge.getLanes().begin(); i != myEdge.getLanes().end(); ++i) {
748  MSLane* l = *i;
749  const MSLinkCont& lc = l->getLinkCont();
750  for (MSLinkCont::const_iterator j = lc.begin(); j != lc.end(); ++j) {
751  MSLink* link = *j;
752  maxPenalty = MAX2(maxPenalty, STEPS2TIME(
753  link->getMesoTLSPenalty() + (link->havePriority() ? 0 : MSGlobals::gMesoMinorPenalty)));
754  }
755  }
756  return maxPenalty;
757 }
758 
759 /****************************************************************************/
MESegment::myTau_jj
const SUMOTime myTau_jj
Definition: MESegment.h:447
MEVehicle
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:44
MESegment::myJamThreshold
double myJamThreshold
The space (in m) which needs to be occupied before the segment is considered jammed.
Definition: MESegment.h:474
MSEdge::isRoundabout
bool isRoundabout() const
Definition: MSEdge.h:640
NODETYPE_TRAFFIC_LIGHT_RIGHT_ON_RED
Definition: SUMOXMLDefinitions.h:1058
MESegment::myCarQues
Queues myCarQues
The car queues. Vehicles are inserted in the front and removed in the back.
Definition: MESegment.h:480
MSEdge::getSuccessors
const MSEdgeVector & getSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges, restricted by vClass.
Definition: MSEdge.cpp:959
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
MSCFModel::getMaxDecel
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
Definition: MSCFModel.h:217
MESegment::newArrival
SUMOTime newArrival(const MEVehicle *const v, double newSpeed, SUMOTime currentTime)
compute the new arrival time when switching speed
Definition: MESegment.cpp:612
DEBUG_COND
#define DEBUG_COND
Definition: MESegment.cpp:53
MSEdge::getSpeedLimit
double getSpeedLimit() const
Returns the speed limit of the edge @caution The speed limit of the first lane is retured; should pro...
Definition: MSEdge.cpp:877
MESegment::myTau_fj
const SUMOTime myTau_fj
Definition: MESegment.h:447
MSNet.h
MSEdge::unlock
virtual void unlock() const
release exclusive access to the mesoscopic state
Definition: MSEdge.h:687
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Named
Base class for objects which have an id.
Definition: Named.h:56
MSEdge::getVehicleMaxSpeed
double getVehicleMaxSpeed(const SUMOTrafficObject *const veh) const
Returns the maximum speed the vehicle may use on this edge.
Definition: MSEdge.cpp:889
MESegment::getTLSCapacity
double getTLSCapacity(const MEVehicle *veh) const
Returns the average green time as fraction of cycle time.
Definition: MESegment.cpp:731
MESegment::limitedControlOverride
bool limitedControlOverride(const MSLink *link) const
whether the given link may be passed because the option meso-junction-control.limited is set
Definition: MESegment.cpp:443
MESegment::myTau_ff
const SUMOTime myTau_ff
The time headway parameters, see the Eissfeldt thesis.
Definition: MESegment.h:447
MSEdge::addWaiting
void addWaiting(SUMOVehicle *vehicle) const
Adds a vehicle to the list of waiting vehicles.
Definition: MSEdge.cpp:1106
MESegment::myMeanSpeed
double myMeanSpeed
the mean speed on this segment. Updated at event time or on demand
Definition: MESegment.h:505
MESegment
A single mesoscopic segment (cell)
Definition: MESegment.h:49
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
NUMERICAL_EPS
#define NUMERICAL_EPS
Definition: config.h:148
MESegment::myNumCars
int myNumCars
The cached value for the number of cars.
Definition: MESegment.h:483
MESegment::loadState
void loadState(const std::vector< std::string > &vehIDs, MSVehicleControl &vc, const SUMOTime blockTime, const int queIdx)
Loads the state of this segment with the given parameters.
Definition: MESegment.cpp:660
MELoop::changeSegment
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...
Definition: MELoop.cpp:80
MESegment::addDetector
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
Definition: MESegment.cpp:211
MESegment::myLastHeadway
SUMOTime myLastHeadway
the last headway
Definition: MESegment.h:497
MEVehicle::setLastEntryTime
void setLastEntryTime(SUMOTime t)
Sets the entry time for the current segment.
Definition: MEVehicle.h:263
MESegment::initialise
bool initialise(MEVehicle *veh, SUMOTime time)
Inserts (emits) vehicle into the segment.
Definition: MESegment.cpp:278
FileHelpers.h
MESegment::hasSpaceFor
bool hasSpaceFor(const MEVehicle *veh, SUMOTime entryTime, bool init=false) const
Returns whether the given vehicle would still fit into the segment.
Definition: MESegment.cpp:251
MESegment::myEdge
const MSEdge & myEdge
The microsim edge this segment belongs to.
Definition: MESegment.h:435
MEVehicle::getLastEntryTime
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
Definition: MEVehicle.h:271
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MESegment::jamThresholdForSpeed
double jamThresholdForSpeed(double speed, double jamThresh) const
compute jam threshold for the given speed and jam-threshold option
Definition: MESegment.cpp:192
MSBaseVehicle::hasValidRoute
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
Definition: MSBaseVehicle.cpp:435
MESegment::getTimeHeadway
SUMOTime getTimeHeadway(const MESegment *pred, const MEVehicle *veh)
Definition: MESegment.cpp:352
MSGlobals
Definition: MSGlobals.h:48
MSEdge.h
MAX3
T MAX3(T a, T b, T c)
Definition: StdDefs.h:93
SUMO_TAG_VIEWSETTINGS_VEHICLES
Definition: SUMOXMLDefinitions.h:247
MSVehicleControl::scheduleVehicleRemoval
void scheduleVehicleRemoval(SUMOVehicle *veh, bool checkDuplicate=false)
Removes a vehicle after it has ended.
Definition: MSVehicleControl.cpp:117
MESegment::isOpen
bool isOpen(const MEVehicle *veh) const
Returns whether the vehicle may use the next link.
Definition: MESegment.cpp:405
MEVehicle::setEventTime
void setEventTime(SUMOTime t, bool hasDelay=true)
Sets the (planned) time at which the vehicle leaves his current cell.
Definition: MEVehicle.h:217
MESegment::myDummyParent
static MSEdge myDummyParent
Definition: MESegment.h:501
MESegment::removeDetector
void removeDetector(MSMoveReminder *data)
Removes a data collector for a detector from this segment.
Definition: MESegment.cpp:222
MSDevice.h
MESegment::removeCar
MEVehicle * removeCar(MEVehicle *v, SUMOTime leaveTime, const MSMoveReminder::Notification reason)
Removes the given car from the edge's que.
Definition: MESegment.cpp:329
MESegment::recomputeJamThreshold
void recomputeJamThreshold(double jamThresh)
compute a value for myJamThreshold if jamThresh is negative, compute a value which allows free flow a...
Definition: MESegment.cpp:142
MEVehicle::moveRoutePointer
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
Definition: MEVehicle.cpp:138
MSVehicle.h
MSMoveReminder
Something on a lane to be noticed about vehicle movement.
Definition: MSMoveReminder.h:66
MESegment::myLastMeanSpeedUpdate
SUMOTime myLastMeanSpeedUpdate
the time at which myMeanSpeed was last updated
Definition: MESegment.h:508
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:253
MESegment.h
SUMOTime_MIN
#define SUMOTime_MIN
Definition: SUMOTime.h:36
MSBaseVehicle::getEdge
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
Definition: MSBaseVehicle.cpp:181
MEVehicle::updateDetectors
void updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_JUNCTION)
Updates all vehicle detectors.
Definition: MEVehicle.cpp:396
MAX2
T MAX2(T a, T b)
Definition: StdDefs.h:79
MEVehicle::getEventTime
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves his current cell.
Definition: MEVehicle.h:229
MESegment::myFollowerMap
std::map< const MSEdge *, std::vector< int > > myFollowerMap
The follower edge to que index mapping for multi queue segments.
Definition: MESegment.h:486
MESegment::getMaxPenaltySeconds
double getMaxPenaltySeconds() const
return the maximum tls penalty for all links from this edge
Definition: MESegment.cpp:745
MESegment::myTau_jf
const SUMOTime myTau_jf
Definition: MESegment.h:447
BinaryInputDevice.h
MSGlobals::gMesoOvertaking
static bool gMesoOvertaking
Definition: MSGlobals.h:96
MESegment::hasBlockedLeader
bool hasBlockedLeader() const
whether a leader in any queue is blocked
Definition: MESegment.cpp:693
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
MSMoveReminder.h
MELoop::addLeaderCar
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:197
RandHelper::rand
static double rand(std::mt19937 *rng=0)
Returns a random real number in [0, 1)
Definition: RandHelper.h:53
SIMTIME
#define SIMTIME
Definition: SUMOTime.h:63
MESegment::DO_NOT_PATCH_JAM_THRESHOLD
static const double DO_NOT_PATCH_JAM_THRESHOLD
Definition: MESegment.h:378
MSVehicleControl::getVehicle
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
Definition: MSVehicleControl.cpp:240
MESegment::prepareDetectorForWriting
void prepareDetectorForWriting(MSMoveReminder &data)
Updates data of a detector for all vehicle queues.
Definition: MESegment.cpp:237
MEVehicle::isStopped
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MEVehicle.cpp:241
MESegment::receive
void receive(MEVehicle *veh, SUMOTime time, bool isDepart=false, bool afterTeleport=false)
Adds the vehicle to the segment, adapting its parameters.
Definition: MESegment.cpp:491
MSVehicleType::getCarFollowModel
const MSCFModel & getCarFollowModel() const
Returns the vehicle type's car following model definition (const version)
Definition: MSVehicleType.h:140
MSBaseVehicle::getImpatience
double getImpatience() const
Returns this vehicles impatience.
Definition: MSBaseVehicle.cpp:557
MESegment::getMeanSpeed
double getMeanSpeed() const
wrapper to satisfy the FunctionBinding signature
Definition: MESegment.h:200
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:58
NODETYPE_TRAFFIC_LIGHT_NOJUNCTION
Definition: SUMOXMLDefinitions.h:1057
MSJunction.h
MESegment::myHeadwayCapacity
const double myHeadwayCapacity
The capacity of the segment in number of cars, used only in time headway calculation This parameter h...
Definition: MESegment.h:456
MSVehicleType::getLengthWithGap
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
Definition: MSVehicleType.h:117
SUMO_TAG_SEGMENT
segment of a lane
Definition: SUMOXMLDefinitions.h:174
MSGlobals::gMesoMinorPenalty
static SUMOTime gMesoMinorPenalty
Definition: MSGlobals.h:102
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
DEBUG_COND2
#define DEBUG_COND2(obj)
Definition: MESegment.cpp:54
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
MEVehicle::setBlockTime
void setBlockTime(const SUMOTime t)
Sets the time at which the vehicle was blocked.
Definition: MEVehicle.h:279
DEFAULT_VEH_LENGTH_WITH_GAP
#define DEFAULT_VEH_LENGTH_WITH_GAP
Definition: MESegment.cpp:45
MESegment::getFlow
double getFlow() const
returns flow based on headway
Definition: MESegment.cpp:704
MELoop::getSegmentForEdge
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:292
OutputDevice.h
MESegment::getLink
MSLink * getLink(const MEVehicle *veh, bool tlsPenalty=false) const
Returns the link the given car will use when passing the next junction.
Definition: MESegment.cpp:376
MESegment::myIndex
const int myIndex
Running number of the segment in the edge.
Definition: MESegment.h:444
ProcessError
Definition: UtilExceptions.h:39
MEVehicle::getStoptime
SUMOTime getStoptime(const MESegment *const seg, SUMOTime time) const
Returns until when to stop at the given segment.
Definition: MEVehicle.cpp:259
MSGlobals.h
MEVehicle::processStop
void processStop()
ends the current stop and performs loading/unloading
Definition: MEVehicle.cpp:306
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
MSGlobals::gCheckRoutes
static bool gCheckRoutes
Definition: MSGlobals.h:78
MSBaseVehicle::getVehicleType
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
Definition: MSBaseVehicle.h:123
MESegment::getEventTime
SUMOTime getEventTime() const
Returns the (planned) time at which the next vehicle leaves this segment.
Definition: MESegment.cpp:633
MSMoveReminder::NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSMoveReminder.h:93
MSEdge::allowedLanes
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
Definition: MSEdge.cpp:359
MSLane::getLinkCont
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
Definition: MSLane.cpp:2110
MESegment::vaporizeAnyCar
bool vaporizeAnyCar(SUMOTime currentTime)
tries to remove any car from this segment
Definition: MESegment.cpp:575
SUMO_ATTR_TIME
trigger: the time of the step
Definition: SUMOXMLDefinitions.h:676
MSMoveReminder::NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
Definition: MSMoveReminder.h:97
MESegment::myTLSPenalty
const bool myTLSPenalty
Whether tls penalty is enabled.
Definition: MESegment.h:468
MEVehicle::estimateLeaveSpeed
double estimateLeaveSpeed(const MSLink *link) const
Returns the vehicle's estimated speed after driving accross the link.
Definition: MEVehicle.cpp:122
MESegment::myEntryBlockTime
SUMOTime myEntryBlockTime
Definition: MESegment.h:494
MESegment::overtake
bool overtake()
Definition: MESegment.cpp:478
MSLane::getEdge
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:669
MEVehicle::getWaitingTime
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
Definition: MEVehicle.h:294
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
MESegment::isInvalid
static bool isInvalid(const MESegment *segment)
whether the given segment is 0 or encodes vaporization
Definition: MESegment.h:341
MEVehicle::getSegment
MESegment * getSegment() const
Returns the current segment the vehicle is on.
Definition: MEVehicle.h:247
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
MSGlobals::gMesoNet
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:105
MSMoveReminder::NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
Definition: MSMoveReminder.h:107
MSXMLRawOut.h
MESegment::myBlockTimes
std::vector< SUMOTime > myBlockTimes
The block times.
Definition: MESegment.h:489
MESegment::free
bool free() const
return whether this segment is considered free as opposed to jammed
Definition: MESegment.h:350
MEVehicle::getSpeed
double getSpeed() const
Returns the vehicle's estimated speed assuming no delays.
Definition: MEVehicle.cpp:106
MESegment::myJunctionControl
const bool myJunctionControl
Whether junction control is enabled.
Definition: MESegment.h:465
MEVehicle::hasArrived
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge)
Definition: MEVehicle.cpp:156
MESegment::myA
double myA
slope and axis offset for the jam-jam headway function
Definition: MESegment.h:452
MSBaseVehicle::succEdge
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
Definition: MSBaseVehicle.cpp:171
MEVehicle::setSegment
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
Definition: MEVehicle.h:238
SUMO_ATTR_VALUE
Definition: SUMOXMLDefinitions.h:779
MESegment::getNextInsertionTime
SUMOTime getNextInsertionTime(SUMOTime earliestEntry) const
return a time after earliestEntry at which a vehicle may be inserted at full speed
Definition: MESegment.cpp:361
MESegment::myMinorPenalty
const bool myMinorPenalty
Whether minor penalty is enabled.
Definition: MESegment.h:471
MESegment::send
void send(MEVehicle *veh, MESegment *next, SUMOTime time, const MSMoveReminder::Notification reason)
Removes the vehicle from the segment, adapting its parameters.
Definition: MESegment.cpp:456
MESegment::addReminders
void addReminders(MEVehicle *veh) const
add this lanes MoveReminders to the given vehicle
Definition: MESegment.cpp:484
MESegment::saveState
void saveState(OutputDevice &out)
Saves the state of this segment into the given stream.
Definition: MESegment.cpp:648
MSBaseVehicle::getID
const std::string & getID() const
Returns the name of the vehicle.
Definition: MSBaseVehicle.cpp:138
MEVehicle.h
MSEdge::getLanes
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:167
MSBaseVehicle::addReminder
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
Definition: MSBaseVehicle.cpp:463
MEVehicle::getQueIndex
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition: MEVehicle.h:255
MESegment::myLength
const double myLength
The segment's length.
Definition: MESegment.h:441
MESegment::myCapacity
const double myCapacity
The number of lanes * the length.
Definition: MESegment.h:459
MESegment::tauWithVehLength
SUMOTime tauWithVehLength(SUMOTime tau, double lengthWithGap) const
convert net time gap (leader back to follower front) to gross time gap (leader front to follower fron...
Definition: MESegment.h:429
MSEdge::getNumSuccessors
int getNumSuccessors() const
Returns the number of edges that may be reached from this edge.
Definition: MSEdge.h:324
MSBaseVehicle::onDepart
void onDepart()
Called when the vehicle is inserted into the network.
Definition: MSBaseVehicle.cpp:371
config.h
MSVehicleControl
The class responsible for building and deletion of vehicles.
Definition: MSVehicleControl.h:71
EDGEFUNC_UNKNOWN
Definition: SUMOXMLDefinitions.h:1080
Named::getIDSecure
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
Definition: Named.h:69
MSGlobals::gMesoLimitedJunctionControl
static bool gMesoLimitedJunctionControl
Definition: MSGlobals.h:93
RandHelper.h
StdDefs.h
MESegment::myDetectorData
std::vector< MSMoveReminder * > myDetectorData
The data collection for all kinds of detectors.
Definition: MESegment.h:477
MELoop.h
MESegment::MESegment
MESegment(const std::string &id, const MSEdge &parent, MESegment *next, double length, double speed, int idx, SUMOTime tauff, SUMOTime taufj, SUMOTime taujf, SUMOTime taujj, double jamThresh, bool multiQueue, bool junctionControl)
constructor
Definition: MESegment.cpp:66
MESegment::getLinkPenalty
SUMOTime getLinkPenalty(const MEVehicle *veh) const
Returns the penalty time for passing a link (if using gMesoTLSPenalty > 0 or gMesoMinorPenalty > 0)
Definition: MESegment.cpp:710
MESegment::writeVehicles
void writeVehicles(OutputDevice &of) const
Definition: MESegment.cpp:319
SUMOTime_MAX
#define SUMOTime_MAX
Definition: SUMOTime.h:35
MSLane.h
MESegment::setSpeed
void setSpeed(double newSpeed, SUMOTime currentTime, double jamThresh=DO_NOT_PATCH_JAM_THRESHOLD)
reset mySpeed and patch the speed of all vehicles in it. Also set/recompute myJamThreshold
Definition: MESegment.cpp:621
MSEdge::lock
virtual void lock() const
grant exclusive access to the mesoscopic state
Definition: MSEdge.h:684
MESegment::myVaporizationTarget
static MESegment myVaporizationTarget
Definition: MESegment.h:502
MESegment::myB
double myB
Definition: MESegment.h:452
MSVehicleControl.h
MSBaseVehicle::activateReminders
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
Definition: MSBaseVehicle.cpp:490
MESegment::setSpeedForQueue
void setSpeedForQueue(double newSpeed, SUMOTime currentTime, SUMOTime blockTime, const std::vector< MEVehicle * > &vehs)
Definition: MESegment.cpp:593
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:76
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSMoveReminder::NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
Definition: MSMoveReminder.h:95
MSXMLRawOut::writeVehicle
static void writeVehicle(OutputDevice &of, const MSBaseVehicle &veh)
Writes the dump of the given vehicle into the given device.
Definition: MSXMLRawOut.cpp:129
MESegment::getVehicles
std::vector< const MEVehicle * > getVehicles() const
returns all vehicles (for debugging)
Definition: MESegment.cpp:683
MESegment::useMultiQueue
static bool useMultiQueue(bool multiQueue, const MSEdge &parent)
whether the segment requires use of multiple queues
Definition: MESegment.cpp:137
MSNet::getVehicleControl
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:336
MESegment::myOccupancy
double myOccupancy
The occupied space (in m) on the segment.
Definition: MESegment.h:462
MESO_MIN_SPEED
#define MESO_MIN_SPEED
Definition: MESegment.cpp:47
MESegment::getCarNumber
int getCarNumber() const
Returns the total number of cars on the segment.
Definition: MESegment.h:123
MELoop::removeLeaderCar
void removeLeaderCar(MEVehicle *v)
Removes the given car from the leading vehicles.
Definition: MELoop.cpp:217
NODETYPE_TRAFFIC_LIGHT
Definition: SUMOXMLDefinitions.h:1056