83 double value,
double begTime,
double endTime)
const {
85 if (edge !=
nullptr) {
86 myNet.getWeightsStorage().addEffort(edge, begTime, endTime,
value);
88 WRITE_ERRORF(
TL(
"Trying to set the effort for the unknown edge '%'."),
id);
98 double value,
double begTime,
double endTime)
const {
100 if (edge !=
nullptr) {
101 myNet.getWeightsStorage().addTravelTime(edge, begTime, endTime,
value);
103 WRITE_ERRORF(
TL(
"Trying to set the travel time for the unknown edge '%'."),
id);
128 if (!
load(
"net-file",
true)) {
132 throw ProcessError(
TL(
"Invalid network, no network version declared."));
136 WRITE_WARNING(
TL(
"Network contains internal links which are ignored. Vehicles will 'jump' across junctions and thus underestimate route lengths and travel times."));
143 if (
myOptions.isSet(
"alternative-net-file")) {
144 for (std::string fname :
myOptions.getStringVector(
"alternative-net-file")) {
159 bool stateBeginMismatch =
false;
164 bool defaultBegin =
myOptions.isDefault(
"begin");
166 if (
myOptions.isDefault(
"load-state.offset")) {
168 WRITE_WARNINGF(
TL(
"State was written at a different time=% than the begin time % (set option load-state.offset to force a different begin)!"),
174 stateBeginMismatch =
true;
180 SUMOTime allowReloadOffset =
myOptions.isDefault(
"load-state.remove-vehicles") ? 0 : 1;
181 myNet.setLoaderTime(stateTime - allowReloadOffset);
192 for (
auto it = junctions.
begin(); it != junctions.
end(); it++) {
193 const std::string sinkID = it->first +
"-sink";
194 const std::string sourceID = it->first +
"-source";
204 source->
initialize(
new std::vector<MSLane*>());
207 if (!edge->isInternal()) {
208 const_cast<MSEdge*
>(edge)->addSuccessor(sink);
212 if (!edge->isInternal()) {
217 WRITE_WARNINGF(
TL(
"A TAZ with id '%' already exists. Not building junction TAZ."), it->first)
222 bool haveSeenMesoEdgeType =
false;
224 if (
myOptions.isSet(
"additional-files")) {
228 myNet.getEdgeControl().buildMesoSegments();
231 if (
myOptions.isSet(
"additional-files")) {
232 if (!
load(
"additional-files")) {
240 if (
myXMLHandler.haveSeenAdditionalSpeedRestrictions()) {
241 myNet.getEdgeControl().setAdditionalRestrictions();
246 if (haveSeenMesoEdgeType ||
myXMLHandler.haveSeenTLSParams()) {
248 tll->initMesoTLSPenalties();
260 if (stateBeginMismatch &&
myNet.getVehicleControl().getLoadedVehicleNo() > 0) {
261 throw ProcessError(
TL(
"Loading vehicles ahead of a state file is not supported. Correct --begin option or load vehicles with option --route-files"));
266 if (!
myOptions.isUsableFileList(
"weight-files")) {
270 std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
276 std::string measure =
myOptions.getString(
"weight-attribute");
277 if (!
myOptions.isDefault(
"weight-attribute")) {
278 if (measure ==
"CO" || measure ==
"CO2" || measure ==
"HC" || measure ==
"PMx" || measure ==
"NOx" || measure ==
"fuel" || measure ==
"electricity") {
279 measure +=
"_perVeh";
286 std::vector<std::string> files =
myOptions.getStringVector(
"weight-files");
287 for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i) {
298 const std::string& f =
myOptions.getString(
"load-state");
313 if (!
load(
"route-files")) {
318 for (std::string file :
myOptions.getStringVector(
"route-files")) {
325 myNet.getTLSControl().switchOffAll();
343 std::string validation = oc.
getString(
"xml-validation");
344 std::string routeValidation = oc.
getString(
"xml-validation.routes");
347 validation =
"never";
349 if (oc.
isDefault(
"xml-validation.routes")) {
350 routeValidation =
"never";
358 if (oc.
getInt(
"threads") > 1) {
383 NLHandler handler(
"", *net, db, tb, eb, jb);
385 NLBuilder builder(oc, *net, eb, jb, db, handler);
389 if (builder.
build()) {
417 std::vector<SUMOTime> stateDumpTimes;
418 std::vector<std::string> stateDumpFiles;
425 e->postLoadInitLaneChanger();
429 for (std::string timeStr :
myOptions.getStringVector(
"save-state.times")) {
432 if (
myOptions.isSet(
"save-state.files")) {
433 stateDumpFiles =
myOptions.getStringVector(
"save-state.files");
434 if (stateDumpFiles.size() != stateDumpTimes.size()) {
438 const std::string prefix =
myOptions.getString(
"save-state.prefix");
439 const std::string suffix =
myOptions.getString(
"save-state.suffix");
440 for (std::vector<SUMOTime>::iterator i = stateDumpTimes.begin(); i != stateDumpTimes.end(); ++i) {
442 std::replace(timeStamp.begin(), timeStamp.end(),
':',
'-');
443 stateDumpFiles.push_back(prefix +
"_" + timeStamp + suffix);
456 myNet.closeBuilding(
myOptions, edges, junctions, routeLoaders, tlc, stateDumpTimes, stateDumpFiles,
465 if (!
myOptions.isUsableFileList(mmlWhat)) {
468 std::vector<std::string> files =
myOptions.getStringVector(mmlWhat);
469 for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
483 if (!
myOptions.isUsableFileList(mmlWhat)) {
487 for (
const std::string& file :
myOptions.getStringVector(mmlWhat)) {
503 for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
505 throw ProcessError(
TLF(
"The route file '%' is not accessible.", *fileIt));
509 for (std::vector<std::string>::const_iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
521 WRITE_WARNING(
TL(
"LaneData requested for mesoscopic simulation but --meso-lane-queue is not active. Falling back to edgeData."));
526 myDetectorBuilder.createEdgeLaneMeanData(
id, -1, begin, -1,
"traffic", useLanes,
"true",
527 false,
false, 0, 100000, 0,
SUMO_const_haltingSpeed,
"",
"", std::vector<MSEdge*>(),
AggregateType::NO,
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGEF(...)
#define WRITE_ERRORF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
#define PROGRESS_BEGIN_TIME_MESSAGE(msg)
#define PROGRESS_TIME_MESSAGE(before)
const std::string invalid_return< std::string >::value
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
std::pair< int, double > MMVersion
(M)ajor/(M)inor version for written networks and default version for loading
const double SUMO_const_haltingSpeed
the speed threshold at which vehicles are considered as halting
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()
Stores edges and lanes, performs moving of vehicle.
const MSEdgeVector & getEdges() const
Returns loaded edges.
A road/street connecting two junctions.
void setOtherTazConnector(const MSEdge *edge)
static void clear()
Clears the dictionary.
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...
void initialize(const std::vector< MSLane * > *lanes)
Initialize the edge.
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....
Stores time-dependant events and executes them at the proper time.
static void buildStreams()
Builds the streams used possibly by the simulation.
static void setMSGlobals(OptionsCont &oc)
Sets the global microsim-options.
static void fillOptions()
Inserts options used by the simulation into the OptionsCont-singleton.
static bool checkOptions()
Checks the set options.
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Container for junctions; performs operations on all stored junctions.
void postloadInitContainer()
Closes building of junctions.
The base class for an intersection.
const ConstMSEdgeVector & getOutgoing() const
const ConstMSEdgeVector & getIncoming() const
static void clear()
Clears the dictionary.
static void initRNGs(const OptionsCont &oc)
initialize rngs
The simulated network and simulation perfomer.
void loadRoutes()
loads routes for the next few steps
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.
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.
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.
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.
void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds an effort for a given edge and time period.
Obtains edge efforts from a weights handler and stores them within the edges.
MSNet & myNet
The network edges shall be obtained from.
void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds a travel time for a given edge and time period.
static MSNet * init(const bool isLibsumo=false)
MSNet & myNet
The net to fill.
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.
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.
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.
OptionsCont & myOptions
The options to get the names of the files to load and further information from.
static void initRandomness()
initializes all RNGs
NLHandler & myXMLHandler
The handler used to parse the net.
Builds detectors for microsim.
Interface for building edges.
The XML-Handler for network loading.
Builder of microsim-junctions and tls.
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.
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).
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.
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.
static int getArgC()
Return the number of command line arguments.
static void getOptions(const bool commandLineOnly=false)
Parses the command line arguments and loads the configuration.
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()
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.
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()