Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NLBuilder.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-2026 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 main interface for loading a microsim
21/****************************************************************************/
22#include <config.h>
23
24#include <iostream>
25#include <vector>
26#include <string>
27#include <map>
28
41#include <utils/xml/XMLSubSys.h>
42#ifdef HAVE_FOX
44#endif
45#include <libsumo/Helper.h>
50#include <microsim/MSNet.h>
57#include <microsim/MSGlobals.h>
59#include <microsim/MSFrame.h>
65
66#include "NLHandler.h"
67#include "NLNetShapeHandler.h"
70#include "NLDetectorBuilder.h"
71#include "NLTriggerBuilder.h"
72#include "NLBuilder.h"
73
74
75// ===========================================================================
76// method definitions
77// ===========================================================================
78// ---------------------------------------------------------------------------
79// NLBuilder::EdgeFloatTimeLineRetriever_EdgeWeight - methods
80// ---------------------------------------------------------------------------
81void
83 double value, double begTime, double endTime) const {
84 MSEdge* edge = MSEdge::dictionary(id);
85 if (edge != nullptr) {
86 myNet.getWeightsStorage().addEffort(edge, begTime, endTime, value);
87 } else {
88 WRITE_ERRORF(TL("Trying to set the effort for the unknown edge '%'."), id);
89 }
90}
91
92
93// ---------------------------------------------------------------------------
94// NLBuilder::EdgeFloatTimeLineRetriever_EdgeTravelTime - methods
95// ---------------------------------------------------------------------------
96void
98 double value, double begTime, double endTime) const {
99 MSEdge* edge = MSEdge::dictionary(id);
100 if (edge != nullptr) {
101 myNet.getWeightsStorage().addTravelTime(edge, begTime, endTime, value);
102 } else {
103 WRITE_ERRORF(TL("Trying to set the travel time for the unknown edge '%'."), id);
104 }
105}
106
107
108// ---------------------------------------------------------------------------
109// NLBuilder - methods
110// ---------------------------------------------------------------------------
112 MSNet& net,
116 NLHandler& xmlHandler)
119 myNet(net), myXMLHandler(xmlHandler) {}
120
121
123
124
125bool
127 // try to build the net
128 if (!load("net-file", true)) {
129 return false;
130 }
131 if (myXMLHandler.networkVersion() == MMVersion(0, 0)) {
132 throw ProcessError(TL("Invalid network, no network version declared."));
133 }
134 // check whether the loaded net agrees with the simulation options
136 WRITE_WARNING(TL("Network contains internal links which are ignored. Vehicles will 'jump' across junctions and thus underestimate route lengths and travel times."));
137 }
138 if (!myXMLHandler.haveSeenInternalEdge() && myOptions.getBool("mesosim")) {
139 // @todo: setting this option has some side effect in microsim that manifest even in networks without internal lanes this should be checked
141 }
142 buildNet();
143 if (myOptions.isSet("alternative-net-file")) {
144 for (std::string fname : myOptions.getStringVector("alternative-net-file")) {
145 const long before = PROGRESS_BEGIN_TIME_MESSAGE("Loading alternative net from '" + fname + "'");
146 NLNetShapeHandler nsh(fname, myNet);
147 if (!XMLSubSys::runParser(nsh, fname, true)) {
148 WRITE_MESSAGE("Loading of alternative net failed.");
149 return false;
150 }
151 nsh.sortInternalShapes();
152 PROGRESS_TIME_MESSAGE(before);
153 }
154 }
155 // @note on loading order constraints:
156 // - additional-files before route-files and state-files due to referencing
157 // - additional-files before weight-files since the latter might contain intermodal edge data and the intermodal net depends on the stops and public transport from the additionals
158
159 bool stateBeginMismatch = false;
160 if (myOptions.isSet("load-state")) {
161 // first, load only the time
163 if (myOptions.isDefault("begin")) {
164 myOptions.set("begin", time2string(stateTime));
165 if (TraCIServer::getInstance() != nullptr) {
167 }
168 } else {
169 if (stateTime != string2time(myOptions.getString("begin"))) {
170 WRITE_WARNINGF(TL("State was written at a different time=% than the begin time %!"), time2string(stateTime), myOptions.getString("begin"));
171 stateBeginMismatch = true;
172 }
173 }
175 }
176
177 if (myOptions.getBool("junction-taz")) {
178 // create a TAZ for every junction
179 const MSJunctionControl& junctions = myNet.getJunctionControl();
180 for (auto it = junctions.begin(); it != junctions.end(); it++) {
181 const std::string sinkID = it->first + "-sink";
182 const std::string sourceID = it->first + "-source";
183 if (MSEdge::dictionary(sinkID) == nullptr && MSEdge::dictionary(sourceID) == nullptr) {
184 // sink must be built and added before source
185 MSEdge* sink = myEdgeBuilder.buildEdge(sinkID, SumoXMLEdgeFunc::CONNECTOR, "", "", "", -1, 0);
186 MSEdge* source = myEdgeBuilder.buildEdge(sourceID, SumoXMLEdgeFunc::CONNECTOR, "", "", "", -1, 0);
187 sink->setOtherTazConnector(source);
188 source->setOtherTazConnector(sink);
189 MSEdge::dictionary(sinkID, sink);
190 MSEdge::dictionary(sourceID, source);
191 sink->initialize(new std::vector<MSLane*>());
192 source->initialize(new std::vector<MSLane*>());
193 const MSJunction* junction = it->second;
194 for (const MSEdge* edge : junction->getIncoming()) {
195 if (!edge->isInternal()) {
196 const_cast<MSEdge*>(edge)->addSuccessor(sink);
197 }
198 }
199 for (const MSEdge* edge : junction->getOutgoing()) {
200 if (!edge->isInternal()) {
201 source->addSuccessor(const_cast<MSEdge*>(edge));
202 }
203 }
204 } else {
205 WRITE_WARNINGF(TL("A TAZ with id '%' already exists. Not building junction TAZ."), it->first)
206 }
207 }
208 }
209 // load meso edge types
210 bool haveSeenMesoEdgeType = false;
212 if (myOptions.isSet("additional-files")) {
213 haveSeenMesoEdgeType = loadMesoEdgeTypes("additional-files");
214 }
215 // meso segment building must be delayed until meso edge types have been read from additional files
217 }
218 // load additional net elements (sources, detectors, ...)
219 if (myOptions.isSet("additional-files")) {
220 if (!load("additional-files")) {
221 return false;
222 }
223 // load shapes with separate handler
225 if (!ShapeHandler::loadFiles(myOptions.getStringVector("additional-files"), sh)) {
226 return false;
227 }
230 }
232 }
234 if (haveSeenMesoEdgeType || myXMLHandler.haveSeenTLSParams()) {
236 tll->initMesoTLSPenalties();
237 }
238 }
239 }
240 // init after preferences have been loaded from additional-files
242 // init tls after all detectors have been loaded
244 // declare meandata set by options
245 buildDefaultMeanData("edgedata-output", "DEFAULT_EDGEDATA", false);
246 buildDefaultMeanData("lanedata-output", "DEFAULT_LANEDATA", true);
247
248 if (stateBeginMismatch && myNet.getVehicleControl().getLoadedVehicleNo() > 0) {
249 throw ProcessError(TL("Loading vehicles ahead of a state file is not supported. Correct --begin option or load vehicles with option --route-files"));
250 }
251
252 // load weights if wished
253 if (myOptions.isSet("weight-files")) {
254 if (!myOptions.isUsableFileList("weight-files")) {
255 return false;
256 }
257 // build and prepare the weights handler
258 std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
259 // travel time, first (always used)
261 retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition("traveltime", true, ttRetriever));
262 // the measure to use, then
264 std::string measure = myOptions.getString("weight-attribute");
265 if (!myOptions.isDefault("weight-attribute")) {
266 if (measure == "CO" || measure == "CO2" || measure == "HC" || measure == "PMx" || measure == "NOx" || measure == "fuel" || measure == "electricity") {
267 measure += "_perVeh";
268 }
269 retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition(measure, true, eRetriever));
270 }
271 // set up handler
272 SAXWeightsHandler handler(retrieverDefs, "");
273 // start parsing; for each file in the list
274 std::vector<std::string> files = myOptions.getStringVector("weight-files");
275 for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
276 // report about loading when wished
277 WRITE_MESSAGEF(TL("Loading weights from '%'..."), *i);
278 // parse the file
279 if (!XMLSubSys::runParser(handler, *i)) {
280 return false;
281 }
282 }
283 }
284 // load the previous state if wished
285 if (myOptions.isSet("load-state")) {
286 const std::string& f = myOptions.getString("load-state");
287 long before = PROGRESS_BEGIN_TIME_MESSAGE(TLF("Loading state from '%'", f));
288 MSStateHandler h(f, string2time(myOptions.getString("load-state.offset")));
290 if (MsgHandler::getErrorInstance()->wasInformed()) {
291 return false;
292 }
293 PROGRESS_TIME_MESSAGE(before);
294 }
295 // routes from FCD files
297 // load routes
298 if (myOptions.isSet("route-files")) {
299 if (string2time(myOptions.getString("route-steps")) <= 0) {
300 // incremental loading is disabled. Load route files fully
301 if (!load("route-files")) {
302 return false;
303 }
304 } else {
305 // message must come after additional-files have been loaded (but buildRouteLoaderControl was called earlier)
306 for (std::string file : myOptions.getStringVector("route-files")) {
307 WRITE_MESSAGE(TLF("Loading route-files incrementally from '%'", file));
308 }
309 }
310 }
311 // optionally switch off traffic lights
312 if (myOptions.getBool("tls.all-off")) {
314 }
315 WRITE_MESSAGE(TL("Loading done."));
316 return true;
317}
318
319
320MSNet*
321NLBuilder::init(const bool isLibsumo) {
323 oc.clear();
328 return nullptr;
329 }
331 std::string validation = oc.getString("xml-validation");
332 std::string routeValidation = oc.getString("xml-validation.routes");
333 if (isLibsumo) {
334 if (oc.isDefault("xml-validation")) {
335 validation = "never";
336 }
337 if (oc.isDefault("xml-validation.routes")) {
338 routeValidation = "never";
339 }
340 }
341 XMLSubSys::setValidation(validation, oc.getString("xml-validation.net"), routeValidation);
342 if (!MSFrame::checkOptions()) {
343 throw ProcessError();
344 }
345#ifdef HAVE_FOX
346 if (oc.getInt("threads") > 1) {
347 // make the output aware of threading
349 }
350#endif
354 MSVehicleControl* vc = nullptr;
356 vc = new MEVehicleControl();
357 } else {
358 vc = new MSVehicleControl();
359 }
360 MSNet* net = new MSNet(vc, new MSEventControl(), new MSEventControl(), new MSEventControl());
361 // need to init TraCI-Server before loading routes to catch VehicleState::BUILT
362 TraCIServer::openSocket(std::map<int, TraCIServer::CmdExecutor>());
363 if (isLibsumo) {
365 }
366
368 NLDetectorBuilder db(*net);
369 NLJunctionControlBuilder jb(*net, db);
371 NLHandler handler("", *net, db, tb, eb, jb);
372 tb.setHandler(&handler);
373 NLBuilder builder(oc, *net, eb, jb, db, handler);
377 if (builder.build()) {
378 // preload the routes especially for TraCI
379 net->loadRoutes();
380 return net;
381 }
382 delete net;
383 throw ProcessError();
384}
385
386
387void
397
398
399void
401 MSEdgeControl* edges = nullptr;
402 MSJunctionControl* junctions = nullptr;
403 SUMORouteLoaderControl* routeLoaders = nullptr;
404 MSTLLogicControl* tlc = nullptr;
405 std::vector<SUMOTime> stateDumpTimes;
406 std::vector<std::string> stateDumpFiles;
407 try {
408 MSFrame::buildStreams(); // ensure streams are ready for output during building
410 junctions = myJunctionBuilder.build();
411 junctions->postloadInitContainer();
412 for (MSEdge* e : edges->getEdges()) {
413 e->postLoadInitLaneChanger();
414 }
415 routeLoaders = buildRouteLoaderControl(myOptions);
417 for (std::string timeStr : myOptions.getStringVector("save-state.times")) {
418 stateDumpTimes.push_back(string2time(timeStr));
419 }
420 if (myOptions.isSet("save-state.files")) {
421 stateDumpFiles = myOptions.getStringVector("save-state.files");
422 if (stateDumpFiles.size() != stateDumpTimes.size()) {
423 throw ProcessError(TL("Wrong number of state file names!"));
424 }
425 } else {
426 const std::string prefix = myOptions.getString("save-state.prefix");
427 const std::string suffix = myOptions.getString("save-state.suffix");
428 for (std::vector<SUMOTime>::iterator i = stateDumpTimes.begin(); i != stateDumpTimes.end(); ++i) {
429 std::string timeStamp = time2string(*i);
430 std::replace(timeStamp.begin(), timeStamp.end(), ':', '-');
431 stateDumpFiles.push_back(prefix + "_" + timeStamp + suffix);
432 }
433 }
434 } catch (ProcessError&) {
437 delete edges;
438 delete junctions;
439 delete routeLoaders;
440 delete tlc;
441 throw;
442 }
443 // if anthing goes wrong after this point, the net is responsible for cleaning up
444 myNet.closeBuilding(myOptions, edges, junctions, routeLoaders, tlc, stateDumpTimes, stateDumpFiles,
448}
449
450
451bool
452NLBuilder::load(const std::string& mmlWhat, const bool isNet) {
453 if (!myOptions.isUsableFileList(mmlWhat)) {
454 return false;
455 }
456 std::vector<std::string> files = myOptions.getStringVector(mmlWhat);
457 for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
458 const long before = PROGRESS_BEGIN_TIME_MESSAGE(TLF("Loading % from '%'", mmlWhat, *fileIt));
459 if (!XMLSubSys::runParser(myXMLHandler, *fileIt, isNet)) {
460 WRITE_MESSAGEF(TL("Loading of % failed."), mmlWhat);
461 return false;
462 }
463 PROGRESS_TIME_MESSAGE(before);
464 }
465 return true;
466}
467
468
469bool
470NLBuilder::loadMesoEdgeTypes(const std::string& mmlWhat) {
471 if (!myOptions.isUsableFileList(mmlWhat)) {
472 return false;
473 }
474 METypeHandler meTypeHandler("", myNet);
475 for (const std::string& file : myOptions.getStringVector(mmlWhat)) {
476 if (!XMLSubSys::runParser(meTypeHandler, file)) {
477 continue;
478 }
479 }
480 return meTypeHandler.haveSeenMesoEdgeType();
481}
482
483
486 // build the loaders
487 SUMORouteLoaderControl* loaders = new SUMORouteLoaderControl(string2time(oc.getString("route-steps")));
488 // check whether a list is existing
489 if (oc.isSet("route-files") && string2time(oc.getString("route-steps")) > 0) {
490 std::vector<std::string> files = oc.getStringVector("route-files");
491 for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
492 if (!FileHelpers::isReadable(*fileIt)) {
493 throw ProcessError(TLF("The route file '%' is not accessible.", *fileIt));
494 }
495 }
496 // open files for reading
497 for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
498 loaders->add(new SUMORouteLoader(new MSRouteHandler(*fileIt, false)));
499 }
500 }
501 return loaders;
502}
503
504
505void
506NLBuilder::buildDefaultMeanData(const std::string& optionName, const std::string& id, bool useLanes) {
507 if (OptionsCont::getOptions().isSet(optionName)) {
508 if (useLanes && MSGlobals::gUseMesoSim && !OptionsCont::getOptions().getBool("meso-lane-queue")) {
509 WRITE_WARNING(TL("LaneData requested for mesoscopic simulation but --meso-lane-queue is not active. Falling back to edgeData."));
510 useLanes = false;
511 }
512 try {
513 SUMOTime begin = string2time(OptionsCont::getOptions().getString("begin"));
514 myDetectorBuilder.createEdgeLaneMeanData(id, -1, begin, -1, "traffic", useLanes, "true",
515 false, false, 0, 100000, 0, SUMO_const_haltingSpeed, "", "", std::vector<MSEdge*>(), AggregateType::NO,
516 OptionsCont::getOptions().getString(optionName));
517 } catch (InvalidArgument& e) {
518 WRITE_ERROR(e.what());
519 } catch (IOError& e) {
520 WRITE_ERROR(e.what());
521 }
522 }
523}
524
525/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_MESSAGEF(...)
Definition MsgHandler.h:289
#define WRITE_ERRORF(...)
Definition MsgHandler.h:296
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:288
#define WRITE_ERROR(msg)
Definition MsgHandler.h:295
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
Definition MsgHandler.h:292
#define TL(string)
Definition MsgHandler.h:304
#define PROGRESS_TIME_MESSAGE(before)
Definition MsgHandler.h:293
#define TLF(string,...)
Definition MsgHandler.h:306
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition SUMOTime.cpp:46
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:91
std::pair< int, double > MMVersion
(M)ajor/(M)inor version for written networks and default version for loading
Definition StdDefs.h:71
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
Definition StdDefs.h:62
static bool isReadable(std::string path)
Checks whether the given file is readable.
The XML-Handler for meso edge type loading.
bool haveSeenMesoEdgeType() const
The class responsible for building and deletion of vehicles (gui-version)
static SumoRNG * getRecognitionRNG()
static void init()
Static intialization.
static SumoRNG * getResponseTimeRNG()
static SumoRNG * getEquipmentRNG()
Definition MSDevice.h:92
Stores edges and lanes, performs moving of vehicle.
void setAdditionalRestrictions()
apply additional restrictions
void buildMesoSegments()
build meso segments after meso edge types are loaded
const MSEdgeVector & getEdges() const
Returns loaded edges.
A road/street connecting two junctions.
Definition MSEdge.h:77
void setOtherTazConnector(const MSEdge *edge)
Definition MSEdge.h:296
static void clear()
Clears the dictionary.
Definition MSEdge.cpp:1124
void addSuccessor(MSEdge *edge, const MSEdge *via=nullptr)
Adds an edge to the list of edges which may be reached from this edge and to the incoming of the othe...
Definition MSEdge.cpp:1275
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
Definition MSEdge.cpp:105
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition MSEdge.cpp:1079
void addTravelTime(const MSEdge *const e, double begin, double end, double value)
Adds a travel time information for an edge and a time span.
void addEffort(const MSEdge *const e, double begin, double end, double value)
Adds an effort information for an edge and a time span.
Stores time-dependant events and executes them at the proper time.
static void buildStreams()
Builds the streams used possibly by the simulation.
Definition MSFrame.cpp:871
static void setMSGlobals(OptionsCont &oc)
Sets the global microsim-options.
Definition MSFrame.cpp:1149
static void fillOptions()
Inserts options used by the simulation into the OptionsCont-singleton.
Definition MSFrame.cpp:62
static bool checkOptions()
Checks the set options.
Definition MSFrame.cpp:918
static bool gUseMesoSim
Definition MSGlobals.h:106
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition MSGlobals.h:81
Container for junctions; performs operations on all stored junctions.
void postloadInitContainer()
Closes building of junctions.
The base class for an intersection.
Definition MSJunction.h:58
const ConstMSEdgeVector & getOutgoing() const
Definition MSJunction.h:114
const ConstMSEdgeVector & getIncoming() const
Definition MSJunction.h:108
static void clear()
Clears the dictionary.
Definition MSLane.cpp:2533
static void initRNGs(const OptionsCont &oc)
initialize rngs
Definition MSLane.cpp:4674
The simulated network and simulation perfomer.
Definition MSNet.h:89
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition MSNet.h:465
void closeBuilding(const OptionsCont &oc, MSEdgeControl *edges, MSJunctionControl *junctions, SUMORouteLoaderControl *routeLoaders, MSTLLogicControl *tlc, std::vector< SUMOTime > stateDumpTimes, std::vector< std::string > stateDumpFiles, bool hasInternalLinks, bool junctionHigherSpeeds, const MMVersion &version)
Closes the network's building process.
Definition MSNet.cpp:271
MSJunctionControl & getJunctionControl()
Returns the junctions control.
Definition MSNet.h:475
void setCurrentTimeStep(const SUMOTime step)
Sets the current simulation step (used by state loading)
Definition MSNet.h:342
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net's internal edge travel times/efforts container.
Definition MSNet.cpp:1297
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition MSNet.h:515
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition MSNet.h:392
void loadRoutes()
loads routes for the next few steps
Definition MSNet.cpp:498
MSEdgeControl & getEdgeControl()
Returns the edge control.
Definition MSNet.h:435
Parser and container for routes during their loading.
static SumoRNG * getParsingRNG()
get parsing RNG
static void initWeightConstants(const OptionsCont &oc)
initialize constants for using myPriorityFactor
static SUMOTime getTime(const std::string &fileName)
parse time from state file
Parser and output filter for routes and vehicles state saving and loading.
A class that stores and controls tls and switching of their programs.
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
void switchOffAll()
switch all logic variants to 'off'
The parent class for traffic light logics.
static void checkParkingRerouteConsistency()
issues warning for incomplete parkingReroute relationships
The class responsible for building and deletion of vehicles.
int getLoadedVehicleNo() const
Returns the number of build vehicles.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static void initOutputOptions()
init output options
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
static void setFactory(Factory func)
Sets the factory function to use for new MsgHandlers.
Definition MsgHandler.h:64
virtual void clear(bool resetInformed=true)
Clears information whether an error occurred previously and print aggregated message summary.
static MsgHandler * getMessageInstance()
Returns the instance to add normal messages to.
static MsgHandler * create(MsgType type)
MSNet & myNet
The network edges shall be obtained from.
Definition NLBuilder.h:165
void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds an effort for a given edge and time period.
Definition NLBuilder.cpp:82
Obtains edge efforts from a weights handler and stores them within the edges.
Definition NLBuilder.h:175
void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds a travel time for a given edge and time period.
Definition NLBuilder.cpp:97
The main interface for loading a microsim.
Definition NLBuilder.h:58
static MSNet * init(const bool isLibsumo=false)
MSNet & myNet
The net to fill.
Definition NLBuilder.h:215
bool load(const std::string &mmlWhat, const bool isNet=false)
Loads a described subpart form the given list of files.
NLDetectorBuilder & myDetectorBuilder
The detector control builder to use.
Definition NLBuilder.h:212
bool loadMesoEdgeTypes(const std::string &mmlWhat)
loads meso edge types with a dedicated handler and return whether any were loaded
virtual bool build()
Builds and initialises the simulation.
virtual ~NLBuilder()
Destructor.
void buildNet()
Closes the net building process.
NLBuilder(OptionsCont &oc, MSNet &net, NLEdgeControlBuilder &eb, NLJunctionControlBuilder &jb, NLDetectorBuilder &db, NLHandler &xmlHandler)
Constructor.
NLJunctionControlBuilder & myJunctionBuilder
The junction control builder to use.
Definition NLBuilder.h:209
static SUMORouteLoaderControl * buildRouteLoaderControl(const OptionsCont &oc)
Builds the route loader control.
void buildDefaultMeanData(const std::string &optionName, const std::string &id, bool useLanes)
build meanData definition based on option
NLEdgeControlBuilder & myEdgeBuilder
The edge control builder to use.
Definition NLBuilder.h:206
OptionsCont & myOptions
The options to get the names of the files to load and further information from.
Definition NLBuilder.h:203
static void initRandomness()
initializes all RNGs
NLHandler & myXMLHandler
The handler used to parse the net.
Definition NLBuilder.h:218
Builds detectors for microsim.
void createEdgeLaneMeanData(const std::string &id, SUMOTime frequency, SUMOTime begin, SUMOTime end, const std::string &type, const bool useLanes, const std::string &excludeEmpty, const bool withInternal, const bool trackVehicles, const int detectPersons, const double maxTravelTime, const double minSamples, const double haltSpeed, const std::string &vTypes, const std::string &writeAttributes, std::vector< MSEdge * > edges, AggregateType aggregate, const std::string &device)
Creates edge based mean data collector using the given specification.
Interface for building edges.
virtual MSEdge * buildEdge(const std::string &id, const SumoXMLEdgeFunc function, const std::string &streetName, const std::string &edgeType, const std::string &routingType, const int priority, const double distance)
Builds an edge instance (MSEdge in this case)
MSEdgeControl * build(const MMVersion &networkVersion)
builds the MSEdgeControl-class which holds all edges
The XML-Handler for network loading.
Definition NLHandler.h:79
bool haveSeenAdditionalSpeedRestrictions() const
Definition NLHandler.h:119
bool haveSeenInternalEdge() const
Definition NLHandler.h:103
bool hasJunctionHigherSpeeds() const
Definition NLHandler.h:107
bool haveSeenTLSParams() const
Definition NLHandler.h:123
MMVersion networkVersion() const
Definition NLHandler.h:127
bool haveSeenDefaultLength() const
Definition NLHandler.h:111
Builder of microsim-junctions and tls.
MSTLLogicControl * buildTLLogics()
Returns the built tls-logic control.
MSJunctionControl * build() const
Builds the MSJunctionControl which holds all of the simulations junctions.
void postLoadInitialization()
initialize junctions after all connections have been loaded
The XML-Handler for network loading.
void sortInternalShapes()
resolve mismatch between internal lane ids of both networks
The XML-Handler for shapes loading network loading.
Definition NLHandler.h:55
Builds trigger objects for microsim.
void setHandler(NLHandler *handler)
Sets the parent handler to use for nested parsing.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
static SumoRNG * getRNG()
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.
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 isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void clear()
Removes all information from the container.
bool set(const std::string &name, const std::string &value, const bool append=false)
Sets the given value for the named option.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
bool processMetaOptions(bool missingOptions)
Checks for help and configuration output, returns whether we should exit.
bool isUsableFileList(const std::string &name) const
Checks whether the named option is usable as a file list (with at least a single file)
static int getArgC()
Return the number of command line arguments.
Definition OptionsIO.h:63
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
Definition OptionsIO.cpp:74
static void initRandGlobal(SumoRNG *which=nullptr)
Reads the given random number options and initialises the random number generator in accordance.
Complete definition about what shall be retrieved and where to store it.
An XML-handler for network weights.
void add(SUMORouteLoader *loader)
add another loader
static bool loadFiles(const std::vector< std::string > &files, ShapeHandler &sh)
loads all of the given files
static void close()
Closes all of an applications subsystems.
static bool checkOptions(OptionsCont &oc)
checks shared options and sets StdDefs
void stateLoaded(SUMOTime targetTime)
updates myTargetTime and resets vehicle state changes after loading a simulation state
static TraCIServer * getInstance()
Definition TraCIServer.h:68
static void openSocket(const std::map< int, CmdExecutor > &execs)
Initialises the server.
static void setValidation(const std::string &validationScheme, const std::string &netValidationScheme, const std::string &routeValidationScheme)
Enables or disables validation.
Definition XMLSubSys.cpp:83
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.
static void registerStateListener()
Definition Helper.cpp:715