-
Notifications
You must be signed in to change notification settings - Fork 0
/
traveltimes.py
executable file
·189 lines (171 loc) · 4.96 KB
/
traveltimes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
__author__ = "Hippolyte Signargout"
__email__ = "[email protected]"
'''
'''
###Libraries
from __future__ import division
import argparse
import csv
import numpy as np
import igraph
import matplotlib.pyplot as plt
from math import *
#Functions
from utils import digits, spaces, areInside
from pyproj import Proj, transform
###Extract paths
highway=np.loadtxt('data/highway_links.csv') #Links for the highway
dev1=np.loadtxt('data/Paths/Green_South.csv', delimiter=',') #links for five deviations
dev2=np.loadtxt('data/Paths/Yellow_All.csv', delimiter=',')
dev3=np.loadtxt('data/Paths/Path1.csv', delimiter=',')
dev4=np.loadtxt('data/Paths/Path2.csv', delimiter=',')
dev5=np.loadtxt('data/Paths/Path3.csv', delimiter=',')
#extract data
azf=np.loadtxt("data/LA_net.csv", skiprows=1, delimiter=',')
##Initialize
traveltimes=[]
td1=[]
td4=[]
td3=[]
td2=[]
td5=[]
sraveltimes=[]
sd1=[]
sd4=[]
sd3=[]
sd2=[]
sd5=[]
#percentage for loop
for i in range (1,101): #percentage
###SHORTEST PATH
#dubflows=np.loadtxt('data/output/LAfix_output_ratio_1_routed_perc_'+str(i/100)+'.csv', delimiter=',') #Two different sources for the flow, uncomment the one you want
dubflows=np.loadtxt('data/output/New_FW_Heterogeneous_Demand_1/LA_output_ratio_1.0_routed_perc_'+str(i/100)+'.csv', delimiter=',')
####Compute travel times on all paths
totflows=[link[0]+link[1] for link in dubflows]
ttime=0
for j in highway:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
traveltimes.append(ttime)
ttime=0
for j in dev1:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
td1.append(ttime)
ttime=0
for j in dev2:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
td2.append(ttime)
ttime=0
for j in dev3:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
td3.append(ttime)
ttime=0
for j in dev4:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
td4.append(ttime)
ttime=0
for j in dev5:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
td5.append(ttime)
#if (i/5)==floor(i/5):
###WHOLE NETWORK
#dubflows=np.loadtxt('data/output/FW_Heterogeneous_Demand_1/LA_output_ratio_1.0_routed_perc_'+str(i/100)+'.csv', delimiter=',')
#totflows=np.loadtxt('data/output/iod_output_ratio_1_perc_'+str(i/100)+'.csv', delimiter=',')
totflows=np.loadtxt('data/output/LAfix_output_ratio_1_perc_'+str(i/100)+'.csv', delimiter=',') #yet another source, to put 2 on the graphix
#totflows=[link[0]+link[1] for link in dubflows]
ttime=0
for j in highway:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
sraveltimes.append(ttime)
ttime=0
for j in dev1:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
sd1.append(ttime)
ttime=0
for j in dev2:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
sd2.append(ttime)
ttime=0
for j in dev3:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
sd3.append(ttime)
ttime=0
for j in dev4:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
sd4.append(ttime)
ttime=0
for j in dev5:
j=int(j)
a0=azf[j][3]
a4=azf[j][7]
traveltimeminut=(a0+a4*totflows[j]**4)/60
ttime+=traveltimeminut
sd5.append(ttime)
######PLOT
nu=np.loadtxt('data/output/Travel_time_equalization.csv', skiprows=1, delimiter=',',usecols=3)
#fig,(g1, g2)= plt.subplots(1,2, sharey=True)
a, g1=plt.subplots(1,1)
g1.plot(traveltimes, c="r", label="I210")
g1.plot(td1, c="g", label="2")
g1.plot(td2, c="cyan", label="1")
g1.plot(td3, c="darkblue", label="1a")
g1.plot(td4, c="violet", label="1b")
g1.plot(td5, c="turquoise", label="1c")
g1.plot(nu, c='black', lw=2, label="Shortest Path")
g1.legend()
g1.grid(True)
g1.set_xlabel('Percentage of Routed Users (%)')
g1.set_ylabel('Travel Time (min)')
#g2.plot(sraveltimes, c="r")
#g2.plot(sd1, c="g")
#g2.plot(sd2, c="y")
#g2.plot(sd3, c="b")
#g2.plot(sd4, c="pink")
#g2.plot(sd5, c="brown")
#g2.grid(True)
#g2.set_xlabel('Percentage of Routed Users (%)')
#g2.set_ylabel('Travel Time (min)')
plt.show()