Dynamical system model
Loading...
Searching...
No Matches
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 (Size agentId) 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)
 
void setForcePriorities (bool forcePriorities)
 Set the force priorities flag.
 
void setDataUpdatePeriod (Delay dataUpdatePeriod)
 Set the data update period.
 
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 a set of agents to the simulation.
 
void addAgentsRandomly (Size nAgents, const TContainer &src_weights, const TContainer &dst_weights, const size_t minNodeDistance=0)
 Add a set of agents to the simulation.
 
void addAgentsRandomly (Size nAgents, const size_t minNodeDistance=0)
 
void addAgent (std::unique_ptr< Agent > agent)
 Add an agent to the simulation.
 
void addAgent (TArgs &&... args)
 
void addAgents (Size nAgents, TArgs &&... args)
 
void removeAgent (Size agentId)
 Remove an agent from the simulation.
 
void removeAgents (T1 id, Tn... ids)
 
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)
 Optimize the traffic lights by changing the green and red times.
 
const std::unordered_map< Id, std::unique_ptr< Itinerary > > & itineraries () const
 Get the itineraries.
 
const std::map< Id, std::unique_ptr< Agent > > & agents () const
 Get the agents.
 
Size 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
 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, double > m_streetTails
 
std::vector< std::pair< double, double > > m_travelDTs
 
std::vector< Id > m_agentsToRemove
 
Time m_previousOptimizationTime
 
Time m_previousSpireTime
 
- Protected Attributes inherited from dsm::Dynamics< RoadNetwork >
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 ( Size agentId)
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: