-
Notifications
You must be signed in to change notification settings - Fork 4
Enhance traffic lights optimization algorithm #240
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
| densities.reserve(m_graph.streetSet().size()); | ||
| for (const auto& [streetId, street] : m_graph.streetSet()) { | ||
| densities.push_back(street->density(normalized)); | ||
| if (normalized) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 14.4 rule Note
| densities.push_back(street->density(false) * street->length()); | ||
| sum += street->length(); | ||
| } | ||
| if (sum == 0) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 10.4 rule Note
| return Measurement(0., 0.); | ||
| } | ||
| auto meanDensity{std::accumulate(densities.begin(), densities.end(), 0.) / sum}; | ||
| return Measurement(meanDensity, 0.); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| std::unordered_map<Id, std::array<unsigned long long, 4>> m_turnCounts; | ||
| std::unordered_map<Id, std::array<long, 4>> m_turnMapping; | ||
| std::unordered_map<Id, Size> m_streetTails; | ||
| std::unordered_map<Id, double> m_streetTails; |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| tl.resetCycles(); | ||
| } | ||
| auto const outputDifference{(outputGreenSum - outputRedSum) / nCycles}; | ||
| if ((inputDifference * outputDifference > 0) || |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.1 rule Note
| } | ||
| auto const outputDifference{(outputGreenSum - outputRedSum) / nCycles}; | ||
| if ((inputDifference * outputDifference > 0) || | ||
| std::max(std::abs(inputDifference), std::abs(outputDifference)) < threshold || |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.1 rule Note
| double TrafficLight::meanGreenTime(bool priorityStreets) const { | ||
| double meanTime{0.}; | ||
| size_t nCycles{0}; | ||
| for (auto const& [streetId, cycles] : m_cycles) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| } | ||
| } | ||
| } | ||
| return meanTime / nCycles; |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 10.4 rule Note
| meanTime += std::accumulate(cycles.begin(), | ||
| cycles.end(), | ||
| 0., | ||
| [](double acc, TrafficLightCycle const& cycle) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note
| cycles.end(), | ||
| 0., | ||
| [](double acc, TrafficLightCycle const& cycle) { | ||
| return acc + cycle.greenTime(); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 15.5 rule Note
| cycles.end(), | ||
| 0., | ||
| [](double acc, TrafficLightCycle const& cycle) { | ||
| return acc + cycle.greenTime(); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 10.4 rule Note
|
I give up about mac |
New features: