The Agent class represents an agent in the network.
More...
#include <Agent.hpp>
|
| 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.
|
|
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,The | type of the agent's delay. It must be a numeric type (see utility/TypeTraits/is_numeric.hpp). |
◆ 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
-
id | The agent's id |
itineraryId | Optional, The agent's destination node. If not provided, the agent is a random agent |
srcNodeId | Optional, 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
-
id | The agent's id |
itineraryIds | The agent's itinerary |
srcNodeId | Optional, The id of the source node of the agent |
◆ decrementDelay()
template<typename delay_t>
requires (is_numeric_v<delay_t>)
Decrement the agent's delay by 1.
- Exceptions
-
std::underflow_error,if | delay has reached its minimum value |
◆ delay()
template<typename delay_t>
Get the agent's delay.
- Returns
- The agent's delay
◆ distance()
template<typename delay_t>
Get the agent's travelled distance.
- Returns
- The agent's travelled distance
◆ id()
template<typename delay_t>
Get the agent's id.
- Returns
- The agent's id
◆ incrementDelay() [1/2]
template<typename delay_t>
requires (is_numeric_v<delay_t>)
Increment the agent's delay by 1.
- Exceptions
-
std::overflow_error,if | delay 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
-
- Exceptions
-
std::overflow_error,if | delay 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
-
distance | The value to increment the agent's distance byĆ¹ |
- Exceptions
-
std::invalid_argument,if | distance is negative |
◆ incrementTime() [1/2]
template<typename delay_t>
requires (is_numeric_v<delay_t>)
Increment the agent's time by 1.
- Exceptions
-
std::overflow_error,if | time 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
-
time | The value to increment the agent's time by |
- Exceptions
-
std::overflow_error,if | time has reached its maximum value |
◆ isRandom()
template<typename delay_t>
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>
Get the agent's itinerary.
- Returns
- The agent's itinerary
◆ reset()
template<typename delay_t>
requires (is_numeric_v<delay_t>)
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
-
- Exceptions
-
std::invalid_argument,if | speed is negative |
◆ setStreetId()
template<typename delay_t>
void dsm::Agent< delay_t >::setStreetId |
( |
Id | streetId | ) |
|
|
inline |
Set the street occupied by the agent.
- Parameters
-
streetId | The id of the street currently occupied by the agent |
◆ speed()
template<typename delay_t>
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>)
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: