Dynamical system model
Loading...
Searching...
No Matches
dsm::Agent< delay_t > Class Template Reference

The Agent class represents an agent in the network. More...

#include <Agent.hpp>

Public Member Functions

 Agent (Id id, std::optional< Id > itineraryId=std::nullopt, std::optional< Id > srcNodeId=std::nullopt)
 Construct a new Agent object.
 
 Agent (Id id, std::vector< Id > const &trip, std::optional< Id > srcNodeId=std::nullopt)
 Construct a new Agent object.
 
void setStreetId (Id streetId)
 Set the street occupied by the agent.
 
void setSpeed (double speed)
 Set the agent's speed.
 
void incrementDelay ()
 Increment the agent's delay by 1.
 
void incrementDelay (delay_t const delay)
 Increment the agent's delay by a given value.
 
void decrementDelay ()
 Decrement the agent's delay by 1.
 
void incrementDistance ()
 Increment the agent's distance by its speed * 1 second.
 
void incrementDistance (double distance)
 Increment the agent's distance by a given value.
 
void incrementTime ()
 Increment the agent's time by 1.
 
void incrementTime (unsigned int const time)
 Increment the agent's time by a given value.
 
void resetTime ()
 Reset the agent's time to 0.
 
void updateItinerary ()
 Update the agent's itinerary.
 
void reset ()
 Reset the agent.
 
Id id () const
 Get the agent's id.
 
Id itineraryId () const
 Get the agent's itinerary.
 
std::vector< Id > const & trip () const
 Get the agent's trip.
 
std::optional< Id > streetId () const
 Get the id of the street currently occupied by the agent.
 
std::optional< Id > srcNodeId () const
 Get the id of the source node of the agent.
 
double speed () const
 Get the agent's speed.
 
delay_t delay () const
 Get the agent's delay.
 
double distance () const
 Get the agent's travelled distance.
 
unsigned int time () const
 Get the agent's travel time.
 
bool isRandom () const
 Return true if the agent is a random agent.
 

Detailed Description

template<typename delay_t>
requires (is_numeric_v<delay_t>)
class dsm::Agent< delay_t >

The Agent class represents an agent in the network.

Template Parameters
delay_t,Thetype of the agent's delay. It must be a numeric type (see utility/TypeTraits/is_numeric.hpp).

Constructor & Destructor Documentation

◆ Agent() [1/2]

template<typename delay_t>
requires (is_numeric_v<delay_t>)
dsm::Agent< delay_t >::Agent ( Id id,
std::optional< Id > itineraryId = std::nullopt,
std::optional< Id > srcNodeId = std::nullopt )

Construct a new Agent object.

Parameters
idThe agent's id
itineraryIdOptional, The agent's destination node. If not provided, the agent is a random agent
srcNodeIdOptional, The id of the source node of the agent

◆ Agent() [2/2]

template<typename delay_t>
requires (is_numeric_v<delay_t>)
dsm::Agent< delay_t >::Agent ( Id id,
std::vector< Id > const & trip,
std::optional< Id > srcNodeId = std::nullopt )

Construct a new Agent object.

Parameters
idThe agent's id
itineraryIdsThe agent's itinerary
srcNodeIdOptional, The id of the source node of the agent

Member Function Documentation

◆ decrementDelay()

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::decrementDelay ( )

Decrement the agent's delay by 1.

Exceptions
std::underflow_error,ifdelay has reached its minimum value

◆ delay()

template<typename delay_t>
delay_t dsm::Agent< delay_t >::delay ( ) const
inline

Get the agent's delay.

Returns
The agent's delay

◆ distance()

template<typename delay_t>
double dsm::Agent< delay_t >::distance ( ) const
inline

Get the agent's travelled distance.

Returns
The agent's travelled distance

◆ id()

template<typename delay_t>
Id dsm::Agent< delay_t >::id ( ) const
inline

Get the agent's id.

Returns
The agent's id

◆ incrementDelay() [1/2]

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::incrementDelay ( )

Increment the agent's delay by 1.

Exceptions
std::overflow_error,ifdelay has reached its maximum value

◆ incrementDelay() [2/2]

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::incrementDelay ( delay_t const delay)

Increment the agent's delay by a given value.

Parameters
delayThe agent's delay
Exceptions
std::overflow_error,ifdelay has reached its maximum value

◆ incrementDistance()

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::incrementDistance ( double distance)

Increment the agent's distance by a given value.

Parameters
distanceThe value to increment the agent's distance byĆ¹
Exceptions
std::invalid_argument,ifdistance is negative

◆ incrementTime() [1/2]

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::incrementTime ( )

Increment the agent's time by 1.

Exceptions
std::overflow_error,iftime has reached its maximum value

◆ incrementTime() [2/2]

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::incrementTime ( unsigned int const time)

Increment the agent's time by a given value.

Parameters
timeThe value to increment the agent's time by
Exceptions
std::overflow_error,iftime has reached its maximum value

◆ isRandom()

template<typename delay_t>
bool dsm::Agent< delay_t >::isRandom ( ) const
inline

Return true if the agent is a random agent.

Returns
True if the agent is a random agent, false otherwise

◆ itineraryId()

template<typename delay_t>
Id dsm::Agent< delay_t >::itineraryId ( ) const
inline

Get the agent's itinerary.

Returns
The agent's itinerary

◆ reset()

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::reset ( )

Reset the agent.

Reset the following values:

  • street id = std::nullopt
  • delay = 0
  • speed = 0
  • distance = 0
  • time = 0
  • itinerary index = 0

◆ setSpeed()

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::setSpeed ( double speed)

Set the agent's speed.

Parameters
speed,Theagent's speed
Exceptions
std::invalid_argument,ifspeed is negative

◆ setStreetId()

template<typename delay_t>
void dsm::Agent< delay_t >::setStreetId ( Id streetId)
inline

Set the street occupied by the agent.

Parameters
streetIdThe id of the street currently occupied by the agent

◆ speed()

template<typename delay_t>
double dsm::Agent< delay_t >::speed ( ) const
inline

Get the agent's speed.

Returns
The agent's speed

◆ srcNodeId()

template<typename delay_t>
std::optional< Id > dsm::Agent< delay_t >::srcNodeId ( ) const
inline

Get the id of the source node of the agent.

Returns
The id of the source node of the agent

◆ streetId()

template<typename delay_t>
std::optional< Id > dsm::Agent< delay_t >::streetId ( ) const
inline

Get the id of the street currently occupied by the agent.

Returns
The id of the street currently occupied by the agent

◆ time()

template<typename delay_t>
unsigned int dsm::Agent< delay_t >::time ( ) const
inline

Get the agent's travel time.

Returns
The agent's travel time

◆ trip()

template<typename delay_t>
std::vector< Id > const & dsm::Agent< delay_t >::trip ( ) const
inline

Get the agent's trip.

Returns
The agent's trip

◆ updateItinerary()

template<typename delay_t>
requires (is_numeric_v<delay_t>)
void dsm::Agent< delay_t >::updateItinerary ( )

Update the agent's itinerary.

If possible, the agent's itinerary is updated by removing the first element from the itinerary's vector.


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