172 throw ProcessError(
"A network was not yet constructed.");
207 throw ProcessError(
"A network was already constructed.");
244 std::vector<SUMOTime> stateDumpTimes,
245 std::vector<std::string> stateDumpFiles,
265 WRITE_WARNING(
"Opposite direction driving does not work together with the sublane model.");
305 delete router.second;
307 myIntermodalRouter.clear();
323 const std::map<SUMOVehicleClass, double>*
325 std::map<std::string, std::map<SUMOVehicleClass, double> >::const_iterator i =
myRestrictions.find(
id);
351 std::cout <<
SIMTIME <<
" MSNet::simulate(" << start <<
", " << stop <<
")" 383 std::ostringstream msg;
385 msg <<
"Performance: " <<
"\n" <<
" Duration: " << duration <<
"ms" <<
"\n";
387 msg <<
" Real time factor: " << (
STEPS2TIME(
myStep - start) * 1000. / (double)duration) <<
"\n";
388 msg.setf(std::ios::fixed, std::ios::floatfield);
389 msg.setf(std::ios::showpoint);
390 msg <<
" UPS: " << ((double)
myVehiclesMoved / ((
double)duration / 1000)) <<
"\n";
395 msg <<
"Vehicles: " <<
"\n" 402 std::vector<std::string> reasons;
421 msg <<
"Persons: " <<
"\n" 459 std::cout <<
SIMTIME <<
": MSNet::simulationStep() called" 460 <<
", myStep = " <<
myStep 470 bool loadRequested = !TraCI::getLoadArgs().empty();
498 MSRoutingEngine::waitForAll();
547 MSRoutingEngine::waitForAll();
600 if (stopTime >= 0 &&
myStep >= stopTime) {
619 return "The final simulation step has been reached.";
621 return "All vehicles have left the simulation.";
623 return "TraCI requested termination.";
625 return "An error occurred (see log).";
627 return "Interrupted.";
629 return "Too many teleports.";
631 return "TraCI issued load command.";
633 return "Unknown reason.";
670 if (oc.
isSet(
"netstate-dump")) {
672 oc.
getInt(
"netstate-dump.precision"));
683 oc.
getInt(
"emission-output.precision"));
689 oc.
getInt(
"battery-output.precision"));
712 timestep = timestep.substr(0, timestep.length() - 3);
714 std::string filename = output +
"_" + timestep +
".vtp";
743 od.
writeAttr(
"meanWaitingTime", meanWaitingTime);
744 od.
writeAttr(
"meanTravelTime", meanTravelTime);
746 od.
writeAttr(
"meanSpeed", meanSpeed.first);
747 od.
writeAttr(
"meanSpeedRelative", meanSpeed.second);
763 for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
764 const std::vector<MSLane*>& lanes = (*i)->getLanes();
765 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
766 const std::vector<MSLink*>& links = (*j)->getLinkCont();
767 for (std::vector<MSLink*>::const_iterator k = links.begin(); k != links.end(); ++k) {
768 (*k)->writeApproaching(od, (*j)->getID());
837 std::ostringstream oss;
838 oss.setf(std::ios::fixed, std::ios::floatfield);
839 oss.setf(std::ios::showpoint);
844 << (
TS / durationSec) <<
"*RT, ~" 847 oss <<
" (0ms ?*RT. ?";
858 std::cout << oss.str().substr(0, 90 - prev.length());
887 (*i)->vehicleStateChanged(vehicle, to, info);
913 return stop->
getID();
957 if (routingAlgorithm ==
"dijkstra") {
961 if (routingAlgorithm !=
"astar") {
962 WRITE_WARNING(
"TraCI and Triggers cannot use routing algorithm '" + routingAlgorithm +
"'. using 'astar' instead.");
999 if (opt ==
"parkingAreas") {
1001 }
else if (opt ==
"ptStops") {
1003 }
else if (opt ==
"allJunctions") {
1023 const MSEdge*
const edge = &i.second->getLane().getEdge();
1029 const MSEdge*
const edge = &i.second->getLane().getEdge();
1032 for (
const auto& a : i.second->getAllAccessPos()) {
1035 if (external !=
nullptr) {
1047 for (MSEdgeVector::const_iterator e = edges.begin(); e != edges.end(); ++e) {
1048 for (std::vector<MSLane*>::const_iterator i = (*e)->getLanes().begin(); i != (*e)->getLanes().end(); ++i) {
1049 if ((*i)->getShape().hasElevation()) {
1072 if (e->getBidiEdge() !=
nullptr) {
std::string myStateDumpSuffix
static void write(OutputDevice &of, const MSEdgeControl &ec, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
static double gLateralResolution
bool hasNonWaiting() const
checks whether any transportable is still engaged in walking / stopping
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
SumoXMLTag
Numbers representing SUMO-XML - element names.
void writeBlocks(OutputDevice &od) const
write rail signal block output for all links and driveways
bool myHasPedestrianNetwork
Whether the network contains pedestrian network elements.
int getEndedVehicleNo() const
Returns the number of removed vehicles.
Representation of a vehicle in the micro simulation.
public transport stops and access
double getBeginLanePosition() const
Returns the begin position of this stop.
Interface for objects listening to vehicle state changes.
TRACI_CONST int ROUTING_MODE_COMBINED
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
void loadNext(SUMOTime step)
loads the next routes up to and including the given time step
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
bool checkBidiEdges()
check wether bidirectional edges occur in the network
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
EffortCalculator * getExternalEffort() const
int getArrivedVehicleNo() const
Returns the number of arrived vehicles.
MSPedestrianRouter * myPedestrianRouter
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
int getLoadedVehicleNo() const
Returns the number of build vehicles.
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
static void cleanup()
Clean up remaining devices instances.
A lane area vehicles can halt at.
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
void patchActiveLanes()
Resets information whether a lane is active for all lanes.
int getLoadedNumber() const
Returns the number of build transportables.
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
int gPrecision
the precision for floating point outputs
void updateDetectors(const SUMOTime step)
Computes detector values.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
virtual void execute(SUMOTime time)
Executes time-dependant commands.
_IntermodalEdge * getStopEdge(const std::string &stopId) const
Returns the associated stop edge.
SimulationState simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouterEffort
bool logSimulationDuration() const
Returns whether duration shall be logged.
MSIntermodalRouter & getIntermodalRouter(const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
std::string time2string(SUMOTime t)
std::map< SumoXMLTag, NamedObjectCont< MSStoppingPlace * > > myStoppingPlaces
Dictionary of bus / container stops.
int getNumericalID() const
Computes the shortest path through a network using the A* algorithm.
void writeRailSignalBlocks() const
write rail signal block output
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
bool retrieveExistingEffort(const MSEdge *const e, const double t, double &value) const
Returns an effort for an edge and time if stored.
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
The final simulation step has been performed.
SUMOTime myEdgeDataEndTime
end of loaded edgeData
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
double myVersion
the network version
std::vector< std::string > myStateDumpFiles
The names for the state files.
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
int getActiveVehicleCount() const
Returns the number of build vehicles that have not been removed or need to wait for a passenger or a ...
Storage for geometrical objects.
static const std::string STAGE_LANECHANGE
void cleanup()
clean up subscriptions
static void write(OutputDevice &of, SUMOTime timestep)
Dumping a hugh List of Parameters available in the Simulation.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
bool myHasBidiEdges
Whether the network contains bidirectional rail edges.
std::vector< std::string > & getLoadArgs()
A map of named object pointers.
Detectors container; responsible for string and output generation.
bool myLefthand
Whether the network was built for left-hand traffic.
A storage for edge travel times and efforts.
void detectCollisions(SUMOTime timestep, const std::string &stage)
Detect collisions.
std::map< int, MSIntermodalRouter * > myIntermodalRouter
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
SimulationState
Possible states of a simulation - running or stopped with different reasons.
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
#define WRITE_WARNING(msg)
The simulated network and simulation perfomer.
static void setArgs(int argc, char **argv)
Stores the command line arguments for later parsing.
static OptionsCont & getOptions()
Retrieves the options.
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Container for junctions; performs operations on all stored junctions.
std::unique_ptr< MSDynamicShapeUpdater > myDynamicShapeUpdater
Updater for dynamic shapes that are tracking traffic objects (ensures removal of shape dynamics when ...
static bool gCheck4Accidents
static void write(OutputDevice &of, SUMOTime timestep)
Export the queueing length in front of a junction (very experimental!)
void setJunctionApproaches(SUMOTime t)
Register junction approaches for all vehicles after velocities have been planned. This is a prerequis...
virtual MSTransportableControl & getContainerControl()
Returns the container control.
static void write(OutputDevice &of, SUMOTime timestep, bool elevation)
Writes the position and the angle of each vehicle into the given device.
virtual std::pair< double, double > getVehicleMeanSpeeds() const
get current absolute and relative mean vehicle speed in the network
void writeChargingStationOutput() const
write charging station output
A class that stores and controls tls and switching of their programs.
static void cleanup()
Closes root tags of output files.
A road/street connecting two junctions.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
long long int myVehiclesMoved
The overall number of vehicle movements.
double getEndLanePosition() const
Returns the end position of this stop.
The simulation does not contain further vehicles.
the effort calculator interface
A scoped lock which only triggers on condition.
static void generateOutputForUnfinished()
generate output for vehicles which are still in the network
static void cleanupStatic()
Place for static initializations of simulation components (called after successful net build) ...
An error occurred during the simulation step.
double getTotalDepartureDelay() const
Returns the total departure delay.
static void clear()
Clears the dictionary (delete all known routes, too)
bool myAmInterrupted
whether an interrupt occured
The main mesocopic simulation loop.
void writeOutput()
Write netstate, summary and detector output.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void adaptIntermodalRouter(MSNet::MSIntermodalRouter &router) const
SimulationState simulationState(SUMOTime stopTime) const
Called after a simulation step, this method returns the current simulation state. ...
static std::string printStatistics()
get statistics for printing to stdout
MSInsertionControl * myInserter
Controls vehicle insertion;.
Representation of a vehicle.
static const std::set< MSDevice_SSM *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing SSM devices
void checkInsertions(SUMOTime time)
Checks "movement" of stored vehicles.
Computes the shortest path through a network using the Dijkstra algorithm.
int emitVehicles(SUMOTime time)
Emits vehicles that want to depart at the given time.
SUMORouteLoaderControl * myRouteLoaders
Route loader for dynamic loading of routes.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
ShapeContainer & getShapeContainer()
Returns the shapes container.
void closeSimulation(SUMOTime start)
Closes the simulation (all files, connections, etc.)
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
int getTeleportsYield() const
return the number of teleports due to vehicles stuck on a minor road
An output device that encapsulates an ofstream.
static void clear()
Clears the dictionary.
void abortAnyWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
SUMOTime getTargetTime() const
MSDetectorControl * myDetectorControl
Controls detectors;.
static void init()
Static initalization.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
void postSimStepOutput() const
Prints the statistics of the step at its end.
double getMinimumTravelTime(const SUMOVehicle *const veh) const
returns the minimum travel time for the given vehicle
Stores edges and lanes, performs moving of vehicle.
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.
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
static void write(OutputDevice &of, SUMOTime timestep)
Produce a VTK output to use with Tools like ParaView.
virtual void addStop(const int stopEdge, const Parameterised ¶ms)=0
The connection to a client was closed by the client.
The simulation is running.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
int getEmergencyStops() const
return the number of emergency stops
SUMOTime string2time(const std::string &r)
std::map< std::string, bool > myWarnedOnce
container to record warnings that shall only be issued once
void check2Switch(SUMOTime step)
Checks whether any WAUT is trying to switch a tls into another program.
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
static void postProcessRemoteControl()
bool hasInternalLinks() const
return whether the network contains internal links
bool hasTransportables() const
checks whether any transportable waits to finish her plan
void changeLanes(const SUMOTime t)
Moves (precomputes) critical vehicles.
void updateAndWriteOutput()
This is called once per time step in MSNet::writeOutput() and collects the surrounding vehicles...
int getTeleportsJam() const
return the number of teleports due to jamming
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
static void cleanupAll()
perform cleanup for all devices
static void cleanup()
properly deletes all trigger instances
double getTotalTravelTime() const
Returns the total travel time.
TraCI server used to control sumo by a remote TraCI client.
MSPedestrianRouter & getPedestrianRouter(const MSEdgeVector &prohibited=MSEdgeVector()) const
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
bool lefthand() const
return whether the network was built for lefthand traffic
SUMOTime myStateDumpPeriod
The period for writing state.
int getTeleportsWrongLane() const
return the number of teleports due to vehicles stuck on the wrong lane
Inserts vehicles into the network when their departure time is reached.
long myTraCIStepDuration
The last simulation step duration.
int myMaxTeleports
Maximum number of teleports.
junctions with edges allowing the additional mode
void abortWaiting()
informes about all waiting vehicles (deletion in destructor)
PedestrianRouter< MSEdge, MSLane, MSJunction, MSVehicle > MSPedestrianRouter
VehicleState
Definition of a vehicle state.
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 hasNeighs, bool lefthand, double version)
Closes the network's building process.
static MSVehicleTransfer * getInstance()
Returns the instance of this object.
static const std::string STAGE_MOVEMENTS
void processCommandsUntilSimStep(SUMOTime step)
process all commands until the next SUMO simulation step. It is guaranteed that t->getTargetTime() >=...
std::vector< VehicleStateListener * > myVehicleStateListeners
Container for vehicle state listener.
static MSNet * myInstance
Unique instance of MSNet.
static void clearAll()
Clears all dictionaries.
static void cleanup()
Static cleanup.
The simulation is loading.
void planMovements(SUMOTime t)
Compute safe velocities for all vehicles based on positions and speeds from the last time step...
void executeMovements(SUMOTime t)
Executes planned vehicle movements with regards to right-of-way.
A train stop (alias for bus stop)
bool retrieveExistingTravelTime(const MSEdge *const e, const double t, double &value) const
Returns a travel time for an edge and time if stored.
void close(SUMOTime step)
Closes the detector outputs.
MSTransportableControl * myContainerControl
Controls container building and deletion;.
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
bool checkWalkingarea()
check all lanes for type walkingArea
MSInsertionControl & getInsertionControl()
Returns the insertion control.
static void clear()
Clears the dictionary.
static void write(OutputDevice &of, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
MSTransportableControl * myPersonControl
Controls person building and deletion;.
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool checkElevation()
check all lanes for elevation data
An external interrupt occured.
int getPendingFlowCount() const
Returns the number of flows that are still active.
void removePending()
Removes a vehicle after it has ended.
static void cleanup()
remove state at simulation end
void preSimStepOutput() const
Prints the current step number.
static TraCIServer * getInstance()
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
A storage for options typed value containers)
static void cleanup()
removes remaining vehicleInformation in sVehicles
static void initStatic()
Place for static initializations of simulation components (called after successful net build) ...
MSEdgeWeightsStorage * myEdgeWeights
The net's knowledge about edge efforts/travel times;.
The simulation had too many teleports.
void prohibit(const std::vector< E *> &toProhibit)
MSNet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents, ShapeContainer *shapeCont=0)
Constructor.
void checkWaiting(MSNet *net, const SUMOTime time)
checks whether any transportables waiting time is over
static void write(OutputDevice &of, const SUMOTime timestep)
Writes the complete network state into the given device.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
static void cleanup()
cleanup remaining data structures
const MSEdgeVector & getEdges() const
Returns loaded edges.
const MSEdgeWeightsStorage & getWeightsStorage() const
Returns the vehicle's internal edge travel times/efforts container.
long mySimBeginMillis
The overall simulation duration.
virtual ~MSNet()
Destructor.
bool myHasElevation
Whether the network contains elevation data.
static void write(OutputDevice &of, SUMOTime timestep, int precision)
Writes the complete network state of the given edges into the given device.
std::string myStateDumpPrefix
name components for periodic state
Static storage of an output device and its base (abstract) implementation.
static void closeAll(bool keepErrorRetrievers=false)
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
static const std::set< MSDevice_ToC *, ComparatorNumericalIdLess > & getInstances()
returns all currently existing ToC devices
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSIntermodalRouter
SUMOTime myStep
Current time step.
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const MSEdgeVector &prohibited=MSEdgeVector()) const
The class responsible for building and deletion of vehicles.
std::vector< MSEdge * > MSEdgeVector
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
void simulationStep()
Performs a single simulation step.
static long getCurrentMillis()
Returns the current time in milliseconds.
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
const MSLane & getLane() const
Returns the lane this stop is located at.
void simulate(SUMOTime tMax)
Perform simulation up to the given time.
void loadRoutes()
loads routes for the next few steps
#define WRITE_MESSAGE(msg)
static const std::string STAGE_INSERTIONS
MSEventControl * myInsertionEvents
Controls insertion events;.
int getCollisionCount() const
return the number of collisions
Representation of a lane in the micro simulation.
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
static bool wasClosed()
check whether close was requested
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const MSEdgeVector &prohibited=MSEdgeVector()) const
int getTeleportCount() const
return the number of teleports (including collisions)
Stores time-dependant events and executes them at the proper time.
bool myHasInternalLinks
Whether the network contains internal links/lanes/edges.
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
void addAccess(const std::string &stopId, const E *stopEdge, const double pos, const double length, const SumoXMLTag category)
Adds access edges for stopping places to the intermodal network.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOAbstractRouter< MSEdge, SUMOVehicle > * myRouterTT
static void adaptIntermodalRouter(MSIntermodalRouter &router)
static void cleanup()
remove state at simulation end
void determineCandidates(SUMOTime time)
Checks for all vehicles whether they can be emitted.
Network * getNetwork() const
static void saveState(const std::string &file, SUMOTime step)
Saves the current state.
const std::string generateStatistics(SUMOTime start)
Writes performance output and running vehicle stats.
bool generatesOutput()
Whether this device requested to write output.
The ToC Device controls transition of control between automated and manual driving.
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net's internal edge travel times/efforts container.
void writeOutput()
Write output to file given by option device.toc.file.
static const std::string STAGE_EVENTS
string constants for simstep stages
int getJammedNumber() const
Returns the number of times a transportables was jammed.