Traffic Flow Dynamics Model
|
#include <Graph.hpp>
Public Member Functions | |
Graph (std::string) | |
import from file (only matrix) More... | |
void | setSeed (int const) |
set the seed of the random number generator More... | |
void | setTimeScale (int const) |
set the time scale More... | |
int | getTimeScale () const noexcept |
get the time scale More... | |
void | addVehicle (int) |
Adds a vehicle with a given type. More... | |
void | addRndmVehicles (int) |
add vehicles of random type in _vehicles More... | |
void | addVehiclesUniformly (int) |
add vehicles uniformly on the streets More... | |
void | setTemperature (double const) |
set the temperature of the network More... | |
double | getTemperature () const noexcept |
get the system temperature More... | |
void | updateTransMatrix () |
update the transition matrix More... | |
void | evolve (bool) |
evolve the network More... | |
void | evolve () |
evolve the network with reinsertion (default) More... | |
void | printMatrix () noexcept |
print adjency matrix on terminal More... | |
void | print (bool const) const noexcept |
print network info on terminal More... | |
void | printStreets () const noexcept |
print streets on terminal with nodes and number of vehicles More... | |
void | fprintMatrix (char const *) |
print adjency matrix on file | |
void | fprint (bool const) const noexcept |
print network info on file More... | |
void | fprintStreets (std::string const &) const noexcept |
print streets on file with nodes and number of vehicles More... | |
void | fprintVisual (std::string const &) const noexcept |
print file for visual.py More... | |
void | fprintHistogram (std::string const &, std::string const &, int const, std::string const &) const |
Print some network's data in a elegible format. More... | |
void | fprintDistribution (std::string const &, std::string const &) const |
print graphs whit format y \t x More... | |
void | fprintTimeDistribution (std::string const &, std::string const &, double const) const |
print graphs whit format y \t t More... | |
void | fprintActualState (std::string const &, std::string const &) const |
print actual state More... | |
Graph class.
This class is used to represent a graph. It contains the adjency matrix, the coordinates matrix, the streets, the vehicles, the number of vehicles on each street, the dimension, the temperature, the time, the mean time traveled and the number of vehicles to destination.
Graph::Graph | ( | std::string | fName | ) |
import from file (only matrix)
Generate the graph from the matrix.
fName | matrix file path |
void Graph::addRndmVehicles | ( | int | nVehicles | ) |
add vehicles of random type in _vehicles
Adds a fixed number of vehicles with random types Adds a fixed number of vehicles with random types starting at their origin.
nVehicles | number of vehiclesù |
std::invalid_argument | if nVehicles < 0 |
void Graph::addVehicle | ( | int | type | ) |
Adds a vehicle with a given type.
add a vehicle of a type in _vehicles street
type | vehicle type |
std::invalid_argument | if type is invalid |
void Graph::addVehiclesUniformly | ( | int | nVehicles | ) |
add vehicles uniformly on the streets
Adds a fixed number of vehicles with random types Adds a fixed number of vehicles with random types uniformply distributed on the graph.
nVehicles | number of vehicles |
std::invalid_argument | if nVehicles < 0 |
void Graph::evolve | ( | ) |
evolve the network with reinsertion (default)
Updates the state of the system reinserting vehicles Updates the state of the system by moving vehicles and reinserting them in the streets from their origin.
void Graph::evolve | ( | bool | reinsert | ) |
evolve the network
Updates the state of the system.
Updates the state of the system by moving vehicles. The evolution algorithm, for all vehicles:
reinsert | if true, vehicles are reinserted in the streets from their origin |
|
noexcept |
print network info on file
Print information of the network.
printGraph | if true, prints the graph. Print information of the network like number of nodes, number of streets and the graph. |
void Graph::fprintActualState | ( | std::string const & | outFolder, |
std::string const & | opt | ||
) | const |
print actual state
Print the means of some network's data in a format readable by LaTeX.
outFolder | folder where the data file will be saved. |
opt | is used to select wich data print. In particolar you can choose between the following options:
|
std::invalid_argument | if opt is not valid |
void Graph::fprintDistribution | ( | std::string const & | outFolder, |
std::string const & | opt | ||
) | const |
print graphs whit format y \t x
Print some network's data distributions in a format readable by LaTeX.
outFolder | folder where the data file will be saved. |
opt | is used to select wich data print. In particolar you can choose between the following options:
|
std::invalid_argument | if opt is not valid |
void Graph::fprintHistogram | ( | std::string const & | outFolder, |
std::string const & | opt, | ||
int const | nBins, | ||
std::string const & | format | ||
) | const |
Print some network's data in a elegible format.
outFolder | folder where the data file will be saved. |
opt | is used to select wich data print. In particolar you can choose between the following options:
|
nBins | is the number of bins used to create the histogram. |
format | is the format of the data. In particolar you can choose between the following options:
|
std::invalid_argument | if nBins < 1 or format/option is invalid. |
|
noexcept |
print streets on file with nodes and number of vehicles
Print information of every street on a file.
fName | name of the file where the information will be saved. Print information of every street like index, origin, destination, number of vehicles and input velocity. |
void Graph::fprintTimeDistribution | ( | std::string const & | outFolder, |
std::string const & | opt, | ||
double const | timeZero | ||
) | const |
print graphs whit format y \t t
Print some network's data in a format readable by LaTeX.
outFolder | folder where the data file will be saved. |
opt | is used to select wich data print. In particolar you can choose between the following options:
|
timeZero | is the time at which the simulation starts |
std::invalid_argument | if opt is not valid |
|
noexcept |
print file for visual.py
Print network's data in a format readable by the script visual.py.
outFolder | folder where the data file will be saved. |
|
noexcept |
get the system temperature
get the temperature of the network
|
noexcept |
get the time scale
Get the time scale of the simulation.
|
noexcept |
print network info on terminal
Print informations about the system.
|
noexcept |
print adjency matrix on terminal
Print the transition matrix.
|
noexcept |
print streets on terminal with nodes and number of vehicles
Print information of every street. Print information of every street like index, origin, destination, number of vehicles and input velocity.
void Graph::setSeed | ( | int const | seed | ) |
set the seed of the random number generator
Set the seed for the random number generator.
seed | seed for the random number generator |
void Graph::setTemperature | ( | double const | temperature | ) |
set the temperature of the network
set the system temperature
temperature |
std::invalid_argument | if temperature < 0 |
void Graph::setTimeScale | ( | int const | timeScale | ) |
set the time scale
Set the time scale for the simulation. Default value is 100.
timeScale | time scale |
std::invalid_argument | if timeScale < 1 |
void Graph::updateTransMatrix | ( | ) |
update the transition matrix
create all the transition matrices for all vehicle types
The transition matrix is updated according to the expected traveltime using Dijsktra's algorithm. It uses also temperature to simulate the effect of a noise.