Loading [MathJax]/extensions/tex2jax.js
Dynamical system model
All Classes Namespaces Files Functions Pages
dsm::FirstOrderDynamics Class Reference
Inheritance diagram for dsm::FirstOrderDynamics:
dsm::RoadDynamics< Delay > dsm::Dynamics< RoadNetwork >

Public Member Functions

 FirstOrderDynamics (RoadNetwork &graph, bool useCache=false, std::optional< unsigned int > seed=std::nullopt, double alpha=0., std::function< double(const RoadNetwork *, Id, Id)> weightFunction=weight_functions::streetTime, double weightTreshold=60.)
 Construct a new First Order Dynamics object.
 
void setAgentSpeed (std::unique_ptr< Agent > const &pAgent) override
 Set the speed of an agent.
 
void setSpeedFluctuationSTD (double speedFluctuationSTD)
 Set the standard deviation of the speed fluctuation.
 
double streetMeanSpeed (Id streetId) const override
 Get the mean speed of a street in \(m/s\).
 
Measurement< double > streetMeanSpeed () const override
 Get the mean speed of the streets in \(m/s\).
 
Measurement< double > streetMeanSpeed (double threshold, bool above) const override
 Get the mean speed of the streets with density above or below a threshold in \(m/s\).
 
- Public Member Functions inherited from dsm::RoadDynamics< Delay >
 RoadDynamics (RoadNetwork &graph, bool useCache=false, std::optional< unsigned int > seed=std::nullopt, std::function< double(const RoadNetwork *, Id, Id)> weightFunction=weight_functions::streetTime, double weightTreshold=60.)
 Construct a new RoadDynamics object.
 
void setErrorProbability (double errorProbability)
 Set the error probability.
 
void setPassageProbability (double passageProbability)
 Set the passage probability.
 
void setTransitionMatrix (const SparseMatrix< double > &transitionMatrix)
 Set the transition matrix.
 
void setForcePriorities (bool forcePriorities) noexcept
 Set the force priorities flag.
 
void setDataUpdatePeriod (Delay dataUpdatePeriod) noexcept
 Set the data update period.
 
void setMaxDistance (double const maxDistance)
 Set the maximum distance which a random agent can travel.
 
void setMaxTravelTime (Time const maxTravelTime) noexcept
 Set the maximum travel time which a random agent can travel.
 
void setDestinationNodes (std::initializer_list< Id > destinationNodes, bool updatePaths=true)
 Set the destination nodes.
 
void setDestinationNodes (TContainer const &destinationNodes, bool updatePaths=true)
 Set the destination nodes.
 
void updatePaths ()
 Update the paths of the itineraries based on the given weight function.
 
void addAgentsUniformly (Size nAgents, std::optional< Id > itineraryId=std::nullopt)
 Add agents uniformly on the road network.
 
void addAgentsRandomly (Size nAgents, const TContainer &src_weights, const TContainer &dst_weights, const std::variant< std::monostate, size_t, double > minNodeDistance=std::monostate{})
 Add a set of agents to the simulation.
 
void addAgentsRandomly (Size nAgents, const std::variant< std::monostate, size_t, double > minNodeDistance=std::monostate{})
 
void addAgent (std::unique_ptr< Agent > agent)
 Add an agent to the simulation.
 
void addAgent (TArgs &&... args)
 
void addAgents (Size nAgents, TArgs &&... args)
 
void addItinerary (TArgs &&... args)
 Add an itinerary.
 
void addItinerary (std::unique_ptr< Itinerary > itinerary)
 Add an itinerary.
 
void evolve (bool reinsert_agents=false)
 Evolve the simulation.
 
void optimizeTrafficLights (double const threshold=0., TrafficLightOptimization optimizationType=TrafficLightOptimization::DOUBLE_TAIL, const std::string &logFile=std::string())
 Optimize the traffic lights by changing the green and red times.
 
const std::unordered_map< Id, std::unique_ptr< Itinerary > > & itineraries () const noexcept
 Get the itineraries.
 
const SparseMatrix< double > & transitionMatrix () const noexcept
 Get the transition matrix.
 
const std::vector< std::unique_ptr< Agent > > & agents () const noexcept
 Get the agents.
 
size_t nAgents () const
 Get the number of agents currently in the simulation.
 
Measurement< double > meanTravelTime (bool clearData=false)
 Get the mean travel time of the agents in \(s\).
 
Measurement< double > meanTravelDistance (bool clearData=false)
 Get the mean travel distance of the agents in \(m\).
 
Measurement< double > meanTravelSpeed (bool clearData=false)
 Get the mean travel speed of the agents in \(m/s\).
 
const std::unordered_map< Id, std::array< unsigned long long, 4 > > & turnCounts () const noexcept
 Get the turn counts of the agents.
 
std::unordered_map< Id, std::array< double, 4 > > turnProbabilities (bool reset=true)
 Get the turn probabilities of the agents.
 
std::unordered_map< Id, std::array< long, 4 > > turnMapping () const
 
Measurement< double > agentMeanSpeed () const
 Get the mean speed of the agents in \(m/s\).
 
Measurement< double > streetMeanDensity (bool normalized=false) const
 Get the mean density of the streets in \(m^{-1}\).
 
