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 myHaveParamRestrictions(false),
75 myNumInternalEdges(0),
76 myErrorHandler(OptionsCont::getOptions().exists("ignore-errors")
77 && OptionsCont::getOptions().getBool("ignore-errors") ? MsgHandler::getWarningInstance() : MsgHandler::getErrorInstance()),
78 myKeepVTypeDist(OptionsCont::getOptions().exists("keep-vtype-distributions")
79 && OptionsCont::getOptions().getBool("keep-vtype-distributions")),
80 myDoPTRouting(!OptionsCont::getOptions().exists("ptline-routing")
81 || OptionsCont::getOptions().getBool("ptline-routing")),
82 myKeepFlows(OptionsCont::getOptions().exists("keep-flows")
83 && OptionsCont::getOptions().getBool("keep-flows")),
84 myHasBidiEdges(false),
85 myMaxTraveltime(OptionsCont::getOptions().exists("max-traveltime") ? STEPS2TIME(string2time(OptionsCont::getOptions().getString("max-traveltime"))) : -1)
86{
87 if (myInstance != nullptr) {
88 throw ProcessError(TL("A network was already constructed."));
89 }
91 type->onlyReferenced = true;
92 myVehicleTypes.add(type->id, type);
93
95 defPedType->onlyReferenced = true;
97 myVehicleTypes.add(defPedType->id, defPedType);
98
100 defBikeType->onlyReferenced = true;
102 myVehicleTypes.add(defBikeType->id, defBikeType);
103
105 defTaxiType->onlyReferenced = true;
107 myVehicleTypes.add(defTaxiType->id, defTaxiType);
108
110 defRailType->onlyReferenced = true;
112 myVehicleTypes.add(defRailType->id, defRailType);
113
114 myInstance = this;
115}
116
117
119 for (const auto& routables : myRoutables) {
120 for (RORoutable* const r : routables.second) {
121 const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
122 // delete routes and the vehicle
123 if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
124 if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
125 delete veh->getRouteDefinition();
126 }
127 }
128 delete r;
129 }
130 }
131 for (const RORoutable* const r : myPTVehicles) {
132 const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
133 // delete routes and the vehicle
134 if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
135 if (!myRoutes.remove(veh->getRouteDefinition()->getID())) {
136 delete veh->getRouteDefinition();
137 }
138 }
139 delete r;
140 }
141 myRoutables.clear();
142 for (const auto& vTypeDist : myVTypeDistDict) {
143 delete vTypeDist.second;
144 }
145}
146
147
148void
149RONet::addSpeedRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed) {
150 mySpeedRestrictions[id][svc] = speed;
151}
152
153
154double
155RONet::getPreference(const std::string& routingType, const SUMOVTypeParameter& pars) const {
157 auto it = myVTypePreferences.find(pars.id);
158 if (it != myVTypePreferences.end()) {
159 auto it2 = it->second.find(routingType);
160 if (it2 != it->second.end()) {
161 return it2->second;
162 }
163 }
164 auto it3 = myVClassPreferences.find(pars.vehicleClass);
165 if (it3 != myVClassPreferences.end()) {
166 auto it4 = it3->second.find(routingType);
167 if (it4 != it3->second.end()) {
168 return it4->second;
169 }
170 }
171 // fallback to generel preferences
172 it = myVTypePreferences.find("");
173 if (it != myVTypePreferences.end()) {
174 auto it2 = it->second.find(routingType);
175 if (it2 != it->second.end()) {
176 return it2->second;
177 }
178 }
179 }
180 return 1;
181}
182
183
184void
185RONet::addPreference(const std::string& routingType, SUMOVehicleClass svc, double prio) {
186 myVClassPreferences[svc][routingType] = prio;
187 gRoutingPreferences = true;
188}
189
190
191void
192RONet::addPreference(const std::string& routingType, std::string vType, double prio) {
193 myVTypePreferences[vType][routingType] = prio;
194 gRoutingPreferences = true;
195}
196
197
198
199const std::map<SUMOVehicleClass, double>*
200RONet::getRestrictions(const std::string& id) const {
201 std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i = mySpeedRestrictions.find(id);
202 if (i == mySpeedRestrictions.end()) {
203 return nullptr;
204 }
205 return &i->second;
206}
207
208
209bool
211 if (!myEdges.add(edge->getID(), edge)) {
212 WRITE_ERRORF(TL("The edge '%' occurs at least twice."), edge->getID());
213 delete edge;
214 return false;
215 }
216 if (edge->isInternal()) {
218 }
219 return true;
220}
221
222
223bool
224RONet::addDistrict(const std::string id, ROEdge* source, ROEdge* sink) {
225 if (myDistricts.count(id) > 0) {
226 WRITE_ERRORF(TL("The TAZ '%' occurs at least twice."), id);
227 delete source;
228 delete sink;
229 return false;
230 }
232 if (!addEdge(sink)) {
233 return false;
234 }
236 if (!addEdge(source)) {
237 return false;
238 }
239 sink->setOtherTazConnector(source);
240 source->setOtherTazConnector(sink);
241 myDistricts[id] = std::make_pair(std::vector<std::string>(), std::vector<std::string>());
242 return true;
243}
244
245
246bool
247RONet::addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource) {
248 if (myDistricts.count(tazID) == 0) {
249 WRITE_ERRORF(TL("The TAZ '%' is unknown."), tazID);
250 return false;
251 }
252 ROEdge* edge = getEdge(edgeID);
253 if (edge == nullptr) {
254 WRITE_ERRORF(TL("The edge '%' for TAZ '%' is unknown."), edgeID, tazID);
255 return false;
256 }
257 if (isSource) {
258 getEdge(tazID + "-source")->addSuccessor(edge);
259 myDistricts[tazID].first.push_back(edgeID);
260 } else {
261 edge->addSuccessor(getEdge(tazID + "-sink"));
262 myDistricts[tazID].second.push_back(edgeID);
263 }
264 return true;
265}
266
267
268void
270 for (auto item : myNodes) {
271 const std::string tazID = item.first;
272 if (myDistricts.count(tazID) != 0) {
273 WRITE_WARNINGF(TL("A TAZ with id '%' already exists. Not building junction TAZ."), tazID);
274 continue;
275 }
276 const std::string sourceID = tazID + "-source";
277 const std::string sinkID = tazID + "-sink";
278 // sink must be added before source
279 ROEdge* sink = eb.buildEdge(sinkID, nullptr, nullptr, 0, "", "");
280 ROEdge* source = eb.buildEdge(sourceID, nullptr, nullptr, 0, "", "");
281 sink->setOtherTazConnector(source);
282 source->setOtherTazConnector(sink);
283 if (!addDistrict(tazID, source, sink)) {
284 continue;
285 }
286 auto& district = myDistricts[tazID];
287 const RONode* junction = item.second;
288 for (const ROEdge* edge : junction->getIncoming()) {
289 if (!edge->isInternal()) {
290 const_cast<ROEdge*>(edge)->addSuccessor(sink);
291 district.second.push_back(edge->getID());
292 }
293 }
294 for (const ROEdge* edge : junction->getOutgoing()) {
295 if (!edge->isInternal()) {
296 source->addSuccessor(const_cast<ROEdge*>(edge));
297 district.first.push_back(edge->getID());
298 }
299 }
300 }
301}
302
303
304void
305RONet::setBidiEdges(const std::map<ROEdge*, std::string>& bidiMap) {
306 for (const auto& item : bidiMap) {
307 ROEdge* bidi = myEdges.get(item.second);
308 if (bidi == nullptr) {
309 WRITE_ERRORF(TL("The bidi edge '%' is not known."), item.second);
310 }
311 item.first->setBidiEdge(bidi);
312 myHasBidiEdges = true;
313 }
314}
315
316
317void
319 if (!myNodes.add(node->getID(), node)) {
320 WRITE_ERRORF(TL("The node '%' occurs at least twice."), node->getID());
321 delete node;
322 }
323}
324
325
326void
327RONet::addStoppingPlace(const std::string& id, const SumoXMLTag category, SUMOVehicleParameter::Stop* stop) {
328 if (!myStoppingPlaces[category == SUMO_TAG_TRAIN_STOP ? SUMO_TAG_BUS_STOP : category].add(id, stop)) {
329 WRITE_ERRORF(TL("The % '%' occurs at least twice."), toString(category), id);
330 delete stop;
331 }
332}
333
334
335bool
337 return myRoutes.add(def->getID(), def);
338}
339
340
341void
343 if (options.isSet("output-file") && options.getString("output-file") != "") {
344 myRoutesOutput = &OutputDevice::getDevice(options.getString("output-file"));
345 if (myRoutesOutput->isNull()) {
346 myRoutesOutput = nullptr;
347 } else {
348 myRoutesOutput->writeXMLHeader("routes", "routes_file.xsd");
349 }
350 }
351 if (options.exists("alternatives-output") && options.isSet("alternatives-output")
352 && !(options.exists("write-trips") && options.getBool("write-trips"))) {
353 myRouteAlternativesOutput = &OutputDevice::getDevice(options.getString("alternatives-output"));
356 } else {
357 myRouteAlternativesOutput->writeXMLHeader("routes", "routes_file.xsd");
358 }
359 }
360 if (options.isSet("vtype-output")) {
361 myTypesOutput = &OutputDevice::getDevice(options.getString("vtype-output"));
362 myTypesOutput->writeXMLHeader("routes", "routes_file.xsd");
363 }
364}
365
366
367void
369 if (options.exists("intermodal-network-output") && options.isSet("intermodal-network-output")) {
370 OutputDevice::createDeviceByOption("intermodal-network-output", "intermodal");
371 router.writeNetwork(OutputDevice::getDevice(options.getString("intermodal-network-output")));
372 }
373 if (options.exists("intermodal-weight-output") && options.isSet("intermodal-weight-output")) {
374 OutputDevice::createDeviceByOption("intermodal-weight-output", "weights", "meandata_file.xsd");
375 OutputDevice& dev = OutputDevice::getDeviceByOption("intermodal-weight-output");
377 dev.writeAttr(SUMO_ATTR_ID, "intermodalweights");
380 router.writeWeights(dev);
381 dev.closeTag();
382 }
383}
384
385
386void
388 // end writing
389 if (myRoutesOutput != nullptr) {
391 }
392 // only if opened
393 if (myRouteAlternativesOutput != nullptr) {
395 }
396 // only if opened
397 if (myTypesOutput != nullptr) {
399 }
401#ifdef HAVE_FOX
402 if (myThreadPool.size() > 0) {
403 myThreadPool.clear();
404 }
405#endif
406}
407
408
409
411RONet::getVehicleTypeSecure(const std::string& id) {
412 // check whether the type was already known
414 if (id == DEFAULT_VTYPE_ID) {
416 } else if (id == DEFAULT_PEDTYPE_ID) {
418 } else if (id == DEFAULT_BIKETYPE_ID) {
420 } else if (id == DEFAULT_TAXITYPE_ID) {
422 } else if (id == DEFAULT_RAILTYPE_ID) {
424 }
425 if (type != nullptr) {
426 return type;
427 }
428 VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
429 if (it2 != myVTypeDistDict.end()) {
430 return it2->second->get();
431 }
432 if (id == "") {
433 // ok, no vehicle type or an unknown type was given within the user input
434 // return the default type
437 }
438 return type;
439}
440
441
442bool
443RONet::checkVType(const std::string& id) {
444 if (id == DEFAULT_VTYPE_ID) {
448 } else {
449 return false;
450 }
451 } else if (id == DEFAULT_PEDTYPE_ID) {
455 } else {
456 return false;
457 }
458 } else if (id == DEFAULT_BIKETYPE_ID) {
462 } else {
463 return false;
464 }
465 } else if (id == DEFAULT_TAXITYPE_ID) {
469 } else {
470 return false;
471 }
472 } else if (id == DEFAULT_RAILTYPE_ID) {
476 } else {
477 return false;
478 }
479 } else {
480 if (myVehicleTypes.get(id) != 0 || myVTypeDistDict.find(id) != myVTypeDistDict.end()) {
481 return false;
482 }
483 }
484 return true;
485}
486
487
488bool
490 if (checkVType(type->id)) {
491 myVehicleTypes.add(type->id, type);
492 } else {
493 WRITE_ERRORF(TL("The vehicle type '%' occurs at least twice."), type->id);
494 delete type;
495 return false;
496 }
497 return true;
498}
499
500
501bool
502RONet::addVTypeDistribution(const std::string& id, RandomDistributor<SUMOVTypeParameter*>* vehTypeDistribution) {
503 if (checkVType(id)) {
504 myVTypeDistDict[id] = vehTypeDistribution;
505 return true;
506 }
507 delete vehTypeDistribution;
508 return false;
509}
510
511
512bool
513RONet::addVehicle(const std::string& id, ROVehicle* veh) {
514 if (myVehIDs.find(id) == myVehIDs.end()) {
516
517 if (veh->isPublicTransport()) {
518 if (!veh->isPartOfFlow()) {
519 myPTVehicles.push_back(veh);
520 }
521 if (!myDoPTRouting) {
522 return true;
523 }
524 }
525 myRoutables[veh->getDepart()].push_back(veh);
526 return true;
527 }
528 WRITE_ERRORF(TL("Another vehicle with the id '%' exists."), id);
529 delete veh;
530 return false;
531}
532
533
534bool
535RONet::knowsVehicle(const std::string& id) const {
536 return myVehIDs.find(id) != myVehIDs.end();
537}
538
540RONet::getDeparture(const std::string& vehID) const {
541 auto it = myVehIDs.find(vehID);
542 if (it != myVehIDs.end()) {
543 return it->second;
544 } else {
545 throw ProcessError(TLF("Requesting departure time for unknown vehicle '%'", vehID));
546 }
547}
548
549
550bool
551RONet::addFlow(SUMOVehicleParameter* flow, const bool randomize) {
552 if (randomize && flow->repetitionOffset >= 0) {
553 myDepartures[flow->id].reserve(flow->repetitionNumber);
554 for (int i = 0; i < flow->repetitionNumber; ++i) {
555 myDepartures[flow->id].push_back(flow->depart + RandHelper::rand(flow->repetitionNumber * flow->repetitionOffset));
556 }
557 std::sort(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
558 std::reverse(myDepartures[flow->id].begin(), myDepartures[flow->id].end());
559 }
560 const bool added = myFlows.add(flow->id, flow);
561 if (added) {
562 myHaveActiveFlows = true;
563 }
564 return added;
565}
566
567
568bool
570 if (myPersonIDs.count(person->getID()) == 0) {
571 myPersonIDs.insert(person->getID());
572 myRoutables[person->getDepart()].push_back(person);
573 return true;
574 }
575 WRITE_ERRORF(TL("Another person with the id '%' exists."), person->getID());
576 return false;
577}
578
579
580void
581RONet::addContainer(const SUMOTime depart, const std::string desc) {
582 myContainers.insert(std::pair<const SUMOTime, const std::string>(depart, desc));
583}
584
585
586void
588 myHaveActiveFlows = false;
589 for (const auto& i : myFlows) {
590 SUMOVehicleParameter* const pars = i.second;
591 if (pars->line != "" && !myDoPTRouting) {
592 continue;
593 }
594 if (myKeepFlows) {
595 if (pars->repetitionsDone < pars->repetitionNumber) {
596 // each each flow only once
597 pars->repetitionsDone = pars->repetitionNumber;
599 if (type == nullptr) {
601 } else {
602 auto dist = getVTypeDistribution(pars->vtypeid);
603 if (dist != nullptr) {
604 WRITE_WARNINGF("Keeping flow '%' with a vTypeDistribution can lead to invalid routes if the distribution contains different vClasses", pars->id);
605 }
606 }
607 RORouteDef* route = getRouteDef(pars->routeid)->copy(pars->routeid, pars->depart);
608 ROVehicle* veh = new ROVehicle(*pars, route, type, this, errorHandler);
609 addVehicle(pars->id, veh);
610 }
611 } else if (pars->repetitionProbability > 0) {
612 if (pars->repetitionEnd > pars->depart && pars->repetitionsDone < pars->repetitionNumber) {
613 myHaveActiveFlows = true;
614 }
615 const SUMOTime origDepart = pars->depart;
616 while (pars->depart < time && pars->repetitionsDone < pars->repetitionNumber) {
617 if (pars->repetitionEnd <= pars->depart) {
618 break;
619 }
620 // only call rand if all other conditions are met
621 if (RandHelper::rand() < (pars->repetitionProbability * TS)) {
622 SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
623 newPars->id = pars->id + "." + toString(pars->repetitionsDone);
624 newPars->depart = pars->depart;
625 for (StopParVector::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
626 if (stop->until >= 0) {
627 stop->until += pars->depart - origDepart;
628 }
629 }
630 pars->repetitionsDone++;
631 // try to build the vehicle
633 if (type == nullptr) {
635 } else if (!myKeepVTypeDist) {
636 // fix the type id in case we used a distribution
637 newPars->vtypeid = type->id;
638 }
639 const SUMOTime stopOffset = pars->routeid[0] == '!' ? pars->depart - origDepart : pars->depart;
640 RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
641 ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
642 addVehicle(newPars->id, veh);
643 delete newPars;
644 }
645 pars->depart += DELTA_T;
646 }
647 } else {
648 SUMOTime depart = static_cast<SUMOTime>(pars->depart + pars->repetitionTotalOffset);
649 while (pars->repetitionsDone < pars->repetitionNumber && pars->repetitionEnd >= depart) {
650 myHaveActiveFlows = true;
651 depart = static_cast<SUMOTime>(pars->depart + pars->repetitionTotalOffset);
652 if (myDepartures.find(pars->id) != myDepartures.end()) {
653 depart = myDepartures[pars->id].back();
654 }
655 if (depart >= time + DELTA_T) {
656 break;
657 }
658 if (myDepartures.find(pars->id) != myDepartures.end()) {
659 myDepartures[pars->id].pop_back();
660 }
661 SUMOVehicleParameter* newPars = new SUMOVehicleParameter(*pars);
662 newPars->id = pars->id + "." + toString(pars->repetitionsDone);
663 newPars->depart = depart;
664 for (StopParVector::iterator stop = newPars->stops.begin(); stop != newPars->stops.end(); ++stop) {
665 if (stop->until >= 0) {
666 stop->until += depart - pars->depart;
667 }
668 }
669 pars->incrementFlow(1);
670 // try to build the vehicle
672 if (type == nullptr) {
674 } else if (!myKeepVTypeDist) {
675 // fix the type id in case we used a distribution
676 newPars->vtypeid = type->id;
677 }
678 const SUMOTime stopOffset = pars->routeid[0] == '!' ? depart - pars->depart : depart;
679 RORouteDef* route = getRouteDef(pars->routeid)->copy("!" + newPars->id, stopOffset);
680 ROVehicle* veh = new ROVehicle(*newPars, route, type, this, errorHandler);
681 addVehicle(newPars->id, veh);
682 delete newPars;
683 }
684 }
685 }
686}
687
688
689void
690RONet::createBulkRouteRequests(const RORouterProvider& provider, const SUMOTime time, const bool removeLoops) {
691 std::map<const int, std::vector<RORoutable*> > bulkVehs;
692 int numBulked = 0;
693 for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
694 if (i->first >= time) {
695 break;
696 }
697 for (RORoutable* const routable : i->second) {
698 const ROEdge* const depEdge = routable->getDepartEdge();
699 bulkVehs[depEdge->getNumericalID()].push_back(routable);
700 RORoutable* const first = bulkVehs[depEdge->getNumericalID()].front();
701 numBulked++;
702 if (first->getMaxSpeed() != routable->getMaxSpeed()) {
703 WRITE_WARNINGF(TL("Bulking different maximum speeds ('%' and '%') may lead to suboptimal routes."), first->getID(), routable->getID());
704 }
705 if (first->getVClass() != routable->getVClass()) {
706 WRITE_WARNINGF(TL("Bulking different vehicle classes ('%' and '%') may lead to invalid routes."), first->getID(), routable->getID());
707 }
708 }
709 }
710#ifdef HAVE_FOX
711 int workerIndex = 0;
712#endif
713 if ((int)bulkVehs.size() < numBulked) {
714 WRITE_MESSAGE(TLF("Using bulk-mode for % entities from % origins", numBulked, bulkVehs.size()));
715 }
716 for (std::map<const int, std::vector<RORoutable*> >::const_iterator i = bulkVehs.begin(); i != bulkVehs.end(); ++i) {
717#ifdef HAVE_FOX
718 if (myThreadPool.size() > 0) {
719 bool bulk = true;
720 for (RORoutable* const r : i->second) {
721 myThreadPool.add(new RoutingTask(r, removeLoops, myErrorHandler), workerIndex);
722 if (bulk) {
723 myThreadPool.add(new BulkmodeTask(true), workerIndex);
724 bulk = false;
725 }
726 }
727 myThreadPool.add(new BulkmodeTask(false), workerIndex);
728 workerIndex++;
729 if (workerIndex == (int)myThreadPool.size()) {
730 workerIndex = 0;
731 }
732 continue;
733 }
734#endif
735 for (RORoutable* const r : i->second) {
736 r->computeRoute(provider, removeLoops, myErrorHandler);
737 provider.setBulkMode(true);
738 }
739 provider.setBulkMode(false);
740 }
741}
742
743
746 SUMOTime time) {
747 MsgHandler* mh = (options.getBool("ignore-errors") ?
749 if (myHaveActiveFlows) {
750 checkFlows(time, mh);
751 }
752 SUMOTime lastTime = -1;
753 const bool removeLoops = options.getBool("remove-loops");
754#ifdef HAVE_FOX
755 const int maxNumThreads = options.getInt("routing-threads");
756#endif
757 if (myRoutables.size() != 0) {
758 if (options.getBool("bulk-routing")) {
759#ifdef HAVE_FOX
760 while ((int)myThreadPool.size() < maxNumThreads) {
761 new WorkerThread(myThreadPool, provider);
762 }
763#endif
764 createBulkRouteRequests(provider, time, removeLoops);
765 } else {
766 for (RoutablesMap::const_iterator i = myRoutables.begin(); i != myRoutables.end(); ++i) {
767 if (i->first >= time) {
768 break;
769 }
770 for (RORoutable* const routable : i->second) {
771#ifdef HAVE_FOX
772 // add task
773 if (maxNumThreads > 0) {
774 const int numThreads = (int)myThreadPool.size();
775 if (numThreads == 0) {
776 // This is the very first routing. Since at least the CHRouter needs initialization
777 // before it gets cloned, we do not do this in parallel
778 routable->computeRoute(provider, removeLoops, myErrorHandler);
779 new WorkerThread(myThreadPool, provider);
780 } else {
781 // add thread if necessary
782 if (numThreads < maxNumThreads && myThreadPool.isFull()) {
783 new WorkerThread(myThreadPool, provider);
784 }
785 myThreadPool.add(new RoutingTask(routable, removeLoops, myErrorHandler));
786 }
787 continue;
788 }
789#endif
790 routable->computeRoute(provider, removeLoops, myErrorHandler);
791 }
792 }
793 }
794#ifdef HAVE_FOX
795 myThreadPool.waitAll();
796#endif
797 }
798 const double scale = options.exists("scale-suffix") ? options.getFloat("scale") : 1;
799 // write all vehicles (and additional structures)
800 while (myRoutables.size() != 0 || myContainers.size() != 0) {
801 // get the next vehicle, person or container
802 RoutablesMap::iterator routables = myRoutables.begin();
803 const SUMOTime routableTime = routables == myRoutables.end() ? SUMOTime_MAX : routables->first;
804 ContainerMap::iterator container = myContainers.begin();
805 const SUMOTime containerTime = container == myContainers.end() ? SUMOTime_MAX : container->first;
806 // check whether it shall not yet be computed
807 if (routableTime >= time && containerTime >= time) {
808 lastTime = MIN2(routableTime, containerTime);
809 break;
810 }
811 const SUMOTime minTime = MIN2(routableTime, containerTime);
812 if (routableTime == minTime) {
813 // check whether to print the output
814 if (lastTime != routableTime && lastTime != -1) {
815 // report writing progress
816 if (options.getInt("stats-period") >= 0 && ((int)routableTime % options.getInt("stats-period")) == 0) {
817 WRITE_MESSAGE("Read: " + toString(myVehIDs.size()) + ", Discarded: " + toString(myDiscardedRouteNo) + ", Written: " + toString(myWrittenRouteNo));
818 }
819 }
820 lastTime = routableTime;
821 for (const RORoutable* const r : routables->second) {
822 // ok, check whether it has been routed
823 if (r->getRoutingSuccess()) {
824 // write the route
825 int quota = getScalingQuota(scale, myWrittenRouteNo);
826 r->write(myRoutesOutput, myRouteAlternativesOutput, myTypesOutput, options, quota);
828 } else {
830 }
831 // we need to keep individual public transport vehicles but not the flows
832 if (!r->isPublicTransport() || r->isPartOfFlow()) {
833 // delete routes and the vehicle
834 const ROVehicle* const veh = dynamic_cast<const ROVehicle*>(r);
835 if (veh != nullptr && veh->getRouteDefinition()->getID()[0] == '!') {
836 if (r->isPartOfFlow() || !myRoutes.remove(veh->getRouteDefinition()->getID())) {
837 delete veh->getRouteDefinition();
838 }
839 }
840 delete r;
841 }
842 }
843 myRoutables.erase(routables);
844 }
845 if (containerTime == minTime) {
846 myRoutesOutput->writePreformattedTag(container->second);
847 if (myRouteAlternativesOutput != nullptr) {
849 }
850 myContainers.erase(container);
851 }
852 }
853 return lastTime;
854}
855
856
857bool
859 return myRoutables.size() > 0 || (myFlows.size() > 0 && myHaveActiveFlows) || myContainers.size() > 0;
860}
861
862
863int
865 return myEdges.size();
866}
867
868
869int
873
874
875ROEdge*
876RONet::getEdgeForLaneID(const std::string& laneID) const {
878}
879
880
881ROLane*
882RONet::getLane(const std::string& laneID) const {
883 int laneIndex = SUMOXMLDefinitions::getIndexFromLane(laneID);
884 return getEdgeForLaneID(laneID)->getLanes()[laneIndex];
885}
886
887
888void
890 double taxiWait = STEPS2TIME(string2time(OptionsCont::getOptions().getString("persontrip.taxi.waiting-time")));
891 for (const auto& stopType : myInstance->myStoppingPlaces) {
892 // add access to all stopping places
893 const SumoXMLTag element = stopType.first;
894 for (const auto& stop : stopType.second) {
895 router.getNetwork()->addAccess(stop.first, myInstance->getEdgeForLaneID(stop.second->lane),
896 stop.second->startPos, stop.second->endPos, 0., element, false, taxiWait);
897 // add access to all public transport stops
898 if (element == SUMO_TAG_BUS_STOP) {
899 for (const auto& a : stop.second->accessPos) {
900 router.getNetwork()->addAccess(stop.first, myInstance->getEdgeForLaneID(std::get<0>(a)),
901 std::get<1>(a), std::get<1>(a), std::get<2>(a), SUMO_TAG_BUS_STOP, true, taxiWait);
902 }
903 }
904 }
905 }
906 // fill the public transport router with pre-parsed public transport lines
907 for (const auto& i : myInstance->myFlows) {
908 if (i.second->line != "") {
909 const RORouteDef* const route = myInstance->getRouteDef(i.second->routeid);
910 const StopParVector* addStops = nullptr;
911 if (route != nullptr && route->getFirstRoute() != nullptr) {
912 addStops = &route->getFirstRoute()->getStops();
913 }
914 router.getNetwork()->addSchedule(*i.second, addStops);
915 }
916 }
917 for (const RORoutable* const veh : myInstance->myPTVehicles) {
918 // add single vehicles with line attribute which are not part of a flow
919 // no need to add route stops here, they have been added to the vehicle before
920 router.getNetwork()->addSchedule(veh->getParameter());
921 }
922 // add access to transfer from walking to taxi-use
924 for (const ROEdge* edge : ROEdge::getAllEdges()) {
925 if (!edge->isTazConnector() && (edge->getPermissions() & SVC_PEDESTRIAN) != 0 && (edge->getPermissions() & SVC_TAXI) != 0) {
926 router.getNetwork()->addCarAccess(edge, SVC_TAXI, taxiWait);
927 }
928 }
929 }
930}
931
932
933bool
935 return myHavePermissions;
936}
937
938
939void
943
944bool
946 for (const auto& item : myEdges) {
947 if (item.second->hasStoredEffort()) {
948 return true;
949 }
950 }
951 return false;
952}
953
954const std::string
955RONet::getStoppingPlaceName(const std::string& id) const {
956 for (const auto& mapItem : myStoppingPlaces) {
957 SUMOVehicleParameter::Stop* stop = mapItem.second.get(id);
958 if (stop != nullptr) {
959 // see RONetHandler::parseStoppingPlace
960 return stop->busstop;
961 }
962 }
963 return "";
964}
965
966const std::string
967RONet::getStoppingPlaceElement(const std::string& id) const {
968 for (const auto& mapItem : myStoppingPlaces) {
969 SUMOVehicleParameter::Stop* stop = mapItem.second.get(id);
970 if (stop != nullptr) {
971 // see RONetHandler::parseStoppingPlace
972 return stop->actType;
973 }
974 }
976}
977
978
979void
980RONet::addProhibition(const ROEdge* edge, const RouterProhibition& prohibition) {
981 if (myProhibitions.count(edge) != 0) {
982 throw ProcessError(TLF("Already loaded prohibition for edge '%'. (Only one prohibition per edge is supported)", edge->getID()));
983 }
984 myProhibitions[edge] = prohibition;
985}
986
987
988#ifdef HAVE_FOX
989// ---------------------------------------------------------------------------
990// RONet::RoutingTask-methods
991// ---------------------------------------------------------------------------
992void
993RONet::RoutingTask::run(MFXWorkerThread* context) {
994 myRoutable->computeRoute(*static_cast<WorkerThread*>(context), myRemoveLoops, myErrorHandler);
995}
996#endif
997
998
999/****************************************************************************/
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:553
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:375
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:690
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition RONet.cpp:411
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:612
bool myDefaultPedTypeMayBeDeleted
Whether the default pedestrian type was already used or can still be replaced.
Definition RONet.h:544
void setPermissionsFound()
Definition RONet.cpp:940
bool myDefaultRailTypeMayBeDeleted
Whether the default rail type was already used or can still be replaced.
Definition RONet.h:553
std::map< std::string, std::map< SUMOVehicleClass, double > > mySpeedRestrictions
The vehicle class specific speed restrictions.
Definition RONet.h:602
bool myDefaultVTypeMayBeDeleted
Whether the default vehicle type was already used or can still be replaced.
Definition RONet.h:541
void checkFlows(SUMOTime time, MsgHandler *errorHandler)
Definition RONet.cpp:587
std::map< SUMOVehicleClass, std::map< std::string, double > > myVClassPreferences
Preferences for routing.
Definition RONet.h:608
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:200
const RandomDistributor< SUMOVTypeParameter * > * getVTypeDistribution(const std::string &id)
Retrieves the named vehicle type distribution.
Definition RONet.h:301
double getPreference(const std::string &routingType, const SUMOVTypeParameter &pars) const
retriefe edge type specific routing preference
Definition RONet.cpp:155
ContainerMap myContainers
Definition RONet.h:569
std::set< std::string > myPersonIDs
Known person ids.
Definition RONet.h:521
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:578
bool addRouteDef(RORouteDef *def)
Definition RONet.cpp:336
void addStoppingPlace(const std::string &id, const SumoXMLTag category, SUMOVehicleParameter::Stop *stop)
Definition RONet.cpp:327
bool knowsVehicle(const std::string &id) const
returns whether a vehicle with the given id was already loaded
Definition RONet.cpp:535
void cleanup()
closes the file output for computed routes and deletes associated threads if necessary
Definition RONet.cpp:387
bool myHaveActiveFlows
whether any flows are still active
Definition RONet.h:565
std::map< std::string, SUMOTime > myVehIDs
Known vehicle ids and their departure.
Definition RONet.h:518
void openOutput(const OptionsCont &options)
Opens the output for computed routes.
Definition RONet.cpp:342
NamedObjectCont< SUMOVehicleParameter * > myFlows
Known flows.
Definition RONet.h:562
OutputDevice * myRouteAlternativesOutput
The file to write the computed route alternatives into.
Definition RONet.h:584
bool myDefaultBikeTypeMayBeDeleted
Whether the default bicycle type was already used or can still be replaced.
Definition RONet.h:547
RoutablesMap myRoutables
Known routables.
Definition RONet.h:559
int getInternalEdgeNumber() const
Returns the number of internal edges the network contains.
Definition RONet.cpp:870
virtual bool addVehicle(const std::string &id, ROVehicle *veh)
Definition RONet.cpp:513
SUMOTime getDeparture(const std::string &vehID) const
returns departure time for the given vehicle id
Definition RONet.cpp:540
bool myHasBidiEdges
whether the network contains bidirectional railway edges
Definition RONet.h:627
bool addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource)
Definition RONet.cpp:247
void addSpeedRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition RONet.cpp:149
MsgHandler * myErrorHandler
handler for ignorable error messages
Definition RONet.h:615
void writeIntermodal(const OptionsCont &options, ROIntermodalRouter &router) const
Writes the intermodal network and weights if requested.
Definition RONet.cpp:368
RONet()
Constructor.
Definition RONet.cpp:64
NamedObjectCont< RONode * > myNodes
Known nodes.
Definition RONet.h:524
const std::string getStoppingPlaceElement(const std::string &id) const
return the element name for the given stopping place id
Definition RONet.cpp:967
void addContainer(const SUMOTime depart, const std::string desc)
Definition RONet.cpp:581
void addProhibition(const ROEdge *edge, const RouterProhibition &prohibition)
Definition RONet.cpp:980
static void adaptIntermodalRouter(ROIntermodalRouter &router)
Definition RONet.cpp:889
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition RONet.h:178
NamedObjectCont< RORouteDef * > myRoutes
Known routes.
Definition RONet.h:556
bool furtherStored()
Returns the information whether further vehicles, persons or containers are stored.
Definition RONet.cpp:858
bool checkVType(const std::string &id)
Checks whether the vehicle type (distribution) may be added.
Definition RONet.cpp:443
OutputDevice * myRoutesOutput
The file to write the computed routes into.
Definition RONet.h:581
bool addPerson(ROPerson *person)
Definition RONet.cpp:569
int myWrittenRouteNo
The number of written routes.
Definition RONet.h:596
static RONet * myInstance
Unique instance of RONet.
Definition RONet.h:515
RORouteDef * getRouteDef(const std::string &name) const
Returns the named route definition.
Definition RONet.h:339
SUMOTime saveAndRemoveRoutesUntil(OptionsCont &options, const RORouterProvider &provider, SUMOTime time)
Computes routes described by their definitions and saves them.
Definition RONet.cpp:745
virtual bool addEdge(ROEdge *edge)
Definition RONet.cpp:210
bool myDefaultTaxiTypeMayBeDeleted
Whether the default taxi type was already used or can still be replaced.
Definition RONet.h:550
std::map< SumoXMLTag, NamedObjectCont< SUMOVehicleParameter::Stop * > > myStoppingPlaces
Known bus / train / container stops and parking areas.
Definition RONet.h:530
virtual bool addVehicleType(SUMOVTypeParameter *type)
Adds a read vehicle type definition to the network.
Definition RONet.cpp:489
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition RONet.h:599
bool hasPermissions() const
Definition RONet.cpp:934
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:305
ROLane * getLane(const std::string &laneID) const
Retrieves a lane rom the network given its id.
Definition RONet.cpp:882
int myDiscardedRouteNo
The number of discarded routes.
Definition RONet.h:593
VTypeDistDictType myVTypeDistDict
A distribution of vehicle types (probability->vehicle type)
Definition RONet.h:538
std::vector< const RORoutable * > myPTVehicles
vehicles to keep for public transport routing
Definition RONet.h:572
NamedObjectCont< ROEdge * > myEdges
Known edges.
Definition RONet.h:527
void addNode(RONode *node)
Definition RONet.cpp:318
bool addVTypeDistribution(const std::string &id, RandomDistributor< SUMOVTypeParameter * > *vehTypeDistribution)
Adds a vehicle type distribution.
Definition RONet.cpp:502
void addJunctionTaz(ROAbstractEdgeBuilder &eb)
add a taz for every junction unless a taz with the same id already exists
Definition RONet.cpp:269
OutputDevice * myTypesOutput
The file to write the vehicle types into.
Definition RONet.h:587
const bool myKeepFlows
whether to preserve flows
Definition RONet.h:624
const bool myDoPTRouting
whether to calculate routes for public transport
Definition RONet.h:621
Prohibitions myProhibitions
temporary edge closing (rerouters)
Definition RONet.h:633
const bool myKeepVTypeDist
whether to keep the vtype distribution in output
Definition RONet.h:618
virtual ~RONet()
Destructor.
Definition RONet.cpp:118
const std::string getStoppingPlaceName(const std::string &id) const
return the name for the given stopping place id
Definition RONet.cpp:955
std::map< std::string, std::vector< SUMOTime > > myDepartures
Departure times for randomized flows.
Definition RONet.h:575
int getEdgeNumber() const
Returns the total number of edges the network contains including internal edges.
Definition RONet.cpp:864
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
Definition RONet.cpp:876
std::map< std::string, std::map< std::string, double > > myVTypePreferences
Definition RONet.h:609
bool addFlow(SUMOVehicleParameter *flow, const bool randomize)
Definition RONet.cpp:551
bool hasLoadedEffort() const
whether efforts were loaded from file
Definition RONet.cpp:945
void addPreference(const std::string &routingType, SUMOVehicleClass svc, double prio)
add edge type specific routing preference
Definition RONet.cpp:185
NamedObjectCont< SUMOVTypeParameter * > myVehicleTypes
Known vehicle types.
Definition RONet.h:533
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Definition RONet.cpp:224
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:124
bool isPublicTransport() const
Definition RORoutable.h:144
bool isPartOfFlow() const
Definition RORoutable.h:148
SUMOTime getDepart() const
Returns the time the vehicle starts at, -1 for triggered vehicles.
Definition RORoutable.h:115
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:136
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.
long long 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
Prohibitions and their estimated end time.