-
Notifications
You must be signed in to change notification settings - Fork 4
Enhance templates in Dynamics classes #231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| double FirstOrderDynamics::streetMeanSpeed(Id streetId) const { | ||
| const auto& street{this->m_graph.streetSet().at(streetId)}; | ||
| if (street->nAgents() == 0) { | ||
| return street->maxSpeed(); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| } | ||
| std::vector<double> speeds; | ||
| speeds.reserve(this->m_graph.streetSet().size()); | ||
| for (const auto& [streetId, street] : this->m_graph.streetSet()) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| Measurement<double> FirstOrderDynamics::streetMeanSpeed(double threshold, | ||
| bool above) const { | ||
| if (this->m_agents.size() == 0) { | ||
| return Measurement(0., 0.); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| } | ||
| std::vector<double> speeds; | ||
| speeds.reserve(this->m_graph.streetSet().size()); | ||
| for (const auto& [streetId, street] : this->m_graph.streetSet()) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| requires(is_numeric_v<delay_t>) | ||
| RoadDynamics<delay_t>::RoadDynamics(Graph& graph, std::optional<unsigned int> seed) | ||
| : Dynamics<delay_t>(graph, seed), | ||
| : Dynamics<Agent<delay_t>>(graph, seed), |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| FirstOrderDynamics::FirstOrderDynamics(Graph& graph, | ||
| std::optional<unsigned int> seed, | ||
| double alpha) | ||
| : RoadDynamics<Delay>(graph, seed), m_alpha{0.}, m_speedFluctuationSTD{0.} { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| std::optional<unsigned int> seed, | ||
| double alpha) | ||
| : RoadDynamics<Delay>(graph, seed), m_alpha{0.}, m_speedFluctuationSTD{0.} { | ||
| if (alpha < 0. || alpha > 1.) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.1 rule Note
| m_alpha = alpha; | ||
| } | ||
| double globMaxTimePenalty{0.}; | ||
| for (const auto& [streetId, street] : this->m_graph.streetSet()) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| void FirstOrderDynamics::setAgentSpeed(Size agentId) { | ||
| const auto& agent{this->m_agents[agentId]}; | ||
| const auto& street{this->m_graph.streetSet()[agent->streetId().value()]}; | ||
| double speed{street->maxSpeed() * (1. - m_alpha * street->density(true))}; |
Check warning
Code scanning / Cppcheck (reported by Codacy)
Local variable 'speed' shadows outer function Warning
| void FirstOrderDynamics::setAgentSpeed(Size agentId) { | ||
| const auto& agent{this->m_agents[agentId]}; | ||
| const auto& street{this->m_graph.streetSet()[agent->streetId().value()]}; | ||
| double speed{street->maxSpeed() * (1. - m_alpha * street->density(true))}; |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.1 rule Note
| std::normal_distribution<double> speedDist{speed, speed * m_speedFluctuationSTD}; | ||
| speed = speedDist(this->m_generator); | ||
| } | ||
| speed < 0. ? agent->setSpeed(street->maxSpeed() * (1. - m_alpha)) |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.1 rule Note
| double minSpeedRateo = 0.); | ||
| explicit FirstOrderDynamics(Graph& graph, | ||
| std::optional<unsigned int> seed = std::nullopt, | ||
| double alpha = 0.); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 17.8 rule Note
agent_tagent typedelay_tdelay typeDelay