Skip to content

Conversation

@Grufoony
Copy link
Collaborator

Random agents are immortal agents. The only way to kill them is to set the passage probability at junctions: if a normal agent cannot pass, it waits, but if a random agent cannot pass, it dies.

@Grufoony Grufoony requested a review from sbaldu December 17, 2024 09:06
template <typename delay_t>
requires(is_numeric_v<delay_t>)
Agent<delay_t>::Agent(Id id, Id itineraryId, std::optional<Id> srcNodeId)
Agent<delay_t>::Agent(Id id, std::optional<Id> itineraryId, std::optional<Id> srcNodeId)

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
: m_id{id},
m_trip{itineraryId},
m_trip{itineraryId.has_value() ? std::vector<Id>{itineraryId.value()}
: std::vector<Id>{}},

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
template <typename agent_t>
void Dynamics<agent_t>::removeAgent(Size agentId) {
m_agents.erase(agentId);
}

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
/// The matrix format is deduced from the file extension. Currently only .dsm files are supported.
void importMatrix(const std::string& fileName, bool isAdj = true);
void importMatrix(const std::string& fileName,
bool isAdj = true,

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.8 rule Note

MISRA 17.8 rule
void importMatrix(const std::string& fileName, bool isAdj = true);
void importMatrix(const std::string& fileName,
bool isAdj = true,
double defaultSpeed = 13.8888888889);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.8 rule Note

MISRA 17.8 rule
for (auto queueIndex = 0; queueIndex < nLanes; ++queueIndex) {
if (uniformDist(this->m_generator) > m_maxFlowPercentage ||
pStreet->queue(queueIndex).empty()) {
if (pStreet->queue(queueIndex).empty()) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
auto const bCanPass = uniformDist(this->m_generator) < m_passageProbability;
bool bArrived{false};
if (!bCanPass) {
if (pAgent->isRandom()) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
bArrived = true;
}
}
if (bArrived) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
}
if (this->m_itineraries[agent->itineraryId()]->destination() ==
street->nodePair().second) {
if (bArrived) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
buildLog(std::format("The maximum flow percentage ({}) must be between 0 and 1",
maxFlowPercentage)));
void RoadDynamics<delay_t>::setPassageProbability(double passageProbability) {
if (passageProbability < 0. || passageProbability > 1.) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule
Street s12{7, 118 / 8, 118., 13.9, std::make_pair(1, 2)};
Street s23{13, 222 / 8, 222., 13.9, std::make_pair(2, 3)};
Street s34{19, 651 / 4, 651., 13.9, std::make_pair(3, 4)};
Street s34{19, 1, 651., 13.9, std::make_pair(3, 4), 2};

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
@Grufoony Grufoony merged commit c3bf939 into main Dec 17, 2024
25 checks passed
@Grufoony Grufoony deleted the randomAgents branch December 17, 2024 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "random" type of Agent

3 participants