Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RONet.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// The router's network representation
21/****************************************************************************/
22#include <config.h>
23
24#include <algorithm>
35#include "ROEdge.h"
36#include "ROLane.h"
37#include "RONode.h"
38#include "ROPerson.h"
39#include "RORoute.h"
40#include "RORouteDef.h"
41#include "ROVehicle.h"
43#include "RONet.h"
44
45
46// ===========================================================================
47// static member definitions
48// ===========================================================================
49RONet* RONet::myInstance = nullptr;
50
51
52// ===========================================================================
53// method definitions
54// ===========================================================================
55RONet*
57 if (myInstance != nullptr) {
58 return myInstance;
59 }
60 throw ProcessError(TL("A network was not yet constructed."));
61}
62
63
65 myVehicleTypes(), myDefaultVTypeMayBeDeleted(true),
66 myDefaultPedTypeMayBeDeleted(true),
67 myDefaultBikeTypeMayBeDeleted(true),
68 myDefaultTaxiTypeMayBeDeleted(true),
69 myDefaultRailTypeMayBeDeleted(true),
70 myHaveActiveFlows(true),
71 myRoutesOutput(nullptr), myRouteAlternativesOutput(nullptr), myTypesOutput(nullptr),
72 myReadRouteNo(0), myDiscardedRouteNo(0), myWrittenRouteNo(0),
73 myHavePermissions(false),
74 myNumInternalEdges(0),
75 myErrorHandler(OptionsCont::getOptions().exists("ignore-errors")
76 && OptionsCont::getOptions().getBool("ignore-errors") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
77 myKeepVTypeDist(OptionsCont::getOptions().exists("keep-vtype-distributions")
78 && OptionsCont::getOptions().getBool("keep-vtype-distributions")),
79 myDoPTRouting(!OptionsCont::getOptions().exists("ptline-routing")
80 || OptionsCont::getOptions().getBool("ptline-routing")),
81 myKeepFlows(OptionsCont::getOptions().exists("keep-flows")
82 && OptionsCont::getOptions().getBool("keep-flows")),
83 myHasBidiEdges(false) {
84 if (myInstance != nullptr) {
85 throw ProcessError(TL("A network was already constructed."));
86 }
88 type->onlyReferenced = true;
89 myVehicleTypes.add(type->id, type);
90
92 defPedType->onlyReferenced = true;
94 myVehicleTypes.add(defPedType->id, defPedType);
95
97 defBikeType->onlyReferenced = true;
99 myVehicleTypes.add(defBikeType->id, defBikeType);
100
102 defTaxiType->onlyReferenced = true;
104 myVehicleTypes.add(defTaxiType->id, defTaxiType);
105
107 defRailType->onlyReferenced = true;
109 myVehicleTypes.add(defRailType->id, defRailType);
110
111 myInstance = this;
112}
113
114
116 for (const auto& routables : myRoutables) {
117 for (RORoutable* const r : routables.second) {
118 const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
119 // delete routes and the vehicle
120 if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
121 if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
122 delete veh->getRouteDefinition();
123 }
124 }
125 delete r;
126 }
127 }
128 for (const RORoutable* const r : myPTVehicles) {
129 const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
130 // delete routes and the vehicle
131 if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
132 if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
133 delete veh->getRouteDefinition();
134 }
135 }
136 delete r;
137 }
138 myRoutables.clear();
139 for (const auto& vTypeDist : myVTypeDistDict) {
140 delete vTypeDist.second;
141 }
142}
143
144
145void
146RONet::addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
147 myRestrictions[id][svc] = speed;
148}
149
150
151double
152RONet::getPreference(const std::string& routingType, const SUMOVTypeParameter& pars) const {
154 auto it = myVTypePreferences.find(pars.id);
155 if (it != myVTypePreferences.end()) {
156 auto it2 = it->second.find(routingType);
157 if (it2 != it->second.end()) {
158 return it2->second;
159 }
160 }
161 auto it3 = myVClassPreferences.find(pars.vehicleClass);
162 if (it3 != myVClassPreferences.end()) {
163 auto it4 = it3->second.find(routingType);
164 if (it4 != it3->second.end()) {
165 return it4->second;
166 }
167 }
168 // fallback to generel preferences
169 it = myVTypePreferences.find("");
170 if (it != myVTypePreferences.end()) {
171 auto it2 = it->second.find(routingType);
172 if (it2 != it->second.end()) {
173 return it2->second;
174 }
175 }
176 }
177 return 1;
178}
179
180
181void
182RONet::addPreference(const std::string& routingType, SUMOVehicleClass svc, double prio) {
183 myVClassPreferences[svc][routingType] = prio;
184 gRoutingPreferences = true;
185}
186
187
188void
189RONet::addPreference(const std::string& routingType, std::string vType, double prio) {
190 myVTypePreferences[vType][routingType] = prio;
191 gRoutingPreferences = true;
192}
193
194
195
196const std::map<SUMOVehicleClass, double>*
197RONet::getRestrictions(const std::string& id) const {
198 std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = myRestrictions.find(id);
199 if (i == myRestrictions.end()) {
200 return nullptr;
201 }
202 return &i->second;
203}
204
205
206bool
208 if (!myEdges.add(edge->getID(), edge)) {
209 WRITE_ERRORF(TL("The edge '%' occurs at least twice."), edge->getID());
210 delete edge;
211 return false;
212 }
213 if (edge->isInternal()) {
215 }
216 return true;
217}
218
219
220bool
221RONet::addDistrict(const std::string id, ROEdge* source, ROEdge* sink) {
222 if (myDistricts.count(id) > 0) {
223 WRITE_ERRORF(TL("The TAZ '%' occurs at least twice."), id);
224 delete source;
225 delete sink;
226 return false;
227 }
229 if (!addEdge(sink)) {
230 return false;
231 }
233 if (!addEdge(source)) {
234 return false;
235 }
236 sink->setOtherTazConnector(source);
237 source->setOtherTazConnector(sink);
238 myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
239 return true;
240}
241
242
243bool
244RONet::addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource) {
245 if (myDistricts.count(tazID) == 0) {
246 WRITE_ERRORF(TL("The TAZ '%' is unknown."), tazID);
247 return false;
248 }
249 ROEdge* edge = getEdge(edgeID);
250 if (edge == nullptr) {
251 WRITE_ERRORF(TL("The edge '%' for TAZ '%' is unknown."), edgeID, tazID);
252 return false;
253 }
254 if (isSource) {
255 getEdge(tazID + "-source")->addSuccessor(edge);
256 myDistricts[tazID].first.push_back(edgeID);
257 } else {
258 edge->addSuccessor(getEdge(tazID + "-sink"));
259 myDistricts[tazID].second.push_back(edgeID);
260 }
261 return true;
262}
263
264
265void
267 for (auto item : myNodes) {
268 const std::string tazID = item.first;
269 if (myDistricts.count(tazID) != 0) {
270 WRITE_WARNINGF(TL("A TAZ with id '%' already exists. Not building junction TAZ."), tazID);
271 continue;
272 }
273 const std::string sourceID = tazID + "-source";
274 const std::string sinkID = tazID + "-sink";
275 // sink must be added before source
276 ROEdge* sink = eb.buildEdge(sinkID, nullptr, nullptr, 0, "", "");
277 ROEdge* source = eb.buildEdge(sourceID, nullptr, nullptr, 0, "", "");
278 sink->setOtherTazConnector(source);
279 source->setOtherTazConnector(sink);
280 if (!addDistrict(tazID, source, sink)) {
281 continue;
282 }
283 auto& district = myDistricts[tazID];
284 const RONode* junction = item.second;
285 for (const ROEdge* edge : junction->getIncoming()) {
286 if (!edge->isInternal()) {
287 const_cast<ROEdge*>(edge)->addSuccessor(sink);
288 district.second.push_back(edge->getID());
289 }
290 }
291 for (const ROEdge* edge : junction->getOutgoing()) {
292 if (!edge->isInternal()) {
293 source->addSuccessor(const_cast<ROEdge*>(edge));
294 district.first.push_back(edge->getID());
295 }
296 }
297 }
298}
299
300
301void
302RONet::setBidiEdges(const std::map<ROEdge*, std::string>& bidiMap) {
303 for (const auto& item : bidiMap) {
304 ROEdge* bidi = myEdges.get(item.second);
305 if (bidi == nullptr) {
306 WRITE_ERRORF(TL("The bidi edge '%' is not known."), item.second);
307 }
308 item.first->setBidiEdge(bidi);
309 myHasBidiEdges = true;
310 }
311}
312
313
314void
316 if (!myNodes.add(node->getID(), node)) {
317 WRITE_ERRORF(TL("The node '%' occurs at least twice."), node->getID());
318 delete node;
319 }
320}
321
322
323void
324RONet::addStoppingPlace(const std::string& id, const SumoXMLTag category, SUMOVehicleParameter::Stop* stop) {
325 if (!myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(id, stop)) {
326 WRITE_ERRORF(TL("The % '%' occurs at least twice."), toString(category), id);
327 delete stop;
328 }
329}
330
331
332bool
334 return myRoutes.add(def->getID(), def);
335}
336
337
338void
340 if (options.isSet("output-file") && options.getString("output-file") != "") {
341 myRoutesOutput = &OutputDevice::getDevice(options.getString("output-file"));
342 if (myRoutesOutput->isNull()) {
343 myRoutesOutput = nullptr;
344 } else {
345 myRoutesOutput->writeXMLHeader("routes", "routes_file.xsd");
346 }
347 }
348 if (options.exists("alternatives-output") && options.isSet("alternatives-output")
349 && !(options.exists("write-trips") && options.getBool("write-trips"))) {
350 myRouteAlternativesOutput = &OutputDevice::getDevice(options.getString("alternatives-output"));
353 } else {
354 myRouteAlternativesOutput->writeXMLHeader("routes", "routes_file.xsd");
355 }
356 }
357 if (options.isSet("vtype-output")) {
358 myTypesOutput = &OutputDevice::getDevice(options.getString("vtype-output"));
359 myTypesOutput->writeXMLHeader("routes", "routes_file.xsd");
360 }
361}
362
363
364void
366 if (options.exists("intermodal-network-output") && options.isSet("intermodal-network-output")) {
367 OutputDevice::createDeviceByOption("intermodal-network-output", "intermodal");
368 router.writeNetwork(OutputDevice::getDevice(options.getString("intermodal-network-output")));
369 }
370 if (options.exists("intermodal-weight-output") && options.isSet("intermodal-weight-output")) {
371 OutputDevice::createDeviceByOption("intermodal-weight-output", "weights", "meandata_file.xsd");
372 OutputDevice& dev = OutputDevice::getDeviceByOption("intermodal-weight-output");
374 dev.writeAttr(SUMO_ATTR_ID, "intermodalweights");
377 router.writeWeights(dev);
378 dev.closeTag();
379 }
380}
381
382
383void
385 // end writing
386 if (myRoutesOutput != nullptr) {
388 }
389 // only if opened
390 if (myRouteAlternativesOutput != nullptr) {
392 }
393 // only if opened
394 if (myTypesOutput != nullptr) {
396 }
398#ifdef HAVE_FOX
399 if (myThreadPool.size() > 0) {
400 myThreadPool.clear();
401 }
402#endif
403}
404
405
406
408RONet::getVehicleTypeSecure(const std::string& id) {
409 // check whether the type was already known
411 if (id == DEFAULT_VTYPE_ID) {
413 } else if (id == DEFAULT_PEDTYPE_ID) {
415 } else if (id == DEFAULT_BIKETYPE_ID) {
417 } else if (id == DEFAULT_TAXITYPE_ID) {
419 } else if (id == DEFAULT_RAILTYPE_ID) {
421 }
422 if (type != nullptr) {
423 return type;
424 }
425 VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
426 if (it2 != myVTypeDistDict.end()) {
427 return it2->second->get();
428 }
429 if (id == "") {
430 // ok, no vehicle type or an unknown type was given within the user input
431 // return the default type
434 }
435 return type;
436}
437
438
439bool
440RONet::checkVType(const std::string& id) {
441 if (id == DEFAULT_VTYPE_ID) {
445 } else {
446 return false;
447 }
448 } else if (id == DEFAULT_PEDTYPE_ID) {
452 } else {
453 return false;
454 }
455 } else if (id == DEFAULT_BIKETYPE_ID) {
459 } else {
460 return false;
461 }
462 } else if (id == DEFAULT_TAXITYPE_ID) {
466 } else {
467 return false;
468 }
469 } else if (id == DEFAULT_RAILTYPE_ID) {
473 } else {
474 return false;
475 }
476 } else {
477 if (myVehicleTypes.get(id) != 0 || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
478 return false;
479 }
480 }
481 return true;
482}
483
484
485bool
487 if (checkVType(type->id)) {
488 myVehicleTypes.add(type->id, type);
489 } else {
490 WRITE_ERRORF(TL("The vehicle type '%' occurs at least twice."), type->id);
491 delete type;
492 return false;
493 }
494 return true;
495}
496
497
498bool
499RONet::addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution) {
500 if (checkVType(id)) {
501 myVTypeDistDict[id] = vehTypeDistribution;
502 return true;
503 }
504 delete vehTypeDistribution;
505 return false;
506}
507
508
509bool
510RONet::addVehicle(const std::string& id, ROVehicle* veh) {
511 if (myVehIDs.find(id) == myVehIDs.end()) {
513
514 if (veh->isPublicTransport()) {
515 if (!veh->isPartOfFlow()) {
516 myPTVehicles.push_back(veh);
517 }
518 if (!myDoPTRouting) {
519 return true;
520 }
521 }
522 myRoutables[veh->getDepart()].push_back(veh);
523 return true;
524 }
525 WRITE_ERRORF(TL("Another vehicle with the id '%' exists."), id);
526 delete veh;
527 return false;
528}
529
530
531bool
532RONet::knowsVehicle(const std::string& id) const {
533 return myVehIDs.find(id) != myVehIDs.end();
534}
535
537RONet::getDeparture(const std::string& vehID) const {
538 auto it = myVehIDs.find(vehID);
539 if (it != myVehIDs.end()) {
540 return it->second;
541 } else {
542 throw ProcessError(TLF("Requesting departure time for unknown vehicle '%'", vehID));
543 }
544}
545
546
547bool
548RONet::addFlow(SUMOVehicleParameter* flow, const bool randomize) {
549 if (randomize && flow->repetitionOffset >= 0) {
550 myDepartures[flow->id].reserve(flow->repetitionNumber);
551 for (int i = 0; i < flow->repetitionNumber; ++i) {
552 myDepartures[flow->id].push_back(flow->depart + RandHelper::rand(flow->repetitionNumber * flow->repetitionOffset));
553 }
554 std::sort(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
555 std::reverse(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
556 }
557 const bool added = myFlows.add(flow->id, flow);
558 if (added) {
559 myHaveActiveFlows = true;
560 }
561 return added;
562}
563
564
565bool
567 if (myPersonIDs.count(person->getID()) == 0) {
568 myPersonIDs.insert(person->getID());
569 myRoutables[person->getDepart()].push_back(person);
570 return true;
571 }
572 WRITE_ERRORF(TL("Another person with the id '%' exists."), person->getID());
573 return false;
574}
575
576
577void
578RONet::addContainer(const SUMOTime depart, const std::string desc) {
579 myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
580}
581
582
583void
585 myHaveActiveFlows = false;
586 for (const auto& i : myFlows) {
587 SUMOVehicleParameter* const pars = i.second;
588 if (pars->line != "" && !myDoPTRouting) {
589 continue;
590 }
591 if (myKeepFlows) {
592 if (pars->repetitionsDone < pars->repetitionNumber) {
593 // each each flow only once
594 pars->repetitionsDone = pars->repetitionNumber;
596 if (type == nullptr) {
598 } else {
599 auto dist = getVTypeDistribution(pars->vtypeid);
600 if (dist != nullptr) {
601 WRITE_WARNINGF("Keeping flow '%' with a vTypeDistribution can lead to invalid routes if the distribution contains different vClasses", pars->id);
602 }
603 }
604 RORouteDef* route = getRouteDef(pars->routeid)->copy(pars->routeid, pars->depart);
605 ROVehicle* veh = new ROVehicle(*pars, route, type, this, errorHandler);
606 addVehicle(pars->id, veh);
607 }
608 } else if (pars->repetitionProbability > 0) {
609 if (pars->repetitionEnd > pars->depart && pars->repetitionsDone < pars->repetitionNumber) {
610 myHaveActiveFlows = true;
611 }
612 const SUMOTime origDepart = pars->depart;
613 while (pars->depart < time && pars->repetitionsDone < pars->repetitionNumber) {
614 if (pars->repetitionEnd <= pars->depart) {
615 break;
616 }
617 // only call rand if all other conditions are met
618 if (RandHelper::rand() < (pars->repetitionProbability * TS)) {
619 SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
620 newPars->id = pars->id + "." + toString(pars->repetitionsDone);
621 newPars->depart = pars->depart;
622 for (StopParVector::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
623 if (stop->until >= 0) {
624 stop->until += pars->depart - origDepart;
625 }
626 }
627 pars->repetitionsDone++;
628 // try to build the vehicle
630 if (type == nullptr) {
632 } else if (!myKeepVTypeDist) {
633 // fix the type id in case we used a distribution
634 newPars->vtypeid = type->id;
635 }
636 const SUMOTime stopOffset = pars->routeid[0] == '!' ? pars->depart - origDepart : pars->depart;
637 RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
638 ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
639 addVehicle(newPars->id, veh);
640 delete newPars;
641 }
642 pars->depart += DELTA_T;
643 }
644 } else {
645 SUMOTime depart = static_cast<SUMOTime>(pars->depart + pars->repetitionTotalOffset);
646 while (pars->repetitionsDone < pars->repetitionNumber && pars->repetitionEnd >= depart) {
647 myHaveActiveFlows = true;
648 depart = static_cast<SUMOTime>(pars->depart + pars->repetitionTotalOffset);
649 if (myDepartures.find(pars->id) != myDepartures.end()) {
650 depart = myDepartures[pars->id].back();
651 }
652 if (depart >= time + DELTA_T) {
653 break;
654 }
655 if (myDepartures.find(pars->id) != myDepartures.end()) {
656 myDepartures[pars->id].pop_back();
657 }
658 SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
659 newPars->id = pars->id + "." + toString(pars->repetitionsDone);
660 newPars->depart = depart;
661 for (StopParVector::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
662 if (stop->until >= 0) {
663 stop->until += depart - pars->depart;
664 }
665 }
666 pars->incrementFlow(1);
667 // try to build the vehicle
669 if (type == nullptr) {
671 } else if (!myKeepVTypeDist) {
672 // fix the type id in case we used a distribution
673 newPars->vtypeid = type->id;
674 }
675 const SUMOTime stopOffset = pars->routeid[0] == '!' ? depart - pars->depart : depart;
676 RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
677 ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
678 addVehicle(newPars->id, veh);
679 delete newPars;
680 }
681 }
682 }
683}
684
685
686void
687RONet::createBulkRouteRequests(const RORouterProvider& provider, const SUMOTime time, const bool removeLoops) {
688 std::map<const int, std::vector<RORoutable*> > bulkVehs;
689 int numBulked = 0;
690 for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
691 if (i->first >= time) {
692 break;
693 }
694 for (RORoutable* const routable : i->second) {
695 const ROEdge* const depEdge = routable->getDepartEdge();
696 bulkVehs[depEdge->getNumericalID()].push_back(routable);
697 RORoutable* const first = bulkVehs[depEdge->getNumericalID()].front();
698 numBulked++;
699 if (first->getMaxSpeed() != routable->getMaxSpeed()) {
700 WRITE_WARNINGF(TL("Bulking different maximum speeds ('%' and '%') may lead to suboptimal routes."), first->getID(), routable->getID());
701 }
702 if (first->getVClass() != routable->getVClass()) {
703 WRITE_WARNINGF(TL("Bulking different vehicle classes ('%' and '%') may lead to invalid routes."), first->getID(), routable->getID());
704 }
705 }
706 }
707#ifdef HAVE_FOX
708 int workerIndex = 0;
709#endif
710 if ((int)bulkVehs.size() < numBulked) {
711 WRITE_MESSAGE(TLF("Using bulk-mode for % entities from % origins", numBulked, bulkVehs.size()));
712 }
713 for (std::map<const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
714#ifdef HAVE_FOX
715 if (myThreadPool.size() > 0) {
716 bool bulk = true;
717 for (RORoutable* const r : i->second) {
718 myThreadPool.add(new RoutingTask(r, removeLoops, myErrorHandler), workerIndex);
719 if (bulk) {
720 myThreadPool.add(new BulkmodeTask(true), workerIndex);
721 bulk = false;
722 }
723 }
724 myThreadPool.add(new BulkmodeTask(false), workerIndex);
725 workerIndex++;
726 if (workerIndex == (int)myThreadPool.size()) {
727 workerIndex = 0;
728 }
729 continue;
730 }
731#endif
732 for (RORoutable* const r : i->second) {
733 r->computeRoute(provider, removeLoops, myErrorHandler);
734 provider.setBulkMode(true);
735 }
736 provider.setBulkMode(false);
737 }
738}
739
740
743 SUMOTime time) {
744 MsgHandler* mh = (options.getBool("ignore-errors") ?
746 if (myHaveActiveFlows) {
747 checkFlows(time, mh);
748 }
749 SUMOTime lastTime = -1;
750 const bool removeLoops = options.getBool("remove-loops");
751#ifdef HAVE_FOX
752 const int maxNumThreads = options.getInt("routing-threads");
753#endif
754 if (myRoutables.size() != 0) {
755 if (options.getBool("bulk-routing")) {
756#ifdef HAVE_FOX
757 while ((int)myThreadPool.size() < maxNumThreads) {
758 new WorkerThread(myThreadPool, provider);
759 }
760#endif
761 createBulkRouteRequests(provider, time, removeLoops);
762 } else {
763 for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
764 if (i->first >= time) {
765 break;
766 }
767 for (RORoutable* const routable : i->second) {
768#ifdef HAVE_FOX
769 // add task
770 if (maxNumThreads > 0) {
771 const int numThreads = (int)myThreadPool.size();
772 if (numThreads == 0) {
773 // This is the very first routing. Since at least the CHRouter needs initialization
774 // before it gets cloned, we do not do this in parallel
775 routable->computeRoute(provider, removeLoops, myErrorHandler);
776 new WorkerThread(myThreadPool, provider);
777 } else {
778 // add thread if necessary
779 if (numThreads < maxNumThreads && myThreadPool.isFull()) {
780 new WorkerThread(myThreadPool, provider);
781 }
782 myThreadPool.add(new RoutingTask(routable, removeLoops, myErrorHandler));
783 }
784 continue;
785 }
786#endif
787 routable->computeRoute(provider, removeLoops, myErrorHandler);
788 }
789 }
790 }
791#ifdef HAVE_FOX
792 myThreadPool.waitAll();
793#endif
794 }
795 const double scale = options.exists("scale-suffix") ? options.getFloat("scale") : 1;
796 // write all vehicles (and additional structures)
797 while (myRoutables.size() != 0 || myContainers.size() != 0) {
798 // get the next vehicle, person or container
799 RoutablesMap::iterator routables = myRoutables.begin();
800 const SUMOTime routableTime = routables == myRoutables.end() ? SUMOTime_MAX : routables->first;
801 ContainerMap::iterator container = myContainers.begin();
802 const SUMOTime containerTime = container == myContainers.end() ? SUMOTime_MAX : container->first;
803 // check whether it shall not yet be computed
804 if (routableTime >= time && containerTime >= time) {
805 lastTime = MIN2(routableTime, containerTime);
806 break;
807 }
808 const SUMOTime minTime = MIN2(routableTime, containerTime);
809 if (routableTime == minTime) {
810 // check whether to print the output
811 if (lastTime != routableTime && lastTime != -1) {
812 // report writing progress
813 if (options.getInt("stats-period") >= 0 && ((int)routableTime % options.getInt("stats-period")) == 0) {
814 WRITE_MESSAGE("Read: " + toString(myVehIDs.size()) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo));
815 }
816 }
817 lastTime = routableTime;
818 for (const RORoutable* const r : routables->second) {
819 // ok, check whether it has been routed
820 if (r->getRoutingSuccess()) {
821 // write the route
822 int quota = getScalingQuota(scale, myWrittenRouteNo);
823 r->write(myRoutesOutput, myRouteAlternativesOutput, myTypesOutput, options, quota);
825 } else {
827 }
828 // we need to keep individual public transport vehicles but not the flows
829 if (!r->isPublicTransport() || r->isPartOfFlow()) {
830 // delete routes and the vehicle
831 const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
832 if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
833 if (r->isPartOfFlow() || !myRoutes.remove(veh->getRouteDefinition()->getID())) {
834 delete veh->getRouteDefinition();
835 }
836 }
837 delete r;
838 }
839 }
840 myRoutables.erase(routables);
841 }
842 if (containerTime == minTime) {
843 myRoutesOutput->writePreformattedTag(container->second);
844 if (myRouteAlternativesOutput != nullptr) {
846 }
847 myContainers.erase(container);
848 }
849 }
850 return lastTime;
851}
852
853
854bool
856 return myRoutables.size() > 0 || (myFlows.size() > 0 && myHaveActiveFlows) || myContainers.size() > 0;
857}
858
859
860int
862 return myEdges.size();
863}
864
865
866int
870
871
872ROEdge*
873RONet::getEdgeForLaneID(const std::string& laneID) const {
875}
876
877
878ROLane*
879RONet::getLane(const std::string& laneID) const {
880 int laneIndex = SUMOXMLDefinitions::getIndexFromLane(laneID);
881 return getEdgeForLaneID(laneID)->getLanes()[laneIndex];
882}
883
884
885void
887 double taxiWait = STEPS2TIME(string2time(OptionsCont::getOptions().getString("persontrip.taxi.waiting-time")));
888 for (const auto& stopType : myInstance->myStoppingPlaces) {
889 // add access to all stopping places
890 const SumoXMLTag element = stopType.first;
891 for (const auto& stop : stopType.second) {
892 router.getNetwork()->addAccess(stop.first, myInstance->getEdgeForLaneID(stop.second->lane),
893 stop.second->startPos, stop.second->endPos, 0., element, false, taxiWait);
894 // add access to all public transport stops
895 if (element == SUMO_TAG_BUS_STOP) {
896 for (const auto& a : stop.second->accessPos) {
897 router.getNetwork()->addAccess(stop.first, myInstance->getEdgeForLaneID(std::get<0>(a)),
898 std::get<1>(a), std::get<1>(a), std::get<2>(a), SUMO_TAG_BUS_STOP, true, taxiWait);
899 }
900 }
901 }
902 }
903 // fill the public transport router with pre-parsed public transport lines
904 for (const auto& i : myInstance->myFlows) {
905 if (i.second->line != "") {
906 const RORouteDef* const route = myInstance->getRouteDef(i.second->routeid);
907 const StopParVector* addStops = nullptr;
908 if (route != nullptr && route->getFirstRoute() != nullptr) {
909 addStops = &route->getFirstRoute()->getStops();
910 }
911 router.getNetwork()->addSchedule(*i.second, addStops);
912 }
913 }
914 for (const RORoutable* const veh : myInstance->myPTVehicles) {
915 // add single vehicles with line attribute which are not part of a flow
916 // no need to add route stops here, they have been added to the vehicle before
917 router.getNetwork()->addSchedule(veh->getParameter());
918 }
919 // add access to transfer from walking to taxi-use
921 for (const ROEdge* edge : ROEdge::getAllEdges()) {
922 if (!edge->isTazConnector() && (edge->getPermissions() & SVC_PEDESTRIAN) != 0 && (edge->getPermissions() & SVC_TAXI) != 0) {
923 router.getNetwork()->addCarAccess(edge, SVC_TAXI, taxiWait);
924 }
925 }
926 }
927}
928
929
930bool
932 return myHavePermissions;
933}
934
935
936void
940
941bool
943 for (const auto& item : myEdges) {
944 if (item.second->hasStoredEffort()) {
945 return true;
946 }
947 }
948 return false;
949}
950
951const std::string
952RONet::getStoppingPlaceName(const std::string& id) const {
953 for (const auto& mapItem : myStoppingPlaces) {
954 SUMOVehicleParameter::Stop* stop = mapItem.second.get(id);
955 if (stop != nullptr) {
956 // see RONetHandler::parseStoppingPlace
957 return stop->busstop;
958 }
959 }
960 return "";
961}
962
963const std::string
964RONet::getStoppingPlaceElement(const std::string& id) const {
965 for (const auto& mapItem : myStoppingPlaces) {
966 SUMOVehicleParameter::Stop* stop = mapItem.second.get(id);
967 if (stop != nullptr) {
968 // see RONetHandler::parseStoppingPlace
969 return stop->actType;
970 }
971 }
973}
974
975
976#ifdef HAVE_FOX
977// ---------------------------------------------------------------------------
978// RONet::RoutingTask-methods
979// ---------------------------------------------------------------------------
980void
981RONet::RoutingTask::run(MFXWorkerThread* context) {
982 myRoutable->computeRoute(*static_cast<WorkerThread*>(context), myRemoveLoops, myErrorHandler);
983}
984#endif
985
986
987/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
@ TAXI_PICKUP_ANYWHERE
taxi customer may be picked up anywhere
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_ERRORF(...)
Definition MsgHandler.h:296
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:288
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOTime DELTA_T
Definition SUMOTime.cpp:38
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define SUMOTime_MAX
Definition SUMOTime.h:34
#define TS
Definition SUMOTime.h:42
const long long int VTYPEPARS_VEHICLECLASS_SET
const std::string DEFAULT_TAXITYPE_ID
const std::string DEFAULT_RAILTYPE_ID
const std::string DEFAULT_PEDTYPE_ID
const std::string DEFAULT_VTYPE_ID
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_RAIL
vehicle is a not electrified rail
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
@ SVC_BICYCLE
vehicle is a bicycle
@ SVC_TAXI
vehicle is a taxi
@ SVC_PEDESTRIAN
pedestrian
const std::string DEFAULT_BIKETYPE_ID
std::vector< SUMOVehicleParameter::Stop > StopParVector
@ TRIGGERED
The departure is person triggered.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
bool gRoutingPreferences
Definition StdDefs.cpp:37
int getScalingQuota(double frac, int loaded)
Returns the number of instances of the current object that shall be emitted given the number of loade...
Definition StdDefs.cpp:72
T MIN2(T a, T b)
Definition StdDefs.h:80
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
void addCarAccess(const E *edge, SUMOVehicleClass svc, double traveltime)
Adds access edges for transfering from walking to vehicle use.
void addAccess(const std::string &stopId, const E *stopEdge, const double startPos, const double endPos, const double length, const SumoXMLTag category, bool isAccess, double taxiWait)
Adds access edges for stopping places to the intermodal network.
void addSchedule(const SUMOVehicleParameter &pars, const StopParVector *addStops=nullptr)
Network * getNetwork() const
void writeWeights(OutputDevice &dev)
int getCarWalkTransfer() const
void writeNetwork(OutputDevice &dev)
A thread repeatingly calculating incoming tasks.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
const std::string & getID() const
Returns the id.
Definition Named.h:74
T get(const std::string &id) const
Retrieves an item.
int size() const
Returns the number of stored items within the container.
bool remove(const std::string &id, const bool del=true)
Removes an item.
bool add(const std::string &id, T item)
Adds an item.
A storage for options typed value containers)
Definition OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool exists(const std::string &name) const
Returns the information whether the named option is known.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & writePreformattedTag(const std::string &val)
writes a preformatted tag to the device but ensures that any pending tags are closed
void close()
Closes the device and removes it from the dictionary.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
virtual bool isNull()
returns the information whether the device will discard all output
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >(), bool includeConfig=true)
Writes an XML header with optional configuration.
Interface for building instances of router-edges.
virtual ROEdge * buildEdge(const std::string &name, RONode *from, RONode *to, const int priority, const std::string &type, const std::string &routingType)=0
Builds an edge with the given name.
A basic edge for routing applications.
Definition ROEdge.h:73
int getNumericalID() const
Returns the index (numeric id) of the edge.
Definition ROEdge.h:232
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
Definition ROEdge.h:118
bool isInternal() const
return whether this edge is an internal edge
Definition ROEdge.h:160
void setOtherTazConnector(const ROEdge *edge)
Definition ROEdge.h:178
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
Definition ROEdge.h:551
virtual void addSuccessor(ROEdge *s, ROEdge *via=nullptr, std::string dir="")
Adds information about a connected edge.
Definition ROEdge.cpp:135
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
Definition ROEdge.cpp:376
A single lane the router may use.
Definition ROLane.h:48
The router's network representation.
Definition RONet.h:63
void createBulkRouteRequests(const RORouterProvider &provider, const SUMOTime time, const bool removeLoops)
Definition RONet.cpp:687
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition RONet.cpp:408
static RONet * getInstance()
Returns the pointer to the unique instance of RONet (singleton).
Definition RONet.cpp:56
int myNumInternalEdges
The number of internal edges in the dictionary.
Definition RONet.h:590
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
Definition RONet.h:525
void setPermissionsFound()
Definition RONet.cpp:937
bool myDefaultRailTypeMayBeDeleted
Whether the default rail type was already used or can still be replaced.
Definition RONet.h:534
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
Definition RONet.h:522
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
Definition RONet.cpp:584
std::map< SUMOVehicleClass, std::map< std::string, double > > myVClassPreferences
Preferences for routing.
Definition RONet.h:586
const std::map< SUMOVehicleClass, double > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
Definition RONet.cpp:197
const RandomDistributor< SUMOVTypeParameter * > * getVTypeDistribution(const std::string &id)
Retrieves the named vehicle type distribution.
Definition RONet.h:292
double getPreference(const std::string &routingType, const SUMOVTypeParameter &pars) const
retriefe edge type specific routing preference
Definition RONet.cpp:152
ContainerMap myContainers
Definition RONet.h:550
std::set< std::string > myPersonIDs
Known person ids.
Definition RONet.h:502
std::map< std::string, std::pair< std::vector< std::string >, std::vector< std::string > > > myDistricts
traffic assignment zones with sources and sinks
Definition RONet.h:559
bool addRouteDef(RORouteDef *def)
Definition RONet.cpp:333
void addStoppingPlace(const std::string &id, const SumoXMLTag category, SUMOVehicleParameter::Stop *stop)
Definition RONet.cpp:324
bool knowsVehicle(const std::string &id) const
returns whether a vehicle with the given id was already loaded
Definition RONet.cpp:532
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary
Definition RONet.cpp:384
bool myHaveActiveFlows
whether any flows are still active
Definition RONet.h:546
std::map< std::string, SUMOTime > myVehIDs
Known vehicle ids and their departure.
Definition RONet.h:499
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
Definition RONet.cpp:339
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition RONet.h:543
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition RONet.h:565
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
Definition RONet.h:528
RoutablesMap myRoutables
Known routables.
Definition RONet.h:540
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
Definition RONet.cpp:867
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition RONet.cpp:510
SUMOTime getDeparture(const std::string &vehID) const
returns departure time for the given vehicle id
Definition RONet.cpp:537
bool myHasBidiEdges
whether the network contains bidirectional railway edges
Definition RONet.h:605
bool addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource)
Definition RONet.cpp:244
MsgHandler * myErrorHandler
handler for ignorable error messages
Definition RONet.h:593
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
Definition RONet.cpp:365
RONet()
Constructor.
Definition RONet.cpp:64
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition RONet.h:505
const std::string getStoppingPlaceElement(const std::string &id) const
return the element name for the given stopping place id
Definition RONet.cpp:964
void addContainer(const SUMOTime depart, const std::string desc)
Definition RONet.cpp:578
static void adaptIntermodalRouter(ROIntermodalRouter &router)
Definition RONet.cpp:886
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition RONet.h:169
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition RONet.cpp:146
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition RONet.h:537
bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
Definition RONet.cpp:855
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition RONet.cpp:440
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition RONet.h:562
bool addPerson(ROPerson *person)
Definition RONet.cpp:566
int myWrittenRouteNo
The number of written routes.
Definition RONet.h:577
static RONet * myInstance
Unique instance of RONet.
Definition RONet.h:496
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition RONet.h:330
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition RONet.cpp:742
virtual bool addEdge(ROEdge *edge)
Definition RONet.cpp:207
bool myDefaultTaxiTypeMayBeDeleted
Whether the default taxi type was already used or can still be replaced.
Definition RONet.h:531
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition RONet.h:583
std::map< SumoXMLTag, NamedObjectCont< SUMOVehicleParameter::Stop * > > myStoppingPlaces
Known bus / train / container stops and parking areas.
Definition RONet.h:511
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition RONet.cpp:486
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition RONet.h:580
bool hasPermissions() const
Definition RONet.cpp:931
void setBidiEdges(const std::map< ROEdge *, std::string > &bidiMap)
add a taz for every junction unless a taz with the same id already exists
Definition RONet.cpp:302
ROLane * getLane(const std::string &laneID) const
Retrieves a lane rom the network given its id.
Definition RONet.cpp:879
int myDiscardedRouteNo
The number of discarded routes.
Definition RONet.h:574
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition RONet.h:519
std::vector< const RORoutable * > myPTVehicles
vehicles to keep for public transport routing
Definition RONet.h:553
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition RONet.h:508
void addNode(RONode *node)
Definition RONet.cpp:315
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition RONet.cpp:499
void addJunctionTaz(ROAbstractEdgeBuilder &eb)
add a taz for every junction unless a taz with the same id already exists
Definition RONet.cpp:266
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition RONet.h:568
const bool myKeepFlows
whether to preserve flows
Definition RONet.h:602
const bool myDoPTRouting
whether to calculate routes for public transport
Definition RONet.h:599
const bool myKeepVTypeDist
whether to keep the vtype distribution in output
Definition RONet.h:596
virtual ~RONet()
Destructor.
Definition RONet.cpp:115
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
Definition RONet.cpp:952
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
Definition RONet.h:556
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
Definition RONet.cpp:861
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
Definition RONet.cpp:873
std::map< std::string, std::map< std::string, double > > myVTypePreferences
Definition RONet.h:587
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition RONet.cpp:548
bool hasLoadedEffort() const
whether efforts were loaded from file
Definition RONet.cpp:942
void addPreference(const std::string &routingType, SUMOVehicleClass svc, double prio)
add edge type specific routing preference
Definition RONet.cpp:182
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition RONet.h:514
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Definition RONet.cpp:221
Base class for nodes used by the router.
Definition RONode.h:46
const ConstROEdgeVector & getOutgoing() const
Definition RONode.h:76
const ConstROEdgeVector & getIncoming() const
Definition RONode.h:72
A person as used by router.
Definition ROPerson.h:50
A routable thing such as a vehicle or person.
Definition RORoutable.h:53
SUMOVehicleClass getVClass() const
Definition RORoutable.h:117
bool isPublicTransport() const
Definition RORoutable.h:137
bool isPartOfFlow() const
Definition RORoutable.h:141
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition RORoutable.h:108
const std::string & getID() const
Returns the id of the routable.
Definition RORoutable.h:95
const SUMOVehicleParameter & getParameter() const
Returns the definition of the vehicle / person parameter.
Definition RORoutable.h:75
double getMaxSpeed() const
Returns the vehicle's maximum speed.
Definition RORoutable.h:129
Base class for a vehicle's route definition.
Definition RORouteDef.h:53
const RORoute * getFirstRoute() const
Definition RORouteDef.h:104
RORouteDef * copy(const std::string &id, const SUMOTime stopOffset) const
Returns a deep copy of the route definition.
const StopParVector & getStops() const
Returns the list of stops this route contains.
Definition RORoute.h:190
A vehicle as used by router.
Definition ROVehicle.h:50
SUMOTime getDepartureTime() const
Returns the time the vehicle starts at, 0 for triggered vehicles.
Definition ROVehicle.h:92
RORouteDef * getRouteDefinition() const
Returns the definition of the route the vehicle takes.
Definition ROVehicle.h:73
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Represents a generic random distribution.
void setBulkMode(const bool mode) const
Structure representing possible vehicle parameter.
long long int parametersSet
Information for the router which parameter were set.
bool onlyReferenced
Information whether this is a type-stub, being only referenced but not defined (needed by routers)
SUMOVehicleClass vehicleClass
The vehicle's class.
std::string id
The vehicle type's id.
Definition of vehicle stop (position and duration)
std::string actType
act Type (only used by Persons) (used by netedit)
std::string busstop
(Optional) bus stop if one is assigned to the stop
Structure representing possible vehicle parameter.
double repetitionProbability
The probability for emitting a vehicle per second.
void incrementFlow(double scale, SumoRNG *rng=nullptr)
increment flow
std::string vtypeid
The vehicle's type id.
SUMOTime repetitionOffset
The time offset between vehicle reinsertions.
int repetitionsDone
The number of times the vehicle was already inserted.
SUMOTime repetitionTotalOffset
The offset between depart and the time for the next vehicle insertions.
SUMOTime repetitionEnd
The time at which the flow ends (only needed when using repetitionProbability)
std::string routeid
The vehicle's route id.
std::string id
The vehicle's id.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
DepartDefinition departProcedure
Information how the vehicle shall choose the depart time.
std::string line
The vehicle's line (mainly for public transport)
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
static int getIndexFromLane(const std::string laneID)
return lane index when given the lane ID