• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisãob76bd139649531e0d5bd0f6a9b1b53959639e085 (tree)
Hora2011-01-25 02:01:30
Autorlorenzo
Commiterlorenzo

Mensagem de Log

Modifications to various codes: new quantities saved in the gml networks and new functions for statistics and
visualizations in the R codes.

Mudança Sumário

Diff

diff -r 641076e85e9f -r b76bd1396495 Python-codes/iterate_pcap2gml.py
--- a/Python-codes/iterate_pcap2gml.py Tue Jan 18 13:43:52 2011 +0000
+++ b/Python-codes/iterate_pcap2gml.py Mon Jan 24 17:01:30 2011 +0000
@@ -9,14 +9,29 @@
99 import string
1010 import scipy as s
1111
12+from sociopatterns.loader import TagMapping
13+
14+M = TagMapping()
15+
16+f = open('tag_mapping_high_presence.dat')
17+for line in f:
18+ (mapped_id, orig_id, t1, t2, type) = string.split(line[:-1])
19+ mapped_id = int(mapped_id)
20+ orig_id = int(orig_id)
21+ t1 = int(t1)
22+ t2 = int(t2)
23+ M.add_mapping(orig_id, mapped_id, t1, t2)
24+f.close()
25+
26+
1227 # ================= CONFIGURE THESE PARAMETERS ==========================
1328 XXTEA_CRYPTO_KEY = ( 0xf6e103d4, 0x77a739f6, 0x65eecead, 0xa40543a9 )
1429 DECODE = 0
1530 EXPERIMENT = "OBG"
16-TAG_ID_MIN = 1000
17-TAG_ID_MAX = 2000
18-DELTAT = 20 # aggregation window
19-K_MAX = 5 # filter out all nodes with degree > K_MAX (useful for filtering away clusters of tags left together)
31+TAG_ID_MIN = 10
32+TAG_ID_MAX = +3000
33+DELTAT = 120 # aggregation window
34+K_MAX = 24 # filter out all nodes with degree > K_MAX (useful for filtering away clusters of tags left together)
2035 # =======================================================================
2136
2237 TAG_ID_SPAN = TAG_ID_MAX - TAG_ID_MIN
@@ -116,6 +131,9 @@
116131 edge_attr_list.append('%d' % (onoff[i,j] / float(cum_adj[i,j]) / 2.0) )
117132 edge_attr_list.append('%d' % time_first_seen[i,j])
118133 edge_attr_list.append('%d' % time_last_seen[i,j])
134+ edge_attr_list.append('%d' % (TAG_ID_MIN+i) )
135+ edge_attr_list.append('%d' % (TAG_ID_MIN+j) )
136+
119137 edge_attr_list.append("")
120138
121139 edge_label_list.append("edge")
@@ -130,6 +148,8 @@
130148 edge_label_list.append("intermittency")
131149 edge_label_list.append("first_seen")
132150 edge_label_list.append("last_seen")
151+ edge_label_list.append("node_A")
152+ edge_label_list.append("node_B")
133153 edge_label_list.append("]")
134154
135155
@@ -181,9 +201,15 @@
181201 print ("time_grid is", time_grid )
182202
183203 loader = Loader(sys.argv[1:-1], experiment=EXPERIMENT, decode=DECODE, xxtea_crypto_key=XXTEA_CRYPTO_KEY, load_contacts=1, unique_contacts=1, load_sightings=0,
184- start_time=time_grid[0], stop_time=time_grid[-1])
204+ mapping=M,start_time=time_grid[0], stop_time=time_grid[-1])
185205
186-analyzer = ContactGraphAnalyzer(loader, DELTAT, get_graph=False, get_adj=True, tag_id_min=TAG_ID_MIN, tag_id_max=TAG_ID_MAX, isolated_nodes=True, weighted=False)
206+# loader = Loader(sys.argv[1:], decode=0,experiment='OBG',load_contacts=1, unique_contacts=1, load_sightings=0, mapping=M)
207+
208+
209+# analyzer = ContactGraphAnalyzer(loader, DELTAT, get_graph=False, get_adj=True, tag_id_min=TAG_ID_MIN, tag_id_max=TAG_ID_MAX, isolated_nodes=True, weighted=False)
210+
211+analyzer = ContactGraphAnalyzer(loader, DELTAT, get_graph=False, get_adj=True, tag_id_min=TAG_ID_MIN, tag_id_max=TAG_ID_MAX, isolated_nodes=True, weighted=True)
212+
187213
188214
189215 count_day=1
diff -r 641076e85e9f -r b76bd1396495 R-codes/big_boxplot.R
--- a/R-codes/big_boxplot.R Tue Jan 18 13:43:52 2011 +0000
+++ b/R-codes/big_boxplot.R Mon Jan 24 17:01:30 2011 +0000
@@ -69,6 +69,8 @@
6969 }
7070
7171
72+extra_norm <- c()
73+
7274 original <- read.table("frequencies_extended.dat", header=TRUE)
7375 names(original) <- c("role","freq", "norm", "count_norm")
7476
@@ -83,7 +85,29 @@
8385
8486 freq_complete <- c(original$freq,extra_freq)
8587
86-norm_complete <- c(original$norm, extra_freq)
88+
89+n_ij <- read.table("n_ij.dat", header=TRUE)
90+
91+n_ij$role <- levels(n_ij$role)[n_ij$role]
92+
93+
94+for (i in seq(length(extra_roles))){
95+
96+add_role <- extra_roles[i]
97+
98+sel <- which(n_ij$role==add_role)
99+
100+extra_norm <- c(extra_norm, n_ij$norm[sel])
101+
102+}
103+
104+
105+## norm_complete <- c(original$norm, extra_freq)
106+
107+norm_complete <- c(original$norm, extra_norm)
108+
109+
110+
87111
88112 count_norm_complete <- c(original$count_norm, extra_freq)
89113
@@ -1237,7 +1261,7 @@
12371261 ## scale_y_continuous( trans="log10", limits=c(.1,3500), breaks=mb, labels=my_label2## ,expand = c(0.01,0.01)
12381262 ## )+
12391263
1240-scale_y_continuous(limits=c(0,0.0025), breaks=seq(0,0.0025, by=0.0005))+
1264+scale_y_continuous(limits=c(0,0.026), breaks=seq(0,0.025, by=0.005))+
12411265
12421266 ## scale_y_continuous( trans="log10", limits=c(.1,3500), breaks=mb, labels=my_label2)+
12431267
@@ -1256,6 +1280,8 @@
12561280 opts(axis.text.x = theme_text(size=15, colour="black",vjust=1))+
12571281 opts(axis.text.y = theme_text(size=15, colour="black", hjust=1))
12581282
1283+
1284+
12591285 }
12601286
12611287
@@ -1275,6 +1301,12 @@
12751301
12761302 }
12771303
1304+
1305+gpl_list[[1]] <- gpl_list[[1]] +
1306+ opts(title = expression(paste("Aggregation on 5 min, 1 hour cutoff")))+
1307+ opts(plot.title = theme_text(size = 20))
1308+
1309+
12781310 fn <- paste("role-shuffle-normalized-triangles-panel.tex")
12791311
12801312 width <- 15
diff -r 641076e85e9f -r b76bd1396495 R-codes/intervals_advanced.R
--- a/R-codes/intervals_advanced.R Tue Jan 18 13:43:52 2011 +0000
+++ b/R-codes/intervals_advanced.R Mon Jan 24 17:01:30 2011 +0000
@@ -242,6 +242,145 @@
242242
243243 }
244244
245+
246+
247+
248+
249+
250+
251+
252+t_ab_bc_improved_all_triangles <- function(data_tag,tag_id){
253+
254+## delta_t <- abs(diff(data_tag$ini_time))
255+
256+delta_t <- c()
257+labels <- c()
258+roles <- c()
259+ternary_roles <- c()
260+
261+
262+if (length(data_tag$id1)>1){
263+
264+sort_time_ini <- sort(data_tag$ini_time, decreasing=FALSE, index.return=TRUE)
265+
266+ms <- sort_time_ini$ix
267+
268+
269+## sort the data once for all
270+
271+data_tag <- data_tag[ms, ]
272+## print("tag_id is,")
273+## print(tag_id)
274+## print("data_tag is, ")
275+## print(data_tag)
276+for (i in seq(length(data_tag$id1)-1)){
277+for (j in seq((i+1),length(data_tag$id1) )){
278+if (((data_tag$id1[i]+data_tag$id2[i])!=(data_tag$id1[j]+data_tag$id2[j]))){
279+delta_t <- c(delta_t,(data_tag$ini_time[j]-data_tag$ini_time[i]))
280+labels <- rbind(labels,cbind(data_tag$id1[i],data_tag$id2[i],
281+data_tag$id1[j],data_tag$id2[j]))
282+
283+## print("data_tag$id1[i] is, ")
284+## print(data_tag$id1[i])
285+
286+## print("tag_id is, ")
287+## print(tag_id)
288+
289+if (data_tag$id1[i]==tag_id){
290+ tag_a <- data_tag$role_second[i]
291+ tag_b <- data_tag$role_first[i]
292+}else{
293+ tag_a <- data_tag$role_first[i]
294+ tag_b <- data_tag$role_second[i]
295+}
296+
297+
298+## print("i is, ")
299+## print(i)
300+## print("j is")
301+## print(j)
302+
303+
304+if (data_tag$id1[j]==tag_id){
305+ tag_c <- data_tag$role_second[j]
306+}else{
307+ tag_c <- data_tag$role_first[j]
308+}
309+
310+roles <- rbind(roles,cbind(data_tag$role_first[i],data_tag$role_second[i],
311+data_tag$role_first[j],data_tag$role_second[j]))
312+ternary_roles <- rbind(ternary_roles,cbind(tag_a,tag_b,tag_c))
313+}
314+}
315+}
316+}
317+## labels <- cbind(data_tag$id1[1:length(data_tag$id1)-1],data_tag$id2[1:length(data_tag$id2)-1],
318+## data_tag$id1[2:length(data_tag$id1)],data_tag$id2[2:length(data_tag$id2)])
319+return (list(delta_t, labels,roles,ternary_roles))
320+}
321+
322+
323+
324+t_ab_bc_improved_all_triangles_stop <- function(data_tag,tag_id){
325+
326+## delta_t <- abs(diff(data_tag$ini_time))
327+
328+delta_t <- c()
329+labels <- c()
330+roles <- c()
331+ternary_roles <- c()
332+
333+
334+if (length(data_tag$id1)>1){
335+
336+sort_time_ini <- sort(data_tag$ini_time, decreasing=FALSE, index.return=TRUE)
337+
338+ms <- sort_time_ini$ix
339+
340+data_tag <- data_tag[ms, ]
341+for (i in seq(length(data_tag$id1)-1)){
342+
343+
344+j <- i+1
345+
346+while ( (j<=length(data_tag$id1)) & ((data_tag$id1[i]+data_tag$id2[i])!=(data_tag$id1[j]+data_tag$id2[j]))){
347+
348+ delta_t <- c(delta_t,(data_tag$ini_time[j]-data_tag$ini_time[i]))
349+labels <- rbind(labels,cbind(data_tag$id1[i],data_tag$id2[i],
350+data_tag$id1[j],data_tag$id2[j]))
351+
352+
353+if (data_tag$id1[i]==tag_id){
354+ tag_a <- data_tag$role_second[i]
355+ tag_b <- data_tag$role_first[i]
356+}else{
357+ tag_a <- data_tag$role_first[i]
358+ tag_b <- data_tag$role_second[i]
359+}
360+
361+if (data_tag$id1[j]==tag_id){
362+ tag_c <- data_tag$role_second[j]
363+}else{
364+ tag_c <- data_tag$role_first[j]
365+}
366+
367+roles <- rbind(roles,cbind(data_tag$role_first[i],data_tag$role_second[i],
368+data_tag$role_first[j],data_tag$role_second[j]))
369+ternary_roles <- rbind(ternary_roles,cbind(tag_a,tag_b,tag_c))
370+
371+j <- j+1
372+
373+ }
374+
375+}
376+}
377+
378+return (list(delta_t, labels,roles,ternary_roles))
379+}
380+
381+
382+
383+
245384 get_frequence <- function(contact){
246385
247386 freq <- table(contact)
@@ -284,11 +423,11 @@
284423 #######################################################################
285424
286425
287-timeslice_dur <- 20
426+timeslice_dur <- 300
288427
289-cut_off <- 900 #max interval durations
428+cut_off <- 3600*24 #max interval durations
290429
291-time_reversal <- 0
430+time_reversal <- 1
292431
293432 time_uniform <- 0
294433
@@ -449,9 +588,14 @@
449588
450589 data_tag <- data_tot[sel, ]
451590
452-## res_single_tag <- t_ab_bc(data_tag)
453591
454-res_single_tag <- t_ab_bc_improved(data_tag,tag_id)
592+
593+## res_single_tag <- t_ab_bc_improved(data_tag,tag_id)
594+
595+## res_single_tag <- t_ab_bc_improved_all_triangles(data_tag,tag_id)
596+
597+res_single_tag <- t_ab_bc_improved_all_triangles_stop(data_tag,tag_id)
598+
455599
456600 delta_t_overall <- c(delta_t_overall, res_single_tag[[1]])
457601 label_overall <- rbind(label_overall,res_single_tag[[2]])
diff -r 641076e85e9f -r b76bd1396495 R-codes/intervals_reshuffled.R
--- a/R-codes/intervals_reshuffled.R Tue Jan 18 13:43:52 2011 +0000
+++ b/R-codes/intervals_reshuffled.R Mon Jan 24 17:01:30 2011 +0000
@@ -225,6 +225,70 @@
225225 }
226226
227227
228+
229+t_ab_bc_improved_all_triangles_stop <- function(data_tag,tag_id){
230+
231+## delta_t <- abs(diff(data_tag$ini_time))
232+
233+delta_t <- c()
234+labels <- c()
235+roles <- c()
236+ternary_roles <- c()
237+
238+
239+if (length(data_tag$id1)>1){
240+
241+sort_time_ini <- sort(data_tag$ini_time, decreasing=FALSE, index.return=TRUE)
242+
243+ms <- sort_time_ini$ix
244+
245+data_tag <- data_tag[ms, ]
246+for (i in seq(length(data_tag$id1)-1)){
247+
248+
249+j <- i+1
250+
251+while ( (j<=length(data_tag$id1)) & ((data_tag$id1[i]+data_tag$id2[i])!=(data_tag$id1[j]+data_tag$id2[j]))){
252+
253+ delta_t <- c(delta_t,(data_tag$ini_time[j]-data_tag$ini_time[i]))
254+labels <- rbind(labels,cbind(data_tag$id1[i],data_tag$id2[i],
255+data_tag$id1[j],data_tag$id2[j]))
256+
257+
258+if (data_tag$id1[i]==tag_id){
259+ tag_a <- data_tag$role_second[i]
260+ tag_b <- data_tag$role_first[i]
261+}else{
262+ tag_a <- data_tag$role_first[i]
263+ tag_b <- data_tag$role_second[i]
264+}
265+
266+if (data_tag$id1[j]==tag_id){
267+ tag_c <- data_tag$role_second[j]
268+}else{
269+ tag_c <- data_tag$role_first[j]
270+}
271+
272+roles <- rbind(roles,cbind(data_tag$role_first[i],data_tag$role_second[i],
273+data_tag$role_first[j],data_tag$role_second[j]))
274+ternary_roles <- rbind(ternary_roles,cbind(tag_a,tag_b,tag_c))
275+
276+j <- j+1
277+
278+ }
279+
280+}
281+}
282+
283+return (list(delta_t, labels,roles,ternary_roles))
284+}
285+
286+
287+
288+
289+
290+
291+
228292 reassign_roles <- function(data_tot, tag_role_association,tag_ids_uni, select_ids, select_roles ){
229293
230294 reshuffled_unique_roles <- sample(tag_role_association)
@@ -258,13 +322,13 @@
258322
259323
260324
261-cut_off <- 300
325+cut_off <- 3600*24
262326
263327
264328 n_iter <- 200
265329
266330
267-sample_on_times <- 1
331+sample_on_times <- 0
268332
269333
270334 data_tot <- read.table("global_data.dat", header=TRUE)
@@ -389,7 +453,9 @@
389453
390454 ## res_single_tag <- t_ab_bc(data_tag)
391455
392-res_single_tag <- t_ab_bc_improved(data_tag,tag_id)
456+## res_single_tag <- t_ab_bc_improved(data_tag,tag_id)
457+
458+res_single_tag <- t_ab_bc_improved_all_triangles_stop(data_tag,tag_id)
393459
394460 delta_t_overall <- c(delta_t_overall, res_single_tag[[1]])
395461 label_overall <- rbind(label_overall,res_single_tag[[2]])