Revision 05763cfb

View differences:

execMany.sh
1

  
2
#!/bin/sh
3
# This is a comment!
4
echo Hello World    # This is a comment, too!
5

  
6
## declare an array variable
7
declare -a arr=("NN50RAY10" "NN50RAY15" "NN50RAY20" "NN50RAY25" "NN50RAY30" "NN50RAY35" "NN50RAY40" "NN50RAY45" "NN100RAY10" "NN100RAY15" "NN100RAY20" "NN100RAY25" "NN100RAY30" "NN100RAY35" "NN100RAY40" "NN100RAY45" "NN250RAY10" "NN250RAY15" "NN250RAY20" "NN250RAY25" "NN250RAY30" "NN250RAY35" "NN250RAY40" "NN250RAY45" "NN500RAY10" "NN500RAY15" "NN500RAY20" "NN500RAY25" "NN500RAY30" "NN500RAY35" "NN500RAY40" "NN500RAY45" "NN750RAY10" "NN750RAY15" "NN750RAY20" "NN750RAY25" "NN750RAY30" "NN750RAY35" "NN750RAY40" "NN750RAY45" "NN1000RAY10" "NN1000RAY15" "NN1000RAY20" "NN1000RAY25" "NN1000RAY30" "NN1000RAY35" "NN1000RAY40" "NN1000RAY45")
8
for e in "${arr[@]}"
9
do
10
    python mobiExp.py --sf settings/distrib.ini --en "$e" --out out --thr 3
11
done
mobiExp.py
43 43
                if os.path.exists(cdir):
44 44
                    shutil.rmtree(cdir)
45 45
                os.makedirs(cdir)
46
                os.makedirs(cdir+'/topos')
46 47
        if opt in ('--gui'):
47 48
            gui = True
