• R/O
  • SSH

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Révision25efd5dac9a6ae0aa4cd8cc4260b23ca11d6619a (tree)
l'heure2010-04-22 01:19:02
Auteurlorenzo
Commiterlorenzo

Message de Log

Now the code can also define the number of susceptible individuals as the
number of individuals in the seed's CC (instead of simply the number of
individuals entering the museum after the seed). The code is still being
developed, hence be careful!

Change Summary

Modification

diff -r b6ad982fc39c -r 25efd5dac9a6 Python-codes/iterate_deterministic_infection_also_on_days.py
--- a/Python-codes/iterate_deterministic_infection_also_on_days.py Wed Apr 21 15:57:19 2010 +0000
+++ b/Python-codes/iterate_deterministic_infection_also_on_days.py Wed Apr 21 16:19:02 2010 +0000
@@ -4,6 +4,12 @@
44 import numpy as n
55 import sys
66 import string
7+import igraph as ig
8+
9+def array_to_dict_iter(array):
10+ for row in array:
11+ yield dict(source=row[0], target=row[1])
12+
713
814
915
@@ -23,6 +29,8 @@
2329 def time_infection(data_no_loops, infected):
2430 before_and_after=\
2531 network_after_infection_introduction(infected,data_no_loops)
32+
33+ seed=infected
2634
2735 net_infected=before_and_after[0]
2836
@@ -30,6 +38,22 @@
3038 #number of people the seed can infect (not the number of visitors since
3139 #the seed cannot infect a priori those who left before he entered)
3240
41+ g = ig.Graph.DictList(vertices=None, edges=array_to_dict_iter(net_infected[:,1:3]))
42+
43+ g=g.simplify()
44+ clustering=g.clusters()
45+ c_sizes=s.asarray(clustering.sizes())
46+
47+ name_list=g.vs["name"]
48+
49+ name_list=s.asarray(name_list)
50+
51+ sel=s.where(name_list==seed)[0]
52+ seed_membership=clustering.membership[sel]
53+
54+ susceptible_improved=c_sizes[seed_membership]
55+
56+
3357 infected_list_overall=s.zeros(0).astype("int64")
3458 infected_times_overall=s.zeros(0).astype("int64")
3559
@@ -93,7 +117,7 @@
93117 cumulative_new_infected[i]=len(set_infected)
94118
95119 return [infected_list_overall,infected_times_overall,\
96- cumulative_new_infected, time_unique, susceptible]
120+ cumulative_new_infected, time_unique, susceptible,susceptible_improved ]
97121
98122
99123
@@ -250,6 +274,7 @@
250274
251275 total_infected_distr=s.zeros(len(visitor_list)).astype("int64")
252276 total_susceptible_distr=s.zeros(len(visitor_list)).astype("int64")
277+ total_susceptible_distr_improved=s.zeros(len(visitor_list)).astype("int64")
253278
254279
255280 for visitor_iter in xrange(len(visitor_list)):
@@ -268,10 +293,11 @@
268293
269294 total_infected_distr[visitor_iter]=count_infections[-1]
270295 total_susceptible_distr[visitor_iter]=dynamic_infection[4]
296+ total_susceptible_distr_improved[visitor_iter]=dynamic_infection[5]
271297
272298
273299
274- return [total_infected_distr.astype("int64"),len(visitor_list)*s.ones(len(visitor_list)).astype("int64"),total_susceptible_distr.astype("int64")]
300+ return [total_infected_distr.astype("int64"),len(visitor_list)*s.ones(len(visitor_list)).astype("int64"),total_susceptible_distr.astype("int64"),total_susceptible_distr_improved.astype("int64")]
275301
276302
277303 def iterate_calculation_number_infected_on_time_periods(period_list,data_laundry):
@@ -279,6 +305,7 @@
279305 number_infected_overall=s.zeros(0).astype("int64")
280306 number_non_isolated_overall=s.zeros(0).astype("int64")
281307 number_susceptible_overall=s.zeros(0).astype("int64")
308+ number_susceptible_overall_improved=s.zeros(0).astype("int64")
282309
283310 #change period_list into an array of strings
284311
@@ -305,10 +332,11 @@
305332 number_non_isolated_overall=s.hstack((number_non_isolated_overall,number_non_isolated_and_infected[1]))
306333
307334 number_susceptible_overall=s.hstack((number_susceptible_overall,number_non_isolated_and_infected[2]))
335+ number_susceptible_overall_improved=s.hstack((number_susceptible_overall_improved,number_non_isolated_and_infected[3]))
308336
309337
310338 return [number_infected_overall,number_non_isolated_overall,\
311- number_susceptible_overall]
339+ number_susceptible_overall, number_susceptible_overall_improved]
312340
313341
314342
@@ -356,12 +384,13 @@
356384
357385 period_list=n.loadtxt('periods_with_min_number_visitors.dat').astype('int64')
358386
359-data_laundry=0
387+data_laundry=1
360388 number_and_number_infected=iterate_calculation_number_infected_on_time_periods(period_list,data_laundry)
361389
362390 n.savetxt("number_distr_infected_overall.dat", number_and_number_infected[0], fmt="%d")
363391 n.savetxt("number_distr_non_isolated_overall.dat", number_and_number_infected[1], fmt="%d")
364392 n.savetxt("number_distr_susceptible_overall.dat", number_and_number_infected[2], fmt="%d")
393+n.savetxt("number_distr_susceptible_overall_improved.dat", number_and_number_infected[3], fmt="%d")
365394
366395
367396