edsger 0.1.1__cp310-cp310-macosx_10_9_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- edsger/.gitignore +1 -0
- edsger/__init__.py +1 -0
- edsger/_version.py +1 -0
- edsger/commons.c +8391 -0
- edsger/commons.cpython-310-darwin.so +0 -0
- edsger/commons.pxd +25 -0
- edsger/commons.pyx +34 -0
- edsger/dijkstra.c +35848 -0
- edsger/dijkstra.cpython-310-darwin.so +0 -0
- edsger/dijkstra.pyx +504 -0
- edsger/networks.py +414 -0
- edsger/path.py +786 -0
- edsger/path_tracking.c +30241 -0
- edsger/path_tracking.cpython-310-darwin.so +0 -0
- edsger/path_tracking.pyx +93 -0
- edsger/pq_4ary_dec_0b.c +35869 -0
- edsger/pq_4ary_dec_0b.cpython-310-darwin.so +0 -0
- edsger/pq_4ary_dec_0b.pxd +33 -0
- edsger/pq_4ary_dec_0b.pyx +692 -0
- edsger/spiess_florian.c +34520 -0
- edsger/spiess_florian.cpython-310-darwin.so +0 -0
- edsger/spiess_florian.pyx +368 -0
- edsger/star.c +33896 -0
- edsger/star.cpython-310-darwin.so +0 -0
- edsger/star.pyx +356 -0
- edsger/utils.py +63 -0
- edsger-0.1.1.dist-info/METADATA +111 -0
- edsger-0.1.1.dist-info/RECORD +32 -0
- edsger-0.1.1.dist-info/WHEEL +5 -0
- edsger-0.1.1.dist-info/licenses/AUTHORS.rst +5 -0
- edsger-0.1.1.dist-info/licenses/LICENSE +21 -0
- edsger-0.1.1.dist-info/top_level.txt +1 -0
edsger/networks.py
ADDED
@@ -0,0 +1,414 @@
|
|
1
|
+
"""Module dedicated to the generation of small networks, for testing purposes."""
|
2
|
+
|
3
|
+
from io import StringIO
|
4
|
+
|
5
|
+
import numpy as np
|
6
|
+
import pandas as pd
|
7
|
+
|
8
|
+
|
9
|
+
class SiouxFalls:
|
10
|
+
"""
|
11
|
+
A class representing the Sioux Falls network.
|
12
|
+
|
13
|
+
Attributes
|
14
|
+
----------
|
15
|
+
graph_edges : pandas.DataFrame
|
16
|
+
A DataFrame containing the edges of the Sioux Falls network. The DataFrame has three
|
17
|
+
columns: 'tail' (int32), 'head' (int32), and 'trav_time' (float64). Each row represents
|
18
|
+
an edge from the tail node to the head node with a corresponding travel time.
|
19
|
+
|
20
|
+
Examples
|
21
|
+
--------
|
22
|
+
>>> siouxfalls = SiouxFalls()
|
23
|
+
>>> print(siouxfalls.edges.head())
|
24
|
+
tail head trav_time
|
25
|
+
0 0 1 6.000816
|
26
|
+
1 0 2 4.008691
|
27
|
+
2 1 0 6.000834
|
28
|
+
3 1 5 6.573598
|
29
|
+
4 2 0 4.008587
|
30
|
+
|
31
|
+
"""
|
32
|
+
|
33
|
+
@property
|
34
|
+
def edges(self):
|
35
|
+
"""
|
36
|
+
A DataFrame containing the edges of the Sioux Falls network.
|
37
|
+
|
38
|
+
Returns
|
39
|
+
-------
|
40
|
+
graph_edges : pandas.DataFrame
|
41
|
+
A DataFrame containing the edges of the Sioux Falls network. The DataFrame has three
|
42
|
+
columns: 'tail' (int32), 'head' (int32), and 'trav_time' (float64). Each row represents
|
43
|
+
an edge from the tail node to the head node with a corresponding travel time.
|
44
|
+
|
45
|
+
"""
|
46
|
+
siouxfalls_graph_edges_csv = StringIO(
|
47
|
+
"""tail,head,trav_time
|
48
|
+
0,1,6.00081623735432
|
49
|
+
0,2,4.008690750207941
|
50
|
+
1,0,6.000834122995382
|
51
|
+
1,5,6.573598255386801
|
52
|
+
2,0,4.008586653499848
|
53
|
+
2,3,4.2694018322732905
|
54
|
+
2,11,4.0201791556206405
|
55
|
+
3,2,4.271267755875735
|
56
|
+
3,4,2.3153741062577957
|
57
|
+
3,10,7.1333004801798925
|
58
|
+
4,3,2.317072228350169
|
59
|
+
4,5,9.99822520770989
|
60
|
+
4,8,9.651310705326
|
61
|
+
5,1,6.599517667370174
|
62
|
+
5,4,10.020702556347622
|
63
|
+
5,7,14.690955002063726
|
64
|
+
6,7,5.55216038110299
|
65
|
+
6,17,2.0622256872131777
|
66
|
+
7,5,14.824159517828813
|
67
|
+
7,6,5.5014129625630845
|
68
|
+
7,8,15.17470751467586
|
69
|
+
7,15,10.729473525552692
|
70
|
+
8,4,9.670154559500556
|
71
|
+
8,7,15.03786950444767
|
72
|
+
8,9,5.682533051602025
|
73
|
+
9,8,5.717243386296829
|
74
|
+
9,10,12.405689451182845
|
75
|
+
9,14,13.722370282505468
|
76
|
+
9,15,20.084809978398383
|
77
|
+
9,16,16.308017150740422
|
78
|
+
10,3,7.223024555194135
|
79
|
+
10,9,12.203254534036494
|
80
|
+
10,11,13.590227634461067
|
81
|
+
10,13,13.691285688495954
|
82
|
+
11,2,4.019790487445956
|
83
|
+
11,10,13.735155648868584
|
84
|
+
11,12,3.022796543682372
|
85
|
+
12,11,3.023479671561587
|
86
|
+
12,23,17.661007722734873
|
87
|
+
13,10,13.842645045035516
|
88
|
+
13,14,12.23433912804607
|
89
|
+
13,22,9.079344311718367
|
90
|
+
14,9,13.811560451025963
|
91
|
+
14,13,12.374604857173304
|
92
|
+
14,18,4.326212079332104
|
93
|
+
14,21,9.08814367305963
|
94
|
+
15,7,10.778811570380917
|
95
|
+
15,9,20.236275698759837
|
96
|
+
15,16,9.501458490999475
|
97
|
+
15,17,3.1634648042599296
|
98
|
+
16,9,16.308017150740422
|
99
|
+
16,15,9.472854415655233
|
100
|
+
16,18,7.436626799094368
|
101
|
+
17,6,2.063186385018009
|
102
|
+
17,15,3.1658348757764214
|
103
|
+
17,19,4.2593710873324016
|
104
|
+
18,14,4.335530792063869
|
105
|
+
18,16,7.41227403532956
|
106
|
+
18,19,9.459063508153196
|
107
|
+
19,17,4.260230067055197
|
108
|
+
19,18,9.515249398501572
|
109
|
+
19,20,8.165660812781299
|
110
|
+
19,21,7.713130000305229
|
111
|
+
20,19,8.081635689665607
|
112
|
+
20,21,4.213505826088517
|
113
|
+
20,23,11.924059828422909
|
114
|
+
21,14,9.057167182746477
|
115
|
+
21,19,7.713130000305229
|
116
|
+
21,20,4.201049855811011
|
117
|
+
21,22,12.36580549583202
|
118
|
+
22,13,9.065966544087727
|
119
|
+
22,21,12.243138489387317
|
120
|
+
22,23,3.759304188401893
|
121
|
+
23,12,17.617020723058587
|
122
|
+
23,20,11.752579405401582
|
123
|
+
23,22,3.722946742102766"""
|
124
|
+
)
|
125
|
+
graph_edges = pd.read_csv(
|
126
|
+
siouxfalls_graph_edges_csv,
|
127
|
+
sep=",",
|
128
|
+
dtype={"tail": np.uint32, "head": np.uint32, "trav_time": np.float64},
|
129
|
+
)
|
130
|
+
return graph_edges
|
131
|
+
|
132
|
+
|
133
|
+
def create_sf_network(dwell_time=1.0e-6, board_alight_ratio=0.5):
|
134
|
+
"""
|
135
|
+
Example network from Spiess, H. and Florian, M. (1989).
|
136
|
+
Optimal strategies: A new assignment model for transit networks.
|
137
|
+
Transportation Research Part B 23(2), 83-102.
|
138
|
+
|
139
|
+
This network has 13 vertices and 24 edges.
|
140
|
+
"""
|
141
|
+
|
142
|
+
boarding_time = board_alight_ratio * dwell_time
|
143
|
+
alighting_time = board_alight_ratio * dwell_time
|
144
|
+
|
145
|
+
line1_freq = 1.0 / (60.0 * 12.0)
|
146
|
+
line2_freq = 1.0 / (60.0 * 12.0)
|
147
|
+
line3_freq = 1.0 / (60.0 * 30.0)
|
148
|
+
line4_freq = 1.0 / (60.0 * 6.0)
|
149
|
+
|
150
|
+
# stop A
|
151
|
+
# 0 stop vertex
|
152
|
+
# 1 boarding vertex64
|
153
|
+
# 2 boarding vertex
|
154
|
+
|
155
|
+
# stop X
|
156
|
+
# 3 stop vertex
|
157
|
+
# 4 boarding vertex
|
158
|
+
# 5 alighting vertex
|
159
|
+
# 6 boarding vertex
|
160
|
+
|
161
|
+
# stop Y
|
162
|
+
# 7 stop vertex
|
163
|
+
# 8 boarding vertex
|
164
|
+
# 9 alighting vertex
|
165
|
+
# 10 boarding vertex
|
166
|
+
# 11 alighting vertex
|
167
|
+
|
168
|
+
# stop B
|
169
|
+
# 12 stop vertex
|
170
|
+
# 13 alighting vertex
|
171
|
+
# 14 alighting vertex
|
172
|
+
# 15 alighting vertex
|
173
|
+
|
174
|
+
tail = []
|
175
|
+
head = []
|
176
|
+
trav_time = []
|
177
|
+
freq = []
|
178
|
+
vol = []
|
179
|
+
|
180
|
+
# edge 0
|
181
|
+
# stop A : to line 1
|
182
|
+
# boarding edge
|
183
|
+
tail.append(0)
|
184
|
+
head.append(2)
|
185
|
+
freq.append(line1_freq)
|
186
|
+
trav_time.append(boarding_time)
|
187
|
+
vol.append(0.5)
|
188
|
+
|
189
|
+
# edge 1
|
190
|
+
# stop A : to line 2
|
191
|
+
# boarding edge
|
192
|
+
tail.append(0)
|
193
|
+
head.append(1)
|
194
|
+
freq.append(line2_freq)
|
195
|
+
trav_time.append(boarding_time)
|
196
|
+
vol.append(0.5)
|
197
|
+
|
198
|
+
# edge 2
|
199
|
+
# line 1 : first segment
|
200
|
+
# on-board edge
|
201
|
+
tail.append(2)
|
202
|
+
head.append(15)
|
203
|
+
freq.append(np.inf)
|
204
|
+
trav_time.append(25.0 * 60.0)
|
205
|
+
vol.append(0.5)
|
206
|
+
|
207
|
+
# edge 3
|
208
|
+
# line 2 : first segment
|
209
|
+
# on-board edge
|
210
|
+
tail.append(1)
|
211
|
+
head.append(5)
|
212
|
+
freq.append(np.inf)
|
213
|
+
trav_time.append(7.0 * 60.0)
|
214
|
+
vol.append(0.5)
|
215
|
+
|
216
|
+
# edge 4
|
217
|
+
# stop X : from line 2
|
218
|
+
# alighting edge
|
219
|
+
tail.append(5)
|
220
|
+
head.append(3)
|
221
|
+
freq.append(np.inf)
|
222
|
+
trav_time.append(alighting_time)
|
223
|
+
vol.append(0.0)
|
224
|
+
|
225
|
+
# edge 5
|
226
|
+
# stop X : in line 2
|
227
|
+
# dwell edge
|
228
|
+
tail.append(5)
|
229
|
+
head.append(6)
|
230
|
+
freq.append(np.inf)
|
231
|
+
trav_time.append(dwell_time)
|
232
|
+
vol.append(0.5)
|
233
|
+
|
234
|
+
# edge 6
|
235
|
+
# stop X : from line 2 to line 3
|
236
|
+
# transfer edge
|
237
|
+
tail.append(5)
|
238
|
+
head.append(4)
|
239
|
+
freq.append(line3_freq)
|
240
|
+
trav_time.append(dwell_time)
|
241
|
+
vol.append(0.0)
|
242
|
+
|
243
|
+
# edge 7
|
244
|
+
# stop X : to line 2
|
245
|
+
# boarding edge
|
246
|
+
tail.append(3)
|
247
|
+
head.append(6)
|
248
|
+
freq.append(line2_freq)
|
249
|
+
trav_time.append(boarding_time)
|
250
|
+
vol.append(0.0)
|
251
|
+
|
252
|
+
# edge 8
|
253
|
+
# stop X : to line 3
|
254
|
+
# boarding edge
|
255
|
+
tail.append(3)
|
256
|
+
head.append(4)
|
257
|
+
freq.append(line3_freq)
|
258
|
+
trav_time.append(boarding_time)
|
259
|
+
vol.append(0.0)
|
260
|
+
|
261
|
+
# edge 9
|
262
|
+
# line 2 : second segment
|
263
|
+
# on-board edge
|
264
|
+
tail.append(6)
|
265
|
+
head.append(11)
|
266
|
+
freq.append(np.inf)
|
267
|
+
trav_time.append(6.0 * 60.0)
|
268
|
+
vol.append(0.5)
|
269
|
+
|
270
|
+
# edge 10
|
271
|
+
# line 3 : first segment
|
272
|
+
# on-board edge
|
273
|
+
tail.append(4)
|
274
|
+
head.append(9)
|
275
|
+
freq.append(np.inf)
|
276
|
+
trav_time.append(4.0 * 60.0)
|
277
|
+
vol.append(0.0)
|
278
|
+
|
279
|
+
# edge 11
|
280
|
+
# stop Y : from line 3
|
281
|
+
# alighting edge
|
282
|
+
tail.append(9)
|
283
|
+
head.append(7)
|
284
|
+
freq.append(np.inf)
|
285
|
+
trav_time.append(alighting_time)
|
286
|
+
vol.append(0.0)
|
287
|
+
|
288
|
+
# edge 12
|
289
|
+
# stop Y : from line 2
|
290
|
+
# alighting edge
|
291
|
+
tail.append(11)
|
292
|
+
head.append(7)
|
293
|
+
freq.append(np.inf)
|
294
|
+
trav_time.append(alighting_time)
|
295
|
+
vol.append(0.0)
|
296
|
+
|
297
|
+
# edge 13
|
298
|
+
# stop Y : from line 2 to line 3
|
299
|
+
# transfer edge
|
300
|
+
tail.append(11)
|
301
|
+
head.append(10)
|
302
|
+
freq.append(line3_freq)
|
303
|
+
trav_time.append(dwell_time)
|
304
|
+
vol.append(0.0833333333333)
|
305
|
+
|
306
|
+
# edge 14
|
307
|
+
# stop Y : from line 2 to line 4
|
308
|
+
# transfer edge
|
309
|
+
tail.append(11)
|
310
|
+
head.append(8)
|
311
|
+
freq.append(line4_freq)
|
312
|
+
trav_time.append(dwell_time)
|
313
|
+
vol.append(0.4166666666666)
|
314
|
+
|
315
|
+
# edge 15
|
316
|
+
# stop Y : from line 3 to line 4
|
317
|
+
# transfer edge
|
318
|
+
tail.append(9)
|
319
|
+
head.append(8)
|
320
|
+
freq.append(line4_freq)
|
321
|
+
trav_time.append(dwell_time)
|
322
|
+
vol.append(0.0)
|
323
|
+
|
324
|
+
# edge 16
|
325
|
+
# stop Y : in line 3
|
326
|
+
# dwell edge
|
327
|
+
tail.append(9)
|
328
|
+
head.append(10)
|
329
|
+
freq.append(np.inf)
|
330
|
+
trav_time.append(dwell_time)
|
331
|
+
vol.append(0.0)
|
332
|
+
|
333
|
+
# edge 17
|
334
|
+
# stop Y : to line 3
|
335
|
+
# boarding edge
|
336
|
+
tail.append(7)
|
337
|
+
head.append(10)
|
338
|
+
freq.append(line3_freq)
|
339
|
+
trav_time.append(boarding_time)
|
340
|
+
vol.append(0.0)
|
341
|
+
|
342
|
+
# edge 18
|
343
|
+
# stop Y : to line 4
|
344
|
+
# boarding edge
|
345
|
+
tail.append(7)
|
346
|
+
head.append(8)
|
347
|
+
freq.append(line4_freq)
|
348
|
+
trav_time.append(boarding_time)
|
349
|
+
vol.append(0.0)
|
350
|
+
|
351
|
+
# edge 19
|
352
|
+
# line 3 : second segment
|
353
|
+
# on-board edge
|
354
|
+
tail.append(10)
|
355
|
+
head.append(14)
|
356
|
+
freq.append(np.inf)
|
357
|
+
trav_time.append(4.0 * 60.0)
|
358
|
+
vol.append(0.0833333333333)
|
359
|
+
|
360
|
+
# edge 20
|
361
|
+
# line 4 : first segment
|
362
|
+
# on-board edge
|
363
|
+
tail.append(8)
|
364
|
+
head.append(13)
|
365
|
+
freq.append(np.inf)
|
366
|
+
trav_time.append(10.0 * 60.0)
|
367
|
+
vol.append(0.4166666666666)
|
368
|
+
|
369
|
+
# edge 21
|
370
|
+
# stop Y : from line 1
|
371
|
+
# alighting edge
|
372
|
+
tail.append(15)
|
373
|
+
head.append(12)
|
374
|
+
freq.append(np.inf)
|
375
|
+
trav_time.append(alighting_time)
|
376
|
+
vol.append(0.5)
|
377
|
+
|
378
|
+
# edge 22
|
379
|
+
# stop Y : from line 3
|
380
|
+
# alighting edge
|
381
|
+
tail.append(14)
|
382
|
+
head.append(12)
|
383
|
+
freq.append(np.inf)
|
384
|
+
trav_time.append(alighting_time)
|
385
|
+
vol.append(0.0833333333333)
|
386
|
+
|
387
|
+
# edge 23
|
388
|
+
# stop Y : from line 4
|
389
|
+
# alighting edge
|
390
|
+
tail.append(13)
|
391
|
+
head.append(12)
|
392
|
+
freq.append(np.inf)
|
393
|
+
trav_time.append(alighting_time)
|
394
|
+
vol.append(0.4166666666666)
|
395
|
+
|
396
|
+
edges = pd.DataFrame(
|
397
|
+
data={
|
398
|
+
"tail": tail,
|
399
|
+
"head": head,
|
400
|
+
"trav_time": trav_time,
|
401
|
+
"freq": freq,
|
402
|
+
"volume_ref": vol,
|
403
|
+
}
|
404
|
+
)
|
405
|
+
# waiting time is in average half of the period
|
406
|
+
edges["freq"] *= 2.0
|
407
|
+
|
408
|
+
return edges
|
409
|
+
|
410
|
+
|
411
|
+
# author : Francois Pacull
|
412
|
+
# copyright : Architecture & Performance
|
413
|
+
# email: francois.pacull@architecture-performance.fr
|
414
|
+
# license : MIT
|