Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/slow_charge_tl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ int main(int argc, char** argv) {
}
graph.adjustNodeCapacities();
std::cout << "Setting traffic light parameters..." << '\n';
graph.initTrafficLights();
graph.autoInitTrafficLights();
std::cout << "Done." << std::endl;

std::cout << "Creating dynamics...\n";
Expand Down
13 changes: 9 additions & 4 deletions src/dsf/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,18 @@ PYBIND11_MODULE(dsf_cpp, m) {
"adjustNodeCapacities",
&dsf::mobility::RoadNetwork::adjustNodeCapacities,
dsf::g_docstrings.at("dsf::mobility::RoadNetwork::adjustNodeCapacities").c_str())
.def("initTrafficLights",
&dsf::mobility::RoadNetwork::initTrafficLights,
pybind11::arg("minGreenTime") = 30,
dsf::g_docstrings.at("dsf::mobility::RoadNetwork::initTrafficLights").c_str())
.def("autoInitTrafficLights",
&dsf::mobility::RoadNetwork::autoInitTrafficLights,
pybind11::arg("mainRoadPercentage") = 0.6,
dsf::g_docstrings.at("dsf::mobility::RoadNetwork::autoInitTrafficLights")
.c_str())
.def("autoMapStreetLanes",
&dsf::mobility::RoadNetwork::autoMapStreetLanes,
dsf::g_docstrings.at("dsf::mobility::RoadNetwork::autoMapStreetLanes").c_str())
.def("autoAssignRoadPriorities",
&dsf::mobility::RoadNetwork::autoAssignRoadPriorities,
dsf::g_docstrings.at("dsf::mobility::RoadNetwork::autoAssignRoadPriorities")
.c_str())
.def("setStreetStationaryWeights",
&dsf::mobility::RoadNetwork::setStreetStationaryWeights,
pybind11::arg("weights"),
Expand Down
7 changes: 1 addition & 6 deletions src/dsf/mobility/Road.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ namespace dsf::mobility {
m_length{length},
m_maxSpeed{maxSpeed},
m_nLanes{nLanes},
m_name{std::move(name)},
m_priority{nLanes * 100} {
m_name{std::move(name)} {
if (!(length > 0.)) {
throw std::invalid_argument(
std::format("The length of a road ({}) must be greater than 0.", length));
Expand Down Expand Up @@ -84,10 +83,6 @@ namespace dsf::mobility {
}
m_transportCapacity = transportCapacity;
}
void Road::setPriority(int priority) {
assert(priority >= 0);
m_priority = priority;
}
Direction Road::turnDirection(double const& previousStreetAngle) const {
auto const deltaAngle{this->deltaAngle(previousStreetAngle)};
if (std::abs(deltaAngle) >= std::numbers::pi) {
Expand Down
11 changes: 5 additions & 6 deletions src/dsf/mobility/Road.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace dsf::mobility {
int m_capacity;
double m_transportCapacity;
std::string m_name;
int m_priority;
bool m_hasPriority = false;
std::set<Id> m_forbiddenTurns; // Stores the forbidden turns (road ids)
std::optional<RoadType> m_roadType{std::nullopt};

Expand Down Expand Up @@ -70,9 +70,8 @@ namespace dsf::mobility {
/// @param transportCapacity The transport capacity
/// @throws std::invalid_argument If the transport capacity is less or equal to 0
void setTransportCapacity(double transportCapacity);
/// @brief Set the road's priority
/// @param priority The road's priority
void setPriority(int priority);
/// @brief Set the road's priority to true
inline void setPriority() { m_hasPriority = true; }
/// @brief Add a road id to the forbidden turns
/// @param roadId The road id to add
void addForbiddenTurn(Id roadId);
Expand Down Expand Up @@ -102,8 +101,8 @@ namespace dsf::mobility {
/// @return std::string The name
inline auto const& name() const noexcept { return m_name; }
/// @brief Get the priority
/// @return int The priority
inline auto priority() const noexcept { return m_priority; }
/// @return bool Whether the road has priority
inline auto hasPriority() const noexcept { return m_hasPriority; }
/// @brief Get the road's forbidden turns
/// @return std::set<Id> The road's forbidden turns
/// @details The forbidden turns are the road ids that are not allowed to be used by the agents
Expand Down
Loading
Loading