Dynamical System Framework
Loading...
Searching...
No Matches
dsf::mobility::TrafficSimulator Class Reference

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 updatePaths (std::time_t const deltaT=0, bool const throw_on_empty=true)
 Configure the path-update cadence forwarded to the dynamics engine.
void saveData (std::time_t const savingInterval, bool const saveAverageStats=false, bool const saveStreetData=false, bool const saveTravelData=false, bool const saveAgentData=false)
 Configure the data-saving behavior.
void setName (std::string_view const name)
 Set the name 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 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)
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).

Constructor & Destructor Documentation

◆ TrafficSimulator()

dsf::mobility::TrafficSimulator::TrafficSimulator ( std::string_view const jsonConfigFile)
explicit

Construct a new TrafficSimulator and import its configuration from JSON.

Parameters
jsonConfigFileThe path to the JSON configuration file.

Member Function Documentation

◆ connectDataBase()

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.

Parameters
dbPathThe path to the SQLite database file
queriesOptional 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;")

◆ database()

auto * dsf::mobility::TrafficSimulator::database ( ) const
inline

Get the database connection (const version).

Returns
const SQLite::Database const*, The database connection

◆ id()

auto dsf::mobility::TrafficSimulator::id ( ) const
inline

Get the id of the simulation.

Returns
Id, The id of the simulation

◆ importConfig()

void dsf::mobility::TrafficSimulator::importConfig ( std::string_view const jsonConfigFile)

Import a JSON configuration file and apply it to the simulator.

Parameters
jsonConfigFileThe path to the JSON configuration file.

◆ importRoadNetwork()

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.

Parameters
edgesFileThe edges CSV file.
nodePropertiesFileOptional node-properties CSV file.

◆ name()

auto const & dsf::mobility::TrafficSimulator::name ( ) const
inline

Get the name of the simulation.

Returns
const std::string&, The name of the simulation

◆ safeName()

auto const & dsf::mobility::TrafficSimulator::safeName ( ) const
inline

Get a safe name string for filenames (spaces replaced by underscores).

Returns
std::string, The safe name string

◆ setAgentInsertionMethod()

void dsf::mobility::TrafficSimulator::setAgentInsertionMethod ( AgentInsertionMethod const insertionMethod)
inlinenoexcept

Set the strategy used when inserting new agents.

Parameters
insertionMethodThe insertion method to use.

◆ setName()

void dsf::mobility::TrafficSimulator::setName ( std::string_view const name)

Set the name of the simulation.

Parameters
nameThe name of the simulation

◆ setOutputPrefix()

void dsf::mobility::TrafficSimulator::setOutputPrefix ( std::string_view const prefix)

Set the output prefix used for generated CSV files and database paths.

Parameters
prefixThe prefix or directory path.

◆ setTimeFrame()

void dsf::mobility::TrafficSimulator::setTimeFrame ( std::time_t const initTime,
std::optional< std::time_t > const endTime = std::nullopt )

Set the simulation time frame.

Parameters
initTimeThe simulation start time.
endTimeOptional simulation end time.

◆ updatePaths()

void dsf::mobility::TrafficSimulator::updatePaths ( std::time_t const deltaT = 0,
bool const throw_on_empty = true )

Configure the path-update cadence forwarded to the dynamics engine.

Parameters
deltaTThe update cadence in time steps.
throw_on_emptyWhether an empty itinerary path should throw.

The documentation for this class was generated from the following files:
  • src/dsf/mobility/TrafficSimulator.hpp
  • src/dsf/mobility/TrafficSimulator.cpp