The Agent class represents an agent in the network.
More...
#include <Agent.hpp>
|
| Agent (Time const &spawnTime, std::optional< Id > itineraryId=std::nullopt, std::optional< Id > srcNodeId=std::nullopt) |
| Construct a new Agent object.
|
|
| Agent (Time const &spawnTime, std::vector< Id > const &trip, std::optional< Id > srcNodeId=std::nullopt) |
| Construct a new Agent object.
|
|
void | setSrcNodeId (Id srcNodeId) |
|
void | setStreetId (std::optional< Id > streetId=std::nullopt) |
| Set the street occupied by the agent.
|
|
void | setNextStreetId (Id nextStreetId) |
| Set the id of the next street.
|
|
void | setSpeed (double speed) |
| Set the agent's speed.
|
|
void | setFreeTime (Time const &freeTime) |
| Set the agent's free time.
|
|
void | incrementDistance (double distance) |
| Increment the agent's distance by a given value.
|
|
void | updateItinerary () |
| Update the agent's itinerary.
|
|
void | reset (Time const &spawnTime) |
| Reset the agent.
|
|
Time const & | spawnTime () const |
| Get the agent's spawn time.
|
|
Time const & | freeTime () const |
| Get the agent's free time.
|
|
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.
|
|
std::optional< Id > | nextStreetId () const |
| Get the id of the next street.
|
|
double | speed () const |
| Get the agent's speed.
|
|
double | distance () const |
| Get the agent's travelled distance.
|
|
bool | isRandom () const |
| Return true if the agent is a random agent.
|
|
The Agent class represents an agent in the network.
◆ Agent() [1/2]
dsf::Agent::Agent |
( |
Time const & | spawnTime, |
|
|
std::optional< Id > | itineraryId = std::nullopt, |
|
|
std::optional< Id > | srcNodeId = std::nullopt ) |
Construct a new Agent object.
- Parameters
-
spawnTime | The agent's spawn time |
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]
dsf::Agent::Agent |
( |
Time const & | spawnTime, |
|
|
std::vector< Id > const & | trip, |
|
|
std::optional< Id > | srcNodeId = std::nullopt ) |
Construct a new Agent object.
- Parameters
-
spawnTime | The agent's spawn time |
itineraryIds | The agent's itinerary |
srcNodeId | Optional, The id of the source node of the agent |
◆ distance()
double dsf::Agent::distance |
( |
| ) |
const |
Get the agent's travelled distance.
- Returns
- The agent's travelled distance
◆ freeTime()
Time const & dsf::Agent::freeTime |
( |
| ) |
const |
Get the agent's free time.
- Returns
- The agent's free time
◆ id()
Id dsf::Agent::id |
( |
| ) |
const |
Get the agent's id.
- Returns
- The agent's id
◆ incrementDistance()
void dsf::Agent::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 |
◆ isRandom()
bool dsf::Agent::isRandom |
( |
| ) |
const |
Return true if the agent is a random agent.
- Returns
- True if the agent is a random agent, false otherwise
◆ itineraryId()
Id dsf::Agent::itineraryId |
( |
| ) |
const |
Get the agent's itinerary.
- Returns
- The agent's itinerary
◆ nextStreetId()
std::optional< Id > dsf::Agent::nextStreetId |
( |
| ) |
const |
Get the id of the next street.
- Returns
- The id of the next street
◆ reset()
void dsf::Agent::reset |
( |
Time const & | spawnTime | ) |
|
Reset the agent.
Reset the following values:
- street id = std::nullopt
- delay = 0
- speed = 0
- distance = 0
- time = 0
- itinerary index = 0
◆ setFreeTime()
void dsf::Agent::setFreeTime |
( |
Time const & | freeTime | ) |
|
Set the agent's free time.
- Parameters
-
freeTime | The agent's free time |
◆ setNextStreetId()
void dsf::Agent::setNextStreetId |
( |
Id | nextStreetId | ) |
|
Set the id of the next street.
- Parameters
-
nextStreetId | The id of the next street |
◆ setSpeed()
void dsf::Agent::setSpeed |
( |
double | speed | ) |
|
Set the agent's speed.
- Parameters
-
- Exceptions
-
std::invalid_argument,if | speed is negative |
◆ setStreetId()
void dsf::Agent::setStreetId |
( |
std::optional< Id > | streetId = std::nullopt | ) |
|
Set the street occupied by the agent.
- Parameters
-
streetId | The id of the street currently occupied by the agent |
◆ spawnTime()
Time const & dsf::Agent::spawnTime |
( |
| ) |
const |
Get the agent's spawn time.
- Returns
- The agent's spawn time
◆ speed()
double dsf::Agent::speed |
( |
| ) |
const |
Get the agent's speed.
- Returns
- The agent's speed
◆ srcNodeId()
std::optional< Id > dsf::Agent::srcNodeId |
( |
| ) |
const |
Get the id of the source node of the agent.
- Returns
- The id of the source node of the agent
◆ streetId()
std::optional< Id > dsf::Agent::streetId |
( |
| ) |
const |
Get the id of the street currently occupied by the agent.
- Returns
- The id of the street currently occupied by the agent
◆ trip()
std::vector< Id > const & dsf::Agent::trip |
( |
| ) |
const |
Get the agent's trip.
- Returns
- The agent's trip
◆ updateItinerary()
void dsf::Agent::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: