Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/workflows/cmake_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

env:
BUILD_TYPE: Debug
BUILD_TYPE: Release

jobs:
build:
Expand Down
121 changes: 121 additions & 0 deletions examples/data/coordinates.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
nodeId;lat;lon
119;110;90
118;100;90
117;90;90
116;80;90
115;70;90
114;60;90
113;50;90
112;40;90
111;30;90
110;20;90
109;10;90
108;0;90
107;110;80
106;100;80
105;90;80
104;80;80
103;70;80
102;60;80
101;50;80
100;40;80
99;30;80
98;20;80
97;10;80
96;0;80
95;110;70
94;100;70
93;90;70
92;80;70
91;70;70
90;60;70
89;50;70
88;40;70
87;30;70
86;20;70
85;10;70
84;0;70
83;110;60
82;100;60
81;90;60
80;80;60
79;70;60
78;60;60
77;50;60
76;40;60
75;30;60
74;20;60
73;10;60
72;0;60
71;110;50
70;100;50
69;90;50
68;80;50
67;70;50
66;60;50
65;50;50
64;40;50
63;30;50
62;20;50
61;10;50
60;0;50
59;110;40
28;40;20
27;30;20
26;20;20
25;10;20
24;0;20
23;110;10
22;100;10
11;110;0
21;90;10
10;100;0
20;80;10
9;90;0
19;70;10
8;80;0
18;60;10
7;70;0
0;0;0
13;10;10
1;10;0
14;20;10
12;0;10
2;20;0
15;30;10
3;30;0
16;40;10
4;40;0
17;50;10
5;50;0
6;60;0
29;50;20
30;60;20
31;70;20
32;80;20
33;90;20
34;100;20
35;110;20
36;0;30
37;10;30
38;20;30
39;30;30
40;40;30
41;50;30
42;60;30
43;70;30
44;80;30
45;90;30
46;100;30
47;110;30
48;0;40
49;10;40
50;20;40
51;30;40
52;40;40
53;50;40
54;60;40
55;70;40
56;80;40
57;90;40
58;100;40
4 changes: 2 additions & 2 deletions examples/slow_charge_rb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ int main(int argc, char** argv) {
for (const auto& [nodeId, node] : graph.nodeSet()) {
auto& rb = dynamic_cast<Roundabout&>(*node);
rb.setCapacity(degreeVector(nodeId));
rb.setTransportCapacity(degreeVector(nodeId));
}
std::cout << "Done." << std::endl;

Expand Down Expand Up @@ -189,7 +190,7 @@ int main(int argc, char** argv) {
// std::vector<int> deltas;

// lauch progress bar
std::thread t([]() {
std::jthread t([]() {
while (progress < MAX_TIME && !bExitFlag) {
printLoadingBar(progress, MAX_TIME);
std::this_thread::sleep_for(std::chrono::milliseconds(1500));
Expand Down Expand Up @@ -302,7 +303,6 @@ int main(int argc, char** argv) {
// std::cout << "Probability of turning " << std::quoted(turnNames[i]) << ": " << value * 100 << "%\n";
// ++i;
// }
t.join();
std::cout << '\n';
std::cout << "Done." << std::endl;

Expand Down
4 changes: 2 additions & 2 deletions examples/slow_charge_tl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ int main(int argc, char** argv) {
for (const auto& [nodeId, node] : graph.nodeSet()) {
auto& tl = dynamic_cast<TrafficLight&>(*node);
tl.setCapacity(degreeVector(nodeId));
tl.setTransportCapacity(degreeVector(nodeId));
double value = -1.;
while (value < 0.) {
value = random();
Expand Down Expand Up @@ -292,7 +293,7 @@ int main(int argc, char** argv) {
// std::vector<int> deltas;

// lauch progress bar
std::thread t([]() {
std::jthread t([]() {
while (progress < MAX_TIME && !bExitFlag) {
printLoadingBar(progress, MAX_TIME);
std::this_thread::sleep_for(std::chrono::milliseconds(1500));
Expand Down Expand Up @@ -449,7 +450,6 @@ int main(int argc, char** argv) {
// std::cout << "Probability of turning " << std::quoted(turnNames[i]) << ": " << value * 100 << "%\n";
// ++i;
// }
t.join();
std::cout << '\n';
std::cout << "Done." << std::endl;

Expand Down
3 changes: 1 addition & 2 deletions examples/stalingrado.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int main() {
auto& spire = dynamic_cast<SpireStreet&>(*dynamics.graph().streetSet().at(19));

// lauch progress bar
std::thread t([MAX_TIME]() {
std::jthread t([MAX_TIME]() {
while (progress < MAX_TIME) {
printLoadingBar(progress, MAX_TIME);
std::this_thread::sleep_for(std::chrono::milliseconds(1500));
Expand All @@ -118,7 +118,6 @@ int main() {
dynamics.evolve(false);
++progress;
}
t.join();

return 0;
}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
contextily
geopandas
matplotlib
networkx
numpy
Expand Down
12 changes: 7 additions & 5 deletions utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
"""

import networkx as nx
import pandas as pd

Check warning

Code scanning / Prospector (reported by Codacy)

Unable to import 'pandas' (import-error) Warning

Unable to import 'pandas' (import-error)


def create_graph_from_adj(adj: list, coord: list):
"""Creates a graph given adjacency matrix and a list of coordinates"""
def create_graph_from_adj(adj: list, coord: pd.DataFrame):
"""Creates a graph given adjacency matrix and a dataframe of coordinates"""
n = len(adj)
graph = nx.DiGraph()
graph.add_nodes_from(range(n))
for i in range(n):
for j in range(i + 1, n):
for j in range(n):
if adj[i, j] > 0:
graph.add_edge(i, j, color="g", weight=adj[i, j])
graph.add_edge(j, i, color="g", weight=adj[j, i])
edges = graph.edges()
pos = {}
for i in range(n):
pos[i] = coord[i, :]
# coord has id as index with lat, lon columns
for node in graph.nodes():
pos[node] = (coord.loc[node]["lon"], coord.loc[node]["lat"])

return (graph, edges, pos)
Loading
Loading