Measurement< double > streetMeanFlow () const
 Get the mean flow of the streets in \(s^{-1}\).
 
Measurement< double > streetMeanFlow (double threshold, bool above) const
 Get the mean flow of the streets in \(s^{-1}\).
 
Measurement< double > meanSpireInputFlow (bool resetValue=true)
 Get the mean spire input flow of the streets in \(s^{-1}\).
 
Measurement< double > meanSpireOutputFlow (bool resetValue=true)
 Get the mean spire output flow of the streets in \(s^{-1}\).
 
void saveStreetDensities (const std::string &filename, bool normalized=true, char const separator=';') const
 Save the street densities in csv format.
 
void saveInputStreetCounts (const std::string &filename, bool reset=false, char const separator=';')
 Save the street input counts in csv format.
 
void saveOutputStreetCounts (const std::string &filename, bool reset=false, char const separator=';')
 Save the street output counts in csv format.
 
void saveTravelSpeeds (const std::string &filename, bool reset=false)
 Save the travel speeds of the agents in csv format.
 
void saveMacroscopicObservables (const std::string &filename, char const separator=';')
 Save the main macroscopic observables in csv format.
 
- Public Member Functions inherited from dsm::Dynamics< RoadNetwork >
 Dynamics (RoadNetwork &graph, std::optional< unsigned int > seed=std::nullopt)
 Construct a new Dynamics object.
 
void resetTime ()
 Reset the simulation time to 0.
 
const RoadNetworkgraph () const
 Get the graph.
 
Time time () const
 Get the current simulation time-step.
 

Additional Inherited Members

- Protected Member Functions inherited from dsm::Dynamics< RoadNetwork >
void m_evolve ()
 
- Protected Attributes inherited from dsm::RoadDynamics< Delay >
std::unordered_map< Id, std::array< unsigned long long, 4 > > m_turnCounts
 
std::unordered_map< Id, std::array< long, 4 > > m_turnMapping
 
std::unordered_map< Id, std::unordered_map< Direction, double > > m_queuesAtTrafficLights
 
tbb::concurrent_vector< std::pair< double, double > > m_travelDTs
 
Time m_previousOptimizationTime
 
Time m_previousSpireTime
 
- Protected Attributes inherited from dsm::Dynamics< RoadNetwork >
tbb::task_arena m_taskArena
 
Time m_time
 
std::mt19937_64 m_generator
 

Constructor & Destructor Documentation

◆ FirstOrderDynamics()

dsm::FirstOrderDynamics::FirstOrderDynamics ( RoadNetwork & graph,
bool useCache = false,
std::optional< unsigned int > seed = std::nullopt,
double alpha = 0.,
std::function< double(const RoadNetwork *, Id, Id)> weightFunction = weight_functions::streetTime,
double weightTreshold = 60. )
explicit

Construct a new First Order Dynamics object.

Parameters
graphThe graph representing the network
useCacheIf true, the cache is used (default is false)
seedThe seed for the random number generator (default is std::nullopt)
alphaThe minimum speed rate (default is 0)

Member Function Documentation

◆ setAgentSpeed()

void dsm::FirstOrderDynamics::setAgentSpeed ( std::unique_ptr< Agent > const & pAgent)
overridevirtual

Set the speed of an agent.

Parameters
agentIdThe id of the agent
Exceptions
std::invalid_argument,Ifthe agent is not found

Implements dsm::RoadDynamics< Delay >.

◆ setSpeedFluctuationSTD()

void dsm::FirstOrderDynamics::setSpeedFluctuationSTD ( double speedFluctuationSTD)

Set the standard deviation of the speed fluctuation.

Parameters
speedFluctuationSTDThe standard deviation of the speed fluctuation
Exceptions
std::invalid_argument,Ifthe standard deviation is negative

◆ streetMeanSpeed() [1/3]

Measurement< double > dsm::FirstOrderDynamics::streetMeanSpeed ( ) const
overridevirtual

Get the mean speed of the streets in \(m/s\).

Returns
Measurement The mean speed of the agents and the standard deviation

Reimplemented from dsm::RoadDynamics< Delay >.

◆ streetMeanSpeed() [2/3]

Measurement< double > dsm::FirstOrderDynamics::streetMeanSpeed ( double threshold,
bool above ) const
overridevirtual

Get the mean speed of the streets with density above or below a threshold in \(m/s\).

Parameters
thresholdThe density threshold to consider
aboveIf true, the function returns the mean speed of the streets with a density above the threshold, otherwise below
Returns
Measurement The mean speed of the agents and the standard deviation

Reimplemented from dsm::RoadDynamics< Delay >.

◆ streetMeanSpeed() [3/3]

double dsm::FirstOrderDynamics::streetMeanSpeed ( Id streetId) const
overridevirtual

Get the mean speed of a street in \(m/s\).

Returns
double The mean speed of the street or street->maxSpeed() if the street is empty

The mean speed of a street is given by the formula: \( v_{\text{mean}} = v_{\text{max}} \left(1 - \frac{\alpha}{2} \left( n - 1\right) \right) \) where \( v_{\text{max}} \) is the maximum speed of the street, \( \alpha \) is the minimum speed rateo divided by the capacity and \( n \) is the number of agents in the street

Reimplemented from dsm::RoadDynamics< Delay >.


The documentation for this class was generated from the following file: