Skip to content

Commit d3fbe01

Browse files
authored
Add dsf::geometry and Manhattan network creation tool (#353)
- Add `dsf::geometry` namespace - Add `create_manhattan_cartography` - Remove deprecated functions
1 parent e550d14 commit d3fbe01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1397
-1313
lines changed

benchmark/Graph/BenchGraph.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,4 @@ int main() {
5656
// std::cout << "Benchmarking building the adjacency matrix\n";
5757
// b3.benchmark([&g2]() -> void { g2.buildAdj(); });
5858
// b3.print<sb::microseconds>();
59-
60-
// Bench b4(3);
61-
// RoadNetwork g3;
62-
// g3.importMatrix("./RoadNetwork/data/matrix.dat");
63-
// std::cout << "Benchmarking the algorithm for the shortest path\n";
64-
// b4.benchmark([&g3]() -> void { g3.shortestPath(0, 1); });
65-
// b4.print<sb::microseconds>();
6659
}

benchmark/Street/BenchStreet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using SparseMatrix = dsf::SparseMatrix<bool>;
1313
using Bench = sb::Bench<long long int>;
1414

1515
int main() {
16-
Street street(0, std::make_pair(0, 1), 5000.);
16+
Street street(0, dsf::geometry::Point(0, 1), 5000.);
1717
Agent agent(0, 0, 0);
1818
Bench b(1000);
1919

examples/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ Many of these simulations were used as thesis work.
44

55
To compile all simulations, use cmake inside the *examples* folder:
66
```shell
7-
cmake -B build -DCMAKE_BUILD_TYPE=Release && make -C build
7+
cmake -B build -DCMAKE_BUILD_TYPE=Release && make -C build -j$(nproc)
88
```
99
If anything goes wrong, try to build the example in debug mode:
1010
```shell
11-
cmake -B build -DCMAKE_BUILD_TYPE=Debug && make -C build
11+
cmake -B build -DCMAKE_BUILD_TYPE=Debug && make -C build -j$(nproc)
1212
```
1313

1414
## Simulation files

examples/data/coordinates.csv

Lines changed: 0 additions & 121 deletions
This file was deleted.

examples/data/coordinates.dsf

Lines changed: 0 additions & 121 deletions
This file was deleted.

examples/data/matrix.dat

Lines changed: 0 additions & 121 deletions
This file was deleted.

examples/slow_charge_rb.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ std::atomic<bool> bExitFlag{false};
3131
#define PRINT_OUT_SPIRES
3232
// #define PRINT_SPEEDS
3333

34-
using Unit = unsigned int;
35-
using Delay = uint8_t;
36-
3734
using RoadNetwork = dsf::RoadNetwork;
3835
using Dynamics = dsf::FirstOrderDynamics;
3936
using Street = dsf::Street;
@@ -67,8 +64,6 @@ int main(int argc, char** argv) {
6764
std::cout << "Initial number of agents: " << nAgents << '\n';
6865
std::cout << "-------------------------------------------------\n";
6966

70-
const std::string IN_MATRIX{"./data/matrix.dat"}; // input matrix file
71-
const std::string IN_COORDS{"./data/coordinates.dsf"}; // input coords file
7267
const std::string OUT_FOLDER{std::format("{}output_scrb_{}_{}/",
7368
BASE_OUT_FOLDER,
7469
ERROR_PROBABILITY,
@@ -86,16 +81,16 @@ int main(int argc, char** argv) {
8681
// Starting
8782
std::cout << "Using dsf version: " << dsf::version() << '\n';
8883
RoadNetwork graph{};
89-
std::cout << "Importing matrix.dat...\n";
90-
graph.importMatrix(IN_MATRIX, false);
91-
graph.importCoordinates(IN_COORDS);
84+
std::cout << "Importing Manhattan-like network...\n";
85+
graph.importEdges("../test/data/manhattan_edges.csv");
86+
graph.importNodeProperties("../test/data/manhattan_nodes.csv");
9287
std::cout << "Setting street parameters..." << '\n';
9388

9489
std::cout << "Number of nodes: " << graph.nNodes() << '\n';
9590
std::cout << "Number of streets: " << graph.nEdges() << '\n';
9691

9792
std::cout << "Rounding the simulation...\n";
98-
for (Unit i{0}; i < graph.nNodes(); ++i) {
93+
for (std::size_t i{0}; i < graph.nNodes(); ++i) {
9994
graph.makeRoundabout(i);
10095
}
10196
std::cout << "Making every street a spire...\n";
@@ -110,7 +105,7 @@ int main(int argc, char** argv) {
110105
Dynamics dynamics{graph, true, SEED, 0.6};
111106

112107
{
113-
std::vector<Unit> destinationNodes;
108+
std::vector<dsf::Id> destinationNodes;
114109
for (auto const& [nodeId, pNode] : dynamics.graph().nodes()) {
115110
if (pNode->outgoingEdges().size() < 4) {
116111
destinationNodes.push_back(nodeId);

0 commit comments

Comments
 (0)