48 49

  
sampleACF.py
29 29
os.chdir(folder)
30 30

  
31 31

  
32

  
33 32
'''def nistRH(v, h):
34 33
    N, mu, var = len(v), np.mean(v), np.var(v)
35 34
    Ch = 0.0
......
72 71

  
73 72
rankbcdf = pd.DataFrame()
74 73
for t in range(0, len(bcdf)):
75
    r=bcdf.iloc[t].rank(method='first', ascending=False).reset_index(drop=True)
74
    r = bcdf.iloc[t].rank(
75
        method='first', ascending=False).reset_index(drop=True)
76 76
    rankbcdf = rankbcdf.append(r, ignore_index=True)
77 77

  
78
    
79 78

  
80 79
nodes = range(len(bcdf.columns))
81 80

  
......
108 107
    coreNodes = [int(e[0]) for e in srtd_BC[:upto]]
109 108
    return coreNodes
110 109

  
111
def jaccard_top_CF(maxt=100, nlags=20, perc=5):
112
    N = maxt
113
    memoSet = {}
114
    for i in range(0, N):
115
        memoSet[i] = topNodes(i, perc)
116
    retval = []
117
    for tau in range(0, nlags):
118
        jtau = 0.0
119
        for t in range(0, N - tau):
120
            jtau += jaccard_similarity(memoSet[t], memoSet[t+tau])
121
        jtau /= N - tau
122
        retval.append(jtau)
123
    return retval
124 110

  
125
def jaccard_tail_CF(maxt=100, nlags=20, perc=5):
111
def jaccard_CF(start=0, maxt=100, nlags=20, perc=5, top=True):
126 112
    N = maxt
127 113
    memoSet = {}
128 114
    for i in range(0, N):
129
        memoSet[i] = tailNodes(i, perc)
115
        if top:
116
            memoSet[i] = topNodes(start+i, perc)
117
        else:
118
            memoSet[i] = tailNodes(start+i, perc)
130 119
    retval = []
131
    for tau in range(0, nlags):
120
    for tau in range(0, nlags+1):
132 121
        jtau = 0.0
133 122
        for t in range(0, N - tau):
134 123
            jtau += jaccard_similarity(memoSet[t], memoSet[t+tau])
135 124
        jtau /= N - tau
136 125
        retval.append(jtau)
137 126
    return retval
138
p = 2
127

  
128

  
129
#code.interact(local=dict(globals(), **locals()))
130

  
131
colors = iter(['k', 'r', 'b', 'g', 'y', 'c'])
132
styles = iter(['s', 'o', '^', '*', 'p'])
133
p = 5
134
for klen in [25, 50, 100, 200, 500]:
135
    pd.Series(jaccard_CF(start=0, maxt=klen, perc=p, top=True)).plot.line(
136
        label='N='+str(klen), style=next(colors)+next(styles)+'-')
137

  
138
plt.legend()
139
plt.xticks(range(0,21))
140
plt.yticks(np.arange(0,1.0,0.1))
141
plt.grid()
142
plt.ylim(0, 1.0)
143
plt.title("start=t0")
144
plt.xlabel('Tau')
145
plt.ylabel('Jaccard Correlation')
146
plt.savefig(nick+"jaccard_ACF_changingN.pdf", format='pdf')
147
plt.clf()
148
#plt.show()
149

  
150
colors = iter(['k', 'r', 'b', 'g', 'y', 'c'])
151
styles = iter(['s', 'o', '^', '*', 'p'])
152
p = 5
153
for s in [0, 50, 100, 200, 500]:
154
    pd.Series(jaccard_CF(start=s, maxt=50, perc=p, top=True)).plot.line(
155
        label='start='+str(s), style=next(colors)+next(styles)+'-')
156

  
157
plt.legend()
158
plt.xticks(range(0,21))
159
plt.yticks(np.arange(0,1.0,0.1))
160
plt.grid()
161
plt.title("N=50")
162
plt.xlabel('Tau')
163
plt.ylabel('Jaccard Correlation')
164
plt.ylim(0, 1.0)
165
plt.savefig(nick+"jaccard_ACF_changingSTART.pdf", format='pdf')
166
plt.clf()
167

  
168
perc = 20
169
t0 = topNodes(0, perc)
170
l0 = [jaccard_similarity(t0, topNodes(t, perc)) for t in range(1, 70)]
171
t100 = topNodes(100, perc)
172
l100 = [jaccard_similarity(t100, topNodes(100+t, perc)) for t in range(1, 70)]
173
t500 = topNodes(500, perc)
174
l500 = [jaccard_similarity(t500, topNodes(500+t, perc)) for t in range(1, 70)]
175
t750 = topNodes(750, perc)
176
l750 = [jaccard_similarity(t750, topNodes(750+t, perc)) for t in range(1, 70)]
177

  
178
pd.Series(l0).plot(label="start = t0", linewidth=1.5)
179
pd.Series(l100).plot(label="start = t100", linewidth=1.5)
180
pd.Series(l500).plot(label="start = t500", linewidth=1.5)
181
pd.Series(l750).plot(label="start = t750", linewidth=1.5)
182
plt.ylabel("Jaccard Similarity")
183
plt.xlabel("tau")
184
plt.title("Top Set size = "+str(len(t0))+", "+str(perc)+"% of nodes")
185
plt.legend()
186
plt.xticks(range(0,70,5))
187
plt.yticks(np.arange(0,1.1,0.1))
188
plt.ylim(-0.02,1.02)
189
plt.grid()
190
plt.savefig(nick+"jaccard_scaletta.pdf", format='pdf')
191
plt.clf()
192
#t0 = [jaccard_similarity(topNodes(t, perc), topNodes(t+1, perc)) for t in range(0,100)]
193

  
194

  
195
'''p = 80
139 196
pd.Series(jaccard_top_CF(perc=p)).plot(label='Top')
140 197
pd.Series(jaccard_tail_CF(perc=p)).plot(label='Tail')
198
plt.ylabel("Jaccard Similarity")
141 199
plt.legend()
142 200
plt.savefig(nick+"Jaccard-tau1-perc="+str(p)+".pdf", format='pdf')
143 201
plt.clf()
......
152 210

  
153 211
for t in range(0,100):
154 212
    x,y=tailNodes(t,15), tailNodes(t+1,15)
155
    jtail1.append(jaccard_similarity(x,y))
156

  
213
    jtail1.append(jaccard_similarity(x,y))'''
157 214

  
158 215

  
159 216
'''for i in range(k, k+memoryMax):
......
192 249
    tailRSeries = rankbcdf.iloc[:, tailn][t:t+klim]
193 250
    tailRacf = acf(tailRSeries, nlags=memoryMax, unbiased=True, fft=True)
194 251

  
195
    acTop[t]=topacf
196
    acTail[t]=tailacf
197
    acTopRank[t]=topRacf
198
    acTailRank[t]=tailRacf
252
    acTop[t] = topacf
253
    acTail[t] = tailacf
254
    acTopRank[t] = topRacf
255
    acTailRank[t] = tailRacf
199 256

  
200
acTopDF=pd.DataFrame(acTop)
201
acTailDF=pd.DataFrame(acTail)
257
acTopDF = pd.DataFrame(acTop)
258
acTailDF = pd.DataFrame(acTail)
202 259

  
203 260
acTopDF.T.mean().plot(label='Top')
204 261
acTailDF.T.mean().plot(label='Tail')
205
plt.ylim(-1,1)
262
plt.ylim(-1, 1)
206 263
plt.ylabel('ACF...')
207 264
plt.xlabel('Tau')
208 265
plt.legend()
209 266
plt.grid()
210 267
plt.savefig(nick+"ACFtopVSTail.pdf", format='pdf')
211 268
plt.clf()
212
#plt.show()
269
# plt.show()
213 270

  
214
acTopRDF=pd.DataFrame(acTopRank)
215
acTailRDF=pd.DataFrame(acTailRank)
271
acTopRDF = pd.DataFrame(acTopRank)
272
acTailRDF = pd.DataFrame(acTailRank)
216 273

  
217 274
acTopRDF.T.mean().plot(label='TopR')
218 275
acTailRDF.T.mean().plot(label='TailR')
219
plt.ylim(-1,1)
276
plt.ylim(-1, 1)
220 277
plt.ylabel('ACF_rank...')
221 278
plt.xlabel('Tau')
222 279
plt.legend()
......
233 290
plt.xlabel('Time')
234 291
plt.savefig(nick+"topVStailExample.pdf", format='pdf')
235 292
plt.clf()
236
#plt.show()
293
# plt.show()
237 294

  
238
rankbcdf.iloc[:,topn][t:t+klim].plot(label='TopRank')
239
rankbcdf.iloc[:,tailn][t:t+klim].plot(label='TailRank')
295
rankbcdf.iloc[:, topn][t:t+klim].plot(label='TopRank')
296
rankbcdf.iloc[:, tailn][t:t+klim].plot(label='TailRank')
240 297
plt.legend()
241 298
plt.ylabel('Rank (1==HighestBC)')
242 299
plt.xlabel('Time')
243 300
plt.grid()
244 301
plt.savefig(nick+"topVStailRankExample.pdf", format='pdf')
245 302
plt.clf()
246
#plt.show()
303
# plt.show()
247 304

  
248 305

  
249 306
time2top = {}
250 307
time2tail = {}
251 308

  
252
#code.interact(local=dict(globals(), **locals()))
253 309

  
254 310
'''# Per tanti istanti di inizio detti k
255 311
for k in tqdm(range(1, klim)):
settings.ini
1
[baseRPG]
2
duration = 1000s
3
nodes_x_group = 5
4
groups_number = 20
5
max_x = 100
6
max_y = 100
7
min_velocity = 0.1
8
max_velocity = 1.0
9
aggregation = 0.1
10
radius = 30.0
11
mobility_timer = 1s
12
mob_model = ReferencePointGroup
13

  
14
[rpgAGG2:baseRPG]
15
aggregation = 0.2
16

  
17
[rpgAGG5:baseRPG]
18
aggregation = 0.5
19

  
20
[rpgAGG7:baseRPG]
21
aggregation = 0.7
22

  
23
[rpgAGG9:baseRPG]
24
aggregation = 0.9
25

  
26

  
27
[milano]
28
duration = 100s
29
nodes_number = 1000
30
max_x = 100
31
max_y = 100
32
radius = 30.0
33
mobility_timer = 1s
34
mob_model = Milan
35

  
36
[baseRWP]
37
duration = 100s
38
nodes_number = 50
39
max_x = 100
40
max_y = 100
41
min_velocity = 0.1
42
max_velocity = 1.0
43
radius = 30.0
44
mobility_timer = 1s
45
mob_model = RandomWayPoint
46
max_wait_time = 0.0
47

  
48
[baseTVCM]
49
duration = 10000s
50
mobility_timer = 1s
51
mob_model = TimeVariantCommunity
52
nodes_x_group = 5
53
groups_number = 10
54
max_x = 100
55
max_y = 100
56
min_velocity = 0.01
57
max_velocity = 1.0
58
radius = 20.0
59

  
60
# RandomWayPoint exps
61

  
62
# Molti nodi Raggio 30
63
[rwpR30N250:baseRWP]
64
nodes_number = 250
65
radius = 30.0
66

  
67
[rwpR30N500:baseRWP]
68
nodes_number = 500
69
radius = 30.0
70

  
71
[rwpR30N750:baseRWP]
72
nodes_number = 750
73
radius = 30.0
74

  
75

  
76
# 50 nodi
77
[rwpR30N50.0:baseRWP]
78
nodes_number = 50
79
radius = 30.0
80

  
81
[rwpR20N50:baseRWP]
82
nodes_number = 50
83
radius = 20.0
84

  
85
[rwpR10N50:baseRWP]
86
nodes_number = 50
87
radius = 10.0
88

  
89
# 100 nodi
90
[rwpR30N100:baseRWP]
91
nodes_number = 100
92
radius = 30.0
93

  
94
[rwpR20N100:baseRWP]
95
nodes_number = 100
96
radius = 20.0
97

  
98
[rwpR10N100:baseRWP]
99
nodes_number = 100
100
radius = 10.0
101

  
102
# 30 nodi
103
[rwpR30N30:baseRWP]
104
nodes_number = 30
105
radius = 30.0
106

  
107
[rwpR20N30:baseRWP]
108
nodes_number = 30
109
radius = 20.0
110

  
111
[rwpR10N30:baseRWP]
112
nodes_number = 30
113
radius = 10.0
114

  
115
[rwpR5N30:baseRWP]
116
nodes_number = 30
117
radius = 5.0
118

  
119

  
120
# Time-Variant-Community Model
121

  
122
[tvcmR30:baseTVCM]
123
radius = 30.0
124

  
125
[tvcmR20:baseTVCM]
126
radius = 20.0
127

  
128
[tvcmR10:baseTVCM]
129
radius = 10.0
130

  
settings/distrib.ini
1
[base]
2
duration = 300s
3
mobility_timer = 1s
4
max_x = 100
5
max_y = 100
6
velocity = pedestrian
7
radius = 30.0
8
nodes_number = 250
9
nodes_x_group = 5
10
groups_number = 50
11

  
12
[mobRWP:base]
13
mob_model = RandomWayPoint
14
max_wait_time = 0.0
15

  
16
[baseRWP]
17
duration = 1s
18
nodes_number = 250
19
max_x = 100
20
max_y = 100
21
velocity = pedestrian
22
radius = 10.0
23
mobility_timer = 1s
24
mob_model = RandomWayPoint
25
max_wait_time = 0.0
26

  
27
# NNxRadius EXPs
28

  
29
## NN50 -> ray {10,15,20,25,30,35,40,45}
30
[NN50RAY10:baseRWP]
31
nodes_number = 50
32
radius = 10.0
33

  
34
[NN50RAY15:baseRWP]
35
nodes_number = 50
36
radius = 15.0
37

  
38
[NN50RAY20:baseRWP]
39
nodes_number = 50
40
radius = 20.0
41

  
42
[NN50RAY25:baseRWP]
43
nodes_number = 50
44
radius = 25.0
45

  
46
[NN50RAY30:baseRWP]
47
nodes_number = 50
48
radius = 30.0
49

  
50
[NN50RAY35:baseRWP]
51
nodes_number = 50
52
radius = 35.0
53

  
54
[NN50RAY40:baseRWP]
55
nodes_number = 50
56
radius = 40.0
57

  
58
[NN50RAY45:baseRWP]
59
nodes_number = 50
60
radius = 45.0
61

  
62
## NN100 -> ray {10,15,20,25,30,35,40,45}
63
[NN100RAY10:baseRWP]
64
nodes_number = 100
65
radius = 10.0
66

  
67
[NN100RAY15:baseRWP]
68
nodes_number = 100
69
radius = 15.0
70

  
71
[NN100RAY20:baseRWP]
72
nodes_number = 100
73
radius = 20.0
74

  
75
[NN100RAY25:baseRWP]
76
nodes_number = 100
77
radius = 25.0
78

  
79
[NN100RAY30:baseRWP]
80
nodes_number = 100
81
radius = 30.0
82

  
83
[NN100RAY35:baseRWP]
84
nodes_number = 100
85
radius = 35.0
86

  
87
[NN100RAY40:baseRWP]
88
nodes_number = 100
89
radius = 40.0
90

  
91
[NN100RAY45:baseRWP]
92
nodes_number = 100
93
radius = 45.0
94

  
95
## NN250 -> ray {10,15,20,25,30,35,40,45}
96
[NN250RAY10:baseRWP]
97
nodes_number = 250
98
radius = 10.0
99

  
100
[NN250RAY15:baseRWP]
101
nodes_number = 250
102
radius = 15.0
103

  
104
[NN250RAY20:baseRWP]
105
nodes_number = 250
106
radius = 20.0
107

  
108
[NN250RAY25:baseRWP]
109
nodes_number = 250
110
radius = 25.0
111

  
112
[NN250RAY30:baseRWP]
113
nodes_number = 250
114
radius = 30.0
115

  
116
[NN250RAY35:baseRWP]
117
nodes_number = 250
118
radius = 35.0
119

  
120
[NN250RAY40:baseRWP]
121
nodes_number = 250
122
radius = 40.0
123

  
124
[NN250RAY45:baseRWP]
125
nodes_number = 250
126
radius = 45.0
127

  
128
## NN500 -> ray {10,15,20,25,30,35,40,45}
129
[NN500RAY10:baseRWP]
130
nodes_number = 500
131
radius = 10.0
132

  
133
[NN500RAY15:baseRWP]
134
nodes_number = 500
135
radius = 15.0
136

  
137
[NN500RAY20:baseRWP]
138
nodes_number = 500
139
radius = 20.0
140

  
141
[NN500RAY25:baseRWP]
142
nodes_number = 500
143
radius = 25.0
144

  
145
[NN500RAY30:baseRWP]
146
nodes_number = 500
147
radius = 30.0
148

  
149
[NN500RAY35:baseRWP]
150
nodes_number = 500
151
radius = 35.0
152

  
153
[NN500RAY40:baseRWP]
154
nodes_number = 500
155
radius = 40.0
156

  
157
[NN500RAY45:baseRWP]
158
nodes_number = 500
159
radius = 45.0
160

  
161
## NN750 -> ray {10,15,20,25,30,35,40,45}
162
[NN750RAY10:baseRWP]
163
nodes_number = 750
164
radius = 10.0
165

  
166
[NN750RAY15:baseRWP]
167
nodes_number = 750
168
radius = 15.0
169

  
170
[NN750RAY20:baseRWP]
171
nodes_number = 750
172
radius = 20.0
173

  
174
[NN750RAY25:baseRWP]
175
nodes_number = 750
176
radius = 25.0
177

  
178
[NN750RAY30:baseRWP]
179
nodes_number = 750
180
radius = 30.0
181

  
182
[NN750RAY35:baseRWP]
183
nodes_number = 750
184
radius = 35.0
185

  
186
[NN750RAY40:baseRWP]
187
nodes_number = 750
188
radius = 40.0
189

  
190
[NN750RAY45:baseRWP]
191
nodes_number = 750
192
radius = 45.0
193

  
194
## NN1000 -> ray {10,15,20,25,30,35,40,45}
195
[NN1000RAY10:baseRWP]
196
nodes_number = 1000
197
radius = 10.0
198

  
199
[NN1000RAY15:baseRWP]
200
nodes_number = 1000
201
radius = 15.0
202

  
203
[NN1000RAY20:baseRWP]
204
nodes_number = 1000
205
radius = 20.0
206

  
207
[NN1000RAY25:baseRWP]
208
nodes_number = 1000
209
radius = 25.0
210

  
211
[NN1000RAY30:baseRWP]
212
nodes_number = 1000
213
radius = 30.0
214

  
215
[NN1000RAY35:baseRWP]
216
nodes_number = 1000
217
radius = 35.0
218

  
219
[NN1000RAY40:baseRWP]
220
nodes_number = 1000
221
radius = 40.0
222

  
223
[NN1000RAY45:baseRWP]
224
nodes_number = 1000
225
radius = 45.0
settings/settings.ini
1
[baseRPG]
2
duration = 1000s
3
nodes_x_group = 5
4
groups_number = 20
5
max_x = 100
6
max_y = 100
7
min_velocity = 0.1
8
max_velocity = 1.0
9
aggregation = 0.1
10
radius = 30.0
11
mobility_timer = 1s
12
mob_model = ReferencePointGroup
13

  
14
[rpgAGG2:baseRPG]
15
aggregation = 0.2
16

  
17
[rpgAGG5:baseRPG]
18
aggregation = 0.5
19

  
20
[rpgAGG7:baseRPG]
21
aggregation = 0.7
22

  
23
[rpgAGG9:baseRPG]
24
aggregation = 0.9
25

  
26

  
27
[milano]
28
duration = 100s
29
nodes_number = 1000
30
max_x = 100
31
max_y = 100
32
radius = 30.0
33
mobility_timer = 1s
34
mob_model = Milan
35

  
36
[baseRWP]
37
duration = 100s
38
nodes_number = 50
39
max_x = 100
40
max_y = 100
41
min_velocity = 0.1
42
max_velocity = 1.0
43
radius = 30.0
44
mobility_timer = 1s
45
mob_model = RandomWayPoint
46
max_wait_time = 0.0
47

  
48
[baseTVCM]
49
duration = 10000s
50
mobility_timer = 1s
51
mob_model = TimeVariantCommunity
52
nodes_x_group = 5
53
groups_number = 10
54
max_x = 100
55
max_y = 100
56
min_velocity = 0.01
57
max_velocity = 1.0
58
radius = 20.0
59

  
60
# RandomWayPoint exps
61

  
62
# Molti nodi Raggio 30
63
[rwpR30N250:baseRWP]
64
nodes_number = 250
65
radius = 30.0
66

  
67
[rwpR30N500:baseRWP]
68
nodes_number = 500
69
radius = 30.0
70

  
71
[rwpR30N750:baseRWP]
72
nodes_number = 750
73
radius = 30.0
74

  
75

  
76
# 50 nodi
77
[rwpR30N50.0:baseRWP]
78
nodes_number = 50
79
radius = 30.0
80

  
81
[rwpR20N50:baseRWP]
82
nodes_number = 50
83
radius = 20.0
84

  
85
[rwpR10N50:baseRWP]
86
nodes_number = 50
87
radius = 10.0
88

  
89
# 100 nodi
90
[rwpR30N100:baseRWP]
91
nodes_number = 100
92
radius = 30.0
93

  
94
[rwpR20N100:baseRWP]
95
nodes_number = 100
96
radius = 20.0
97

  
98
[rwpR10N100:baseRWP]
99
nodes_number = 100
100
radius = 10.0
101

  
102
# 30 nodi
103
[rwpR30N30:baseRWP]
104
nodes_number = 30
105
radius = 30.0
106

  
107
[rwpR20N30:baseRWP]
108
nodes_number = 30
109
radius = 20.0
110

  
111
[rwpR10N30:baseRWP]
112
nodes_number = 30
113
radius = 10.0
114

  
115
[rwpR5N30:baseRWP]
116
nodes_number = 30
117
radius = 5.0
118

  
119

  
120
# Time-Variant-Community Model
121

  
122
[tvcmR30:baseTVCM]
123
radius = 30.0
124

  
125
[tvcmR20:baseTVCM]
126
radius = 20.0
127

  
128
[tvcmR10:baseTVCM]
129
radius = 10.0
130

  
settings/setup.ini
1
# Impact of Mobility Model
2

  
3
[base]
4
duration = 10000s
5
mobility_timer = 1s
6
max_x = 100
7
max_y = 100
8
velocity = pedestrian
9
radius = 30.0
10
nodes_number = 250
11
nodes_x_group = 5
12
groups_number = 50
13

  
14
[mobRWP:base]
15
mob_model = RandomWayPoint
16
max_wait_time = 0.0
17

  
18
[mobRPG:base]
19
mob_model = ReferencePointGroup
20
aggregation = 0.5
21

  
22
[mobTLW:base]
23
mob_model = TruncatedLevyWalk
24

  
25
[mobGM:base]
26
mob_model = GaussMarkov
27
alpha = 0.9
28

  
29
[milano]
30
duration = 1000s
31
max_x = 100
32
max_y = 100
33
radius = 30.0
34
mobility_timer = 1s
35
mob_model = Milan
36

  
37

  
38

  
39
[baseRWP]
40
duration = 10000s
41
nodes_number = 250
42
max_x = 100
43
max_y = 100
44
velocity = pedestrian
45
radius = 10.0
46
mobility_timer = 1s
47
mob_model = RandomWayPoint
48
max_wait_time = 0.0
49

  
50
[baseRPG]
51
duration = 10000s
52
nodes_x_group = 10
53
groups_number = 20
54
max_x = 100
55
max_y = 100
56
velocity = pedestrian
57
aggregation = 0.5
58
radius = 30.0
59
mobility_timer = 1s
60
mob_model = ReferencePointGroup
61

  
62
[heatRPG:baseRPG]
63
duration = 2500
64
nodes_x_group = 25
65
groups_number = 10
66

  
67

  
68
# Impact of Radius
69
[ray20:baseRWP]
70
radius = 20.0
71

  
72
[ray25:baseRWP]
73
radius = 25.0
74

  
75
[ray30:baseRWP]
76
radius = 30.0
77

  
78
[ray35:baseRWP]
79
radius = 35.0
80

  
81
[ray40:baseRWP]
82
radius = 40.0
83

  
84
# Impact of Nodes' Density
85
[nn50:baseRWP]
86
nodes_number = 50
87
radius = 30
88
duration=1000
89

  
90
[nn100:baseRWP]
91
nodes_number = 100
92

  
93
[nn250:baseRWP]
94
nodes_number = 250
95

  
96
[nn500:baseRWP]
97
nodes_number = 500
98

  
99
[nn750:baseRWP]
100
nodes_number = 750
101

  
102
[nn1000:baseRWP]
103
nodes_number = 1000
104

  
105
[nn4000:baseRWP]
106
nodes_number = 4000
107

  
108

  
109
# Impacts of speed
110

  
111
[speed_slow:baseRWP]
112
velocity = slow
113

  
114
[speed_pedestrian:baseRWP]
115
velocity = pedestrian
116

  
117
[speed_jogging:baseRWP]
118
velocity = jogging
119

  
120
[speed_bike:baseRWP]
121
velocity = bike
122

  
123
[speed_citycar:baseRWP]
124
velocity = citycar
setup.ini
1
# Impact of Mobility Model
2

  
3
[base]
4
duration = 10000s
5
mobility_timer = 1s
6
max_x = 100
7
max_y = 100
8
velocity = pedestrian
9
radius = 30.0
10
nodes_number = 250
11
nodes_x_group = 5
12
groups_number = 50
13

  
14
[mobRWP:base]
15
mob_model = RandomWayPoint
16
max_wait_time = 0.0
17

  
18
[mobRPG:base]
19
mob_model = ReferencePointGroup
20
aggregation = 0.5
21

  
22
[mobTLW:base]
23
mob_model = TruncatedLevyWalk
24

  
25
[mobGM:base]
26
mob_model = GaussMarkov
27
alpha = 0.9
28

  
29
[milano]
30
duration = 1000s
31
max_x = 100
32
max_y = 100
33
radius = 30.0
34
mobility_timer = 1s
35
mob_model = Milan
36

  
37

  
38

  
39
[baseRWP]
40
duration = 10000s
41
nodes_number = 250
42
max_x = 100
43
max_y = 100
44
velocity = pedestrian
45
radius = 30.0
46
mobility_timer = 1s
47
mob_model = RandomWayPoint
48
max_wait_time = 0.0
49

  
50
[baseRPG]
51
duration = 10000s
52
nodes_x_group = 10
53
groups_number = 20
54
max_x = 100
55
max_y = 100
56
velocity = pedestrian
57
aggregation = 0.5
58
radius = 30.0
59
mobility_timer = 1s
60
mob_model = ReferencePointGroup
61

  
62
[heatRPG:baseRPG]
63
duration = 2500
64
nodes_x_group = 25
65
groups_number = 10
66

  
67

  
68
# Impact of Radius
69
[ray20:baseRWP]
70
radius = 20.0
71

  
72
[ray25:baseRWP]
73
radius = 25.0
74

  
75
[ray30:baseRWP]
76
radius = 30.0
77

  
78
[ray35:baseRWP]
79
radius = 35.0
80

  
81
[ray40:baseRWP]
82
radius = 40.0
83

  
84
# Impact of Nodes' Density
85
[nn50:baseRWP]
86
nodes_number = 50
87
radius = 30
88
duration=1000
89

  
90
[nn100:baseRWP]
91
nodes_number = 100
92

  
93
[nn250:baseRWP]
94
nodes_number = 250
95

  
96
[nn500:baseRWP]
97
nodes_number = 500
98

  
99
[nn750:baseRWP]
100
nodes_number = 750
101

  
102
[nn1000:baseRWP]
103
nodes_number = 1000
104

  
105
[nn4000:baseRWP]
106
nodes_number = 4000
107

  
108

  
109
# Impacts of speed
110

  
111
[speed_slow:baseRWP]
112
velocity = slow
113

  
114
[speed_pedestrian:baseRWP]
115
velocity = pedestrian
116

  
117
[speed_jogging:baseRWP]
118
velocity = jogging
119

  
120
[speed_bike:baseRWP]
121
velocity = bike
122

  
123
[speed_citycar:baseRWP]
124
velocity = citycar
simulator.py
14 14
import util.MyUtil as myu
15 15
from time import sleep
16 16
import time
17
import matplotlib.pyplot as plt
18
plt.ion()
19

  
20

  
21 17

  
22 18

  
23 19
def f(params):
......
27 23
    params['gtG'] = G
28 24
    params['nxG'] = nxG
29 25
    ws = G.edge_properties["weight"]
30
    vp, ep = gt.betweenness(G, norm=False, weight=ws)
26
    vp, ep = gt.betweenness(G, norm=True, weight=ws)
31 27
    btwd = {i: vp.a[i] for i in range(len(vp.a))}
32 28
    params['btw'] = btwd
33 29
    kcore = gt.kcore_decomposition(G)
......
60 56
        for i in range(NN):
61 57
            f = open(outPath+"/stats"+'%08d' % i+".csv", 'a+')
62 58
            self.statsFiles[i] = f
63
            f.write("Time,BC,DEG,KCORE\n")
59
            f.write("Time,BC,DEG,KCORE,X,Y\n")
64 60

  
65 61
    def batch_tasks(self, sched, mobi, num_workers=5):
66 62
        # prepare next num_workers tasks
......
97 93

  
98 94
                # Log results to disk
99 95
                for res in results:
100
                    #code.interact(local=dict(globals(), **locals()))
101 96
                    self.logRes(res, stats=['btw', 'deg', 'kcore'])
102 97

  
103 98
                if self.gui and self.num_workers == 1:
99
                    #code.interact(local=dict(globals(), **locals()))
104 100
                    res = results[0]
105 101
                    self.draw(res['nxG'], res['pos'], res['btw'])
102
                else:
103
                    self.draw(res['nxG'], res['pos'], res['btw'], saveFig=True,
104
                              path=self.OP+"/topos/topo"+str(res['tag'])+".pdf")
106 105

  
107 106
        # Main Loop End Here
108 107
        for f in self.statsFiles:
......
115 114
            btw = res['btw'][n]
116 115
            deg = res['deg'][n]
117 116
            kcore = res['kcore'][n]
117
            x, y = res['pos'][n]
118 118
            self.statsFiles[n].write(
119
                ",".join(map(str, [tag, btw, deg, kcore]))+"\n")
119
                ",".join(map(str, [tag, btw, deg, kcore, x, y]))+"\n")
120 120

  
121
    def draw(self, G, pos, measures=None):
121
    def draw(self, G, pos, measures=None, saveFig=False, path=None):
122 122
        xmax = self.params['max_x']
123 123
        ymax = self.params['max_y']
124
        myu.draw(G, pos, xmax, ymax, measures)
124
        myu.draw(G, pos, xmax, ymax, measures, saveFig=saveFig, path=path)
util/MyUtil.py
3 3
import networkx as nx 
4 4
import random as rnd
5 5
import matplotlib.pyplot as plt
6
plt.ion()
6

  
7 7
import matplotlib.colors as mcolors
8 8
import sys
9 9
import code  # code.interact(local=dict(globals(), **locals()))
10 10

  
11
def draw(G, pos, xmax, ymax, measures=None):
11
def draw(G, pos, xmax, ymax, measures=None, saveFig=False, path=None):
12
    fig = plt.figure()
12 13
    lay = {k:pos[k] for k in range(0,len(pos))}
13 14
    if not measures:
14
        measures = nx.betweenness_centrality(G, normalized = False, weight = 'weight', endpoints=True)
15
        measures = nx.betweenness_centrality(G, normalized = True, weight = 'weight', endpoints=True)
16

  
15 17
    measure_name = "Betweenness"
16
    nodes = nx.draw_networkx_nodes(G, lay, node_size=25, cmap=plt.cm.gnuplot2, 
17
                                   node_color=measures.values(),
18
                                   nodelist=measures.keys())
19
    nodes.set_norm(mcolors.SymLogNorm(linthresh=0.01, linscale=1))
18

  
19
    nodes = nx.draw_networkx_nodes(G, lay, node_size=50, cmap=plt.cm.Spectral, 
20
                                       node_color=measures.values(),
21
                                       nodelist=measures.keys())
22

  
23
    #nodes.set_norm(mcolors.SymLogNorm(linthresh=0.01, linscale=1))
24
    mes=measures.values()
25
    nodes.set_norm(mcolors.LogNorm(vmin=0.001, vmax=max(mes)))
26
    #nodes.set_norm(mcolors.LogNorm())
20 27

  
21 28
    edges = nx.draw_networkx_edges(G, lay)
22 29
    plt.title(measure_name)
23
    plt.colorbar(nodes)
24 30

  
31
    myticks=np.geomspace(start=0.001, stop=max(mes), num=7)
32
    cbar=plt.colorbar(nodes, ticks=myticks, label='Norm BC')
33
    cbar.ax.set_yticklabels(["{0:0.4f}".format(i) for i in myticks])
34
    #plt.colorbar(ticks=range(6), label='digit value')
35
    #plt.clim(-0.5, 5.5)
25 36
    plt.xlim(0, xmax)
26 37
    plt.ylim(0, ymax)
27
    
28
    plt.draw()
29
    plt.pause(0.01)
30
    plt.clf()
31
    #plt.show()
38
    plt.xticks(range(0,105,5))
39
    plt.yticks(range(0,105,5))
40
    plt.grid(which='both')
41
    if not saveFig:
42
        plt.ion()
43
        plt.draw()
44
        plt.pause(0.01)
45
        plt.clf()
46
    else:
47
        fig.savefig(path, format='pdf')
48
        #plt.clf()
49
        #plt.show()
32 50

  
33 51
def dictAlikes(d1, d2, perc):
34 52
	if (sorted(d1.keys()) != sorted(d2.keys())):
util/UnitDiskGraph.py
15 15
    return nsmallest(2, numbers)[-1]
16 16

  
17 17

  
18
def reconnectGraph(g, distM):
18
def reconnectGraph(g, nxG, distM):
19 19
    labels, hist=gt.label_components(g, directed=False)
20 20
    # While not only a single component
21 21
    while (not all(e==0 for e in labels.a)):
......
35 35
                    closest=second_smallest(dp)
36 36
                    near_neigh=[k for k in range(len(dp)) if dp[k]==closest][0]
37 37
                    g.add_edge(g.vertex(i), g.vertex(near_neigh))
38
                    
38 39
                    break   
39 40
        else:
40 41
            #iteratively attach the smallest compo to the closest
41 42
            #print "Separated Compo"
42
            #code.interact(local=dict(globals(), **locals()))
43 43
            d={k:len(v) for k,v in comp2nodes.items()}
44 44
            minCompoLabel=min(d, key=d.get)
45 45
            minCompo=comp2nodes[minCompoLabel]
......
55 55
                        nearest_dist = closest
56 56
                        couple=n,v
57 57
            g.add_edge(g.vertex(couple[0]), g.vertex(couple[1]))
58
            #code.interact(local=dict(globals(), **locals()))
58 59
            #print "Connecting %d--%d, which are %.04f distant" % (couple[0], couple[1], nearest_dist)
59 60

  
60 61
        labels, hist=gt.label_components(g, directed=False)
62
    #at the end reconnect also nxG graph
63
    for e in g.edges():
64
        if not nxG.has_edge(e.source(), e.target()):
65
            nxG.add_edge(int(str(e.source())), int(str(e.target())), weight=1.0)
61 66

  
62 67

  
63 68
class UnitDiskGraph:
......
100 105
        eprops = [self.gtG.ep["weight"]]
101 106
        self.gtG.add_edge_list(edges, eprops=eprops)
102 107
        #out=self.gtG.get_out_degrees(self.gtG.get_vertices())
103
        reconnectGraph(self.gtG, distM)
108
        reconnectGraph(self.gtG, self.nxG, distM)
104 109
            
105 110

  
106 111
    def getGraph(self):
107
        return self.gtG, self.nxG
108

  
109
    
110

  
111

  
112

  
113

  
114

  
115

  
112
        return self.gtG, self.nxG

Also available in: Unified diff