|
Dynamical System Framework
|
Public Member Functions | |
| TrafficSimulator () | |
| Construct a new TrafficSimulator with a generated simulation id. | |
| TrafficSimulator (std::string_view const jsonConfigFile) | |
| Construct a new TrafficSimulator and import its configuration from JSON. | |
| void | importConfig (std::string_view const jsonConfigFile) |
| Import a JSON configuration file and apply it to the simulator. | |
| void | connectDataBase (std::string_view const dbPath, std::string_view const queries="PRAGMA busy_timeout = 5000;PRAGMA journal_mode = WAL;PRAGMA " "synchronous=NORMAL;PRAGMA temp_store=MEMORY;PRAGMA cache_size=-20000;") |
| Connect to a SQLite database, creating it if it doesn't exist, and executing optional initialization queries. | |
| void | importRoadNetwork (std::string_view const edgesFile, std::string_view const nodePropertiesFile=std::string_view()) |
| Import a road network and build the simulation dynamics. | |
| void | saveData (std::time_t const savingInterval, bool const saveAverageStats=false, bool const saveStreetData=false, bool const saveTravelData=false, bool const saveAgentData=false, bool const saveTurnCounts=false) |
| Configure the data-saving behavior. | |
| void | setName (std::string_view const name) |
| Set the name of the simulation. | |
| void | setId (Id const id) |
| Set the id of the simulation. | |
| void | setOutputPrefix (std::string_view const prefix) |
| Set the output prefix used for generated CSV files and database paths. | |
| void | setTimeFrame (std::time_t const initTime, std::optional< std::time_t > const endTime=std::nullopt) |
| Set the simulation time frame. | |
| void | setAgentInsertionMethod (AgentInsertionMethod const insertionMethod) noexcept |
| Set the strategy used when inserting new agents. | |
| void | scheduleStreetStatusById (std::time_t const time, std::vector< Id > streetIds, RoadStatus const status) |
| Schedule a change of the status of some streets during the runs. | |
| void | scheduleStreetStatusByName (std::time_t const time, std::string streetName, RoadStatus const status) |
| Schedule a change of the status of the streets whose name contains the given one (see RoadNetwork::setStreetStatusByName). | |
| void | run (std::vector< std::size_t > const &nAgentsPerTimeStep, std::optional< std::time_t > const deltaT=std::nullopt) |
| Run the simulation until the configured end time. | |
| void | run (std::size_t const nInitialAgents, std::time_t const agentInsertionDeltaT, std::time_t const checkDeltaT, std::size_t const agentIncrement=1) |
| Run a slow charge: agents are added at a growing rate until the end time, or until the network is saturated. | |
| auto * | database () const |
| Get the database connection (const version). | |
| auto const * | dynamics () const |
| Get the dynamics engine managed by this simulator. | |
| auto * | dynamics () |
| Get the mutable dynamics engine managed by this simulator. | |
| auto | id () const |
| Get the id of the simulation. | |
| auto | initTime () const |
| Get the simulation start time. | |
| auto | strInitTime () const |
| Get the formatted simulation start time. | |
| auto | endTime () const |
| Get the simulation end time. | |
| auto | strEndTime () const |
| Get the formatted simulation end time. | |
| auto const & | name () const |
| Get the name of the simulation. | |
| auto const & | safeName () const |
| Get a safe name string for filenames (spaces replaced by underscores). | |
|
explicit |
Construct a new TrafficSimulator and import its configuration from JSON.
| jsonConfigFile | The path to the JSON configuration file. |
| void dsf::mobility::TrafficSimulator::connectDataBase | ( | std::string_view const | dbPath, |
| std::string_view const | queries = "PRAGMA busy_timeout = 5000;PRAGMA journal_mode = WAL;PRAGMA " "synchronous=NORMAL;PRAGMA temp_store=MEMORY;PRAGMA cache_size=-20000;" ) |
Connect to a SQLite database, creating it if it doesn't exist, and executing optional initialization queries.
| dbPath | The path to the SQLite database file |
| queries | Optional SQL queries to execute upon connecting to the database (default is a set of pragmas for performance optimization : "PRAGMA busy_timeout = 5000;PRAGMA journal_mode = WAL;PRAGMA synchronous=NORMAL;PRAGMA temp_store=MEMORY;PRAGMA cache_size=-20000;") |
|
inline |
Get the database connection (const version).
|
inline |
Get the id of the simulation.
| void dsf::mobility::TrafficSimulator::importConfig | ( | std::string_view const | jsonConfigFile | ) |
Import a JSON configuration file and apply it to the simulator.
| jsonConfigFile | The path to the JSON configuration file. |
| void dsf::mobility::TrafficSimulator::importRoadNetwork | ( | std::string_view const | edgesFile, |
| std::string_view const | nodePropertiesFile = std::string_view() ) |
Import a road network and build the simulation dynamics.
| edgesFile | The edges CSV file. |
| nodePropertiesFile | Optional node-properties CSV file. |
|
inline |
Get the name of the simulation.
|
inline |
Run a slow charge: agents are added at a growing rate until the end time, or until the network is saturated.
| nInitialAgents | The number of agents added at each insertion, at first |
| agentInsertionDeltaT | The time steps between two insertions |
| checkDeltaT | The time steps between two checks: the number of agents added at each insertion grows by agentIncrement if the agents decreased since the last check |
| agentIncrement | The growth of the agents added at each insertion |
When the network has no room left for an insertion, the run stops there, logging an error, and its summary is logged as usual
|
inline |
Get a safe name string for filenames (spaces replaced by underscores).
| void dsf::mobility::TrafficSimulator::scheduleStreetStatusById | ( | std::time_t const | time, |
| std::vector< Id > | streetIds, | ||
| RoadStatus const | status ) |
Schedule a change of the status of some streets during the runs.
| time | The time step of the run, counted from its start, at which the change is made (before the agents of that step are added) |
| streetIds | The ids of the streets, checked when a run starts |
| status | The status to set |
Agents react to a closure as described in RoadNetwork::setStreetStatusById. Changes not made yet when a run ends are kept for the next run (with a warning), whose steps are counted from its own start
| void dsf::mobility::TrafficSimulator::scheduleStreetStatusByName | ( | std::time_t const | time, |
| std::string | streetName, | ||
| RoadStatus const | status ) |
Schedule a change of the status of the streets whose name contains the given one (see RoadNetwork::setStreetStatusByName).
| time | The time step of the run, counted from its start, at which the change is made (before the agents of that step are added) |
| streetName | The name to match |
| status | The status to set |
|
inlinenoexcept |
Set the strategy used when inserting new agents.
| insertionMethod | The insertion method to use. |
| void dsf::mobility::TrafficSimulator::setId | ( | Id const | id | ) |
Set the id of the simulation.
| id | The id of the simulation |
The default id is the creation time (YYYYMMDDHHMMSS)
| std::invalid_argument | if the id does not fit in a SQLite INTEGER (64-bit signed) |
| void dsf::mobility::TrafficSimulator::setName | ( | std::string_view const | name | ) |
Set the name of the simulation.
| name | The name of the simulation |
| void dsf::mobility::TrafficSimulator::setOutputPrefix | ( | std::string_view const | prefix | ) |
Set the output prefix used for generated CSV files and database paths.
| prefix | The prefix or directory path. |
| void dsf::mobility::TrafficSimulator::setTimeFrame | ( | std::time_t const | initTime, |
| std::optional< std::time_t > const | endTime = std::nullopt ) |
Set the simulation time frame.
| initTime | The simulation start time. |
| endTime | Optional simulation end time. |