-
Notifications
You must be signed in to change notification settings - Fork 4
Add stationary probability for random vehicles movement #376
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -172,6 +172,11 @@ PYBIND11_MODULE(dsf_cpp, m) { | |||||
| .def("autoMapStreetLanes", | ||||||
| &dsf::mobility::RoadNetwork::autoMapStreetLanes, | ||||||
| dsf::g_docstrings.at("dsf::mobility::RoadNetwork::autoMapStreetLanes").c_str()) | ||||||
| .def("setStreetStationaryWeights", | ||||||
| &dsf::mobility::RoadNetwork::setStreetStationaryWeights, | ||||||
| pybind11::arg("weights"), | ||||||
| dsf::g_docstrings.at("dsf::mobility::RoadNetwork::setStreetStationaryWeights") | ||||||
| .c_str()) | ||||||
| .def( | ||||||
| "importEdges", | ||||||
| [](dsf::mobility::RoadNetwork& self, const std::string& fileName) { | ||||||
|
|
@@ -531,6 +536,10 @@ PYBIND11_MODULE(dsf_cpp, m) { | |||||
| pybind11::arg("ratio") = 1.3, | ||||||
| dsf::g_docstrings.at("dsf::mobility::RoadDynamics::optimizeTrafficLights") | ||||||
| .c_str()) | ||||||
| .def("graph", | ||||||
| &dsf::mobility::FirstOrderDynamics::graph, | ||||||
| pybind11::return_value_policy::reference_internal, | ||||||
| dsf::g_docstrings.at("dsf::Dynamics::graph").c_str()) | ||||||
|
||||||
| dsf::g_docstrings.at("dsf::Dynamics::graph").c_str()) | |
| dsf::g_docstrings.at("dsf::Dynamics::graph() const").c_str()) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -497,11 +497,13 @@ namespace dsf::mobility { | |||||
| std::optional<Id> previousNodeId = std::nullopt; | ||||||
| std::set<Id> forbiddenTurns; | ||||||
| double speedCurrent = 1.0; | ||||||
| double stationaryWeightCurrent = 1.0; | ||||||
| if (pAgent->streetId().has_value()) { | ||||||
| auto const& pStreetCurrent{this->graph().edge(pAgent->streetId().value())}; | ||||||
| previousNodeId = pStreetCurrent->source(); | ||||||
| forbiddenTurns = pStreetCurrent->forbiddenTurns(); | ||||||
| speedCurrent = pStreetCurrent->maxSpeed(); | ||||||
| stationaryWeightCurrent = pStreetCurrent->stationaryWeight(); | ||||||
| } | ||||||
|
|
||||||
| // Get path targets for non-random agents | ||||||
|
|
@@ -550,7 +552,10 @@ namespace dsf::mobility { | |||||
|
|
||||||
| // Calculate base probability | ||||||
| auto const speedNext{pStreetOut->maxSpeed()}; | ||||||
| double probability = speedCurrent * speedNext; | ||||||
| double const stationaryWeightNext = pStreetOut->stationaryWeight(); | ||||||
| auto const weightRatio{stationaryWeightNext / | ||||||
| stationaryWeightCurrent}; // SQRT (p_i / p_j) | ||||||
|
||||||
| stationaryWeightCurrent}; // SQRT (p_i / p_j) | |
| stationaryWeightCurrent}; // sqrt(p_next / p_current) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,8 +48,8 @@ namespace dsf::mobility { | |||||||||||||||
| AgentComparator> | ||||||||||||||||
| m_movingAgents; | ||||||||||||||||
| std::vector<Direction> m_laneMapping; | ||||||||||||||||
| // std::unordered_map<Id, double> m_transitionProbabilities; | ||||||||||||||||
| std::optional<Counter> m_counter; | ||||||||||||||||
| double m_stationaryWeight{1.0}; | ||||||||||||||||
|
|
||||||||||||||||
| public: | ||||||||||||||||
| /// @brief Construct a new Street object | ||||||||||||||||
|
|
@@ -84,12 +84,9 @@ namespace dsf::mobility { | |||||||||||||||
| /// @param meanVehicleLength The mean vehicle length | ||||||||||||||||
| /// @throw std::invalid_argument If the mean vehicle length is negative | ||||||||||||||||
| static void setMeanVehicleLength(double meanVehicleLength); | ||||||||||||||||
| // /// @brief Set the street's transition probabilities | ||||||||||||||||
| // /// @param transitionProbabilities The street's transition probabilities | ||||||||||||||||
| // inline void setTransitionProbabilities( | ||||||||||||||||
| // std::unordered_map<Id, double> const& transitionProbabilities) { | ||||||||||||||||
| // m_transitionProbabilities = transitionProbabilities; | ||||||||||||||||
| // }; | ||||||||||||||||
| /// @brief Set the street's stationary weight | ||||||||||||||||
| /// @param weight The street's stationary weight | ||||||||||||||||
| inline void setStationaryWeight(double const weight) { m_stationaryWeight = weight; } | ||||||||||||||||
|
||||||||||||||||
| inline void setStationaryWeight(double const weight) { m_stationaryWeight = weight; } | |
| inline void setStationaryWeight(double const weight) { | |
| if (weight <= 0.0) { | |
| throw std::invalid_argument("Stationary weight must be positive."); | |
| } | |
| m_stationaryWeight = weight; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Python bindings reference
dsf::mobility::RoadNetwork::setStreetStationaryWeightsin the docstrings map (line 178), but this method has no documentation in RoadNetwork.hpp (line 194). This will cause a runtime error when loading the Python module, as the docstrings are generated from Doxygen comments and this key won't exist in the g_docstrings map. Add proper Doxygen documentation for this public API method.