Dynamical system model
Loading...
Searching...
No Matches
dsm::FirstOrderDynamics Class Reference
Inheritance diagram for dsm::FirstOrderDynamics:
dsm::RoadDynamics< Delay > dsm::Dynamics< Agent< Delay > >

Public Member Functions

 FirstOrderDynamics (Graph &graph, bool useCache=false, std::optional< unsigned int > seed=std::nullopt, double alpha=0.)
 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 (Graph &graph, bool useCache=false, std::optional< unsigned int > seed=std::nullopt)
 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 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 evolve (bool reinsert_agents=false) override
 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.
 
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
 
void saveTravelSpeeds (const std::string &filename, bool reset=false)
 Save the travel speeds of the agents in csv format.
 
- Public Member Functions inherited from dsm::Dynamics< Agent< Delay > >
 Dynamics (Graph &graph, bool useCache=false, std::optional< unsigned int > seed=std::nullopt)
 Construct a new Dynamics object.
 
virtual void updatePaths ()
 Update the paths of the itineraries based on the actual travel times.
 
void setDestinationNodes (const std::span< Id > &destinationNodes, bool updatePaths=true)
 Set the dynamics destination nodes auto-generating itineraries.
 
void addAgent (std::unique_ptr< Agent< Delay > > agent)
 Add an agent to the simulation.
 
void addAgent (TArgs &&... args)
 
void addAgents (Size nAgents, TArgs &&... args)
 
void addAgents (Tn... agents)
 Add a pack of agents to the simulation.
 
void addAgents (T1 agent, Tn... agents)
 Add a pack of agents to the simulation.
 
void addAgents (std::span< Agent< Delay > > agents)
 Add a set of agents to the simulation.
 
void removeAgent (Size agentId)
 Remove an agent from the simulation.
 
void removeAgents (T1 id, Tn... ids)
 
void addItinerary (const Itinerary &itinerary)
 Add an itinerary.
 
void addItinerary (std::unique_ptr< Itinerary > itinerary)
 Add an itinerary.
 
void addItineraries (Tn... itineraries)
 
void addItineraries (T1 itinerary, Tn... itineraries)
 Add a pack of itineraries.
 
void addItineraries (std::span< Itinerary > itineraries)
 Add a set of itineraries.
 
void resetTime ()
 Reset the simulation time.
 
const Graphgraph () const
 Get the graph.
 
const std::unordered_map< Id, std::unique_ptr< Itinerary > > & itineraries () const
 Get the itineraries.
 
const std::map< Id, std::unique_ptr< Agent< Delay > > > & agents () const
 Get the agents.
 
Size nAgents () const
 Get the number of agents currently in the simulation.
 
Time time () const
 Get the time.
 
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}$.
 
Measurement< double > meanTravelTime (bool clearData=false)
 Get the mean travel time of the agents in $s$.
 
void saveStreetDensities (const std::string &filename, bool normalized=true) const
 Save the street densities in csv format.
 
void saveInputStreetCounts (const std::string &filename, bool reset=false)
 Save the street input counts in csv format.
 
void saveOutputStreetCounts (const std::string &filename, bool reset=false)
 Save the street output counts in csv format.
 

Additional Inherited Members

- Protected Member Functions inherited from dsm::RoadDynamics< Delay >
virtual Id m_nextStreetId (Id agentId, Id NodeId, std::optional< Id > streetId=std::nullopt)
 Get the next street id.
 
virtual void m_increaseTurnCounts (Id streetId, double delta)
 Increase the turn counts.
 
void m_evolveStreet (const std::unique_ptr< Street > &pStreet, bool reinsert_agents) override
 Evolve a street.
 
bool m_evolveNode (const std::unique_ptr< Node > &pNode) override
 If possible, removes one agent from the node, putting it on the next street.
 
void m_evolveAgents () override
 Evolve the agents.
 
- Protected Member Functions inherited from dsm::Dynamics< Agent< Delay > >
void m_updatePath (const std::unique_ptr< Itinerary > &pItinerary)
 Update the path of a single itinerary using Dijsktra's algorithm.
 
- Protected Attributes inherited from dsm::RoadDynamics< Delay >
Time m_previousOptimizationTime
 
std::vector< std::pair< double, double > > m_travelDTs
 
std::unordered_map< Id, Id > m_agentNextStreetId
 
bool m_forcePriorities
 
std::optional< Delay > m_dataUpdatePeriod
 
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
 
- Protected Attributes inherited from dsm::Dynamics< Agent< Delay > >
Graph m_graph
 
Time m_time
 
Time m_previousSpireTime
 
std::mt19937_64 m_generator
 

Constructor & Destructor Documentation

◆ FirstOrderDynamics()

dsm::FirstOrderDynamics::FirstOrderDynamics ( Graph & graph,
bool useCache = false,
std::optional< unsigned int > seed = std::nullopt,
double alpha = 0. )
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::Dynamics< Agent< 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::Dynamics< Agent< 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::Dynamics< Agent< 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::Dynamics< Agent< Delay > >.


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