1515# we want the array operations to have a different seed across processes
1616array_urand .seed (int (1024 * random ()))
1717
18-
19- nsp = int (sys .argv [1 ]) # initial number of species
20- A = int (sys .argv [2 ]) # area
21- mut_max = float (sys .argv [3 ]) # mutation rate
22- migration = float (sys .argv [4 ]) # initial migration rate
23-
24-
25- ecolab .repro_min (- 0.1 )
26- ecolab .repro_max (0.1 )
27- ecolab .odiag_min (- 1e-5 )
28- ecolab .odiag_max (1e-5 )
29- ecolab .mut_max (mut_max )
30- ecolab .sp_sep (0.1 )
31-
3218def randomList (num , min , max ):
3319 return [random ()* (max - min )+ min for i in range (num )]
3420
35- ecolab .species (range (nsp ))
36-
37- numX = int (sqrt (A ))
38- numY = A // numX
39- ecolab .setGrid (numX ,numY )
40- ecolab .partitionObjects ()
41-
42- # initialises allocators and space on GPU, so that density arrays can be set
43- #ecolab.makeConsistent()
44-
45- for i in range (numX ):
46- for j in range (numY ):
47- ecolab .cell (i ,j ).density (nsp * [100 ])
48-
49- ecolab .repro_rate (randomList (nsp , ecolab .repro_min (), ecolab .repro_max ()))
50- ecolab .interaction .diag (randomList (nsp , - 1e-3 , - 1e-3 ))
51- ecolab .random_interaction (3 ,0 )
52-
53- ecolab .interaction .val (randomList (len (ecolab .interaction .val ), ecolab .odiag_min (), ecolab .odiag_max ()))
54-
55- ecolab .mutation (nsp * [mut_max ])
56- ecolab .migration (nsp * [migration ])
57-
58- from plot import plot
59- from GUI import gui , statusBar , windows
60-
61- def stepImpl ():
21+ def step ():
6222 ecolab .generate (100 )
6323 ecolab .mutate ()
6424 ecolab .migrate ()
@@ -67,15 +27,51 @@ def stepImpl():
6727
6828def av (x ):
6929 return sum (x )/ len (x ) if len (x )> 0 else 0
70-
71- def step ():
72- stepImpl ()
73- # area, mutation, migration, no. species, connectivity
7430
75- for i in range (100 ):
76- step ()
31+ #nsp=int(sys.argv[1]) # initial number of species
32+ #A=int(sys.argv[2]) # area
33+ #mut_max=float(sys.argv[3]) # mutation rate
34+ #migration=float(sys.argv[4]) # initial migration rate
35+
36+ print ("Area, Mutation rate, Migration rate, Number of species, Interaction strength^2" )
37+ for A in [1 , 2 , 4 , 9 , 16 ]:
38+ for mut_max in [1e-4 , 1e-3 , 1e-2 ]:
39+ for migration in [1e-6 , 1e-5 , 1e-4 , 1e-3 ]:
40+ for nsp in [100 , 200 , 400 ]:
41+ ecolab .tstep (0 )
42+ ecolab .repro_min (- 0.1 )
43+ ecolab .repro_max (0.1 )
44+ ecolab .odiag_min (- 1e-5 )
45+ ecolab .odiag_max (1e-5 )
46+ ecolab .mut_max (mut_max )
47+ ecolab .sp_sep (0.1 )
48+
49+ ecolab .species (range (nsp ))
50+ ecolab .create (nsp * [0 ])
51+
52+
53+ numX = int (sqrt (A ))
54+ numY = A // numX
55+ ecolab .setGrid (numX ,numY )
56+ ecolab .partitionObjects ()
57+
58+ for i in range (numX ):
59+ for j in range (numY ):
60+ ecolab .cell (i ,j ).density (nsp * [100 ])
61+
62+ ecolab .repro_rate (randomList (nsp , ecolab .repro_min (), ecolab .repro_max ()))
63+ ecolab .interaction .diag (randomList (nsp , - 1e-3 , - 1e-3 ))
64+ ecolab .random_interaction (3 ,0 )
65+
66+ ecolab .interaction .val (randomList (len (ecolab .interaction .val ), ecolab .odiag_min (), ecolab .odiag_max ()))
67+
68+ ecolab .mutation (nsp * [mut_max ])
69+ ecolab .migration (nsp * [migration ])
70+
71+ for i in range (100 ):
72+ step ()
7773
78- print (numX * numY , av (ecolab .mutation ()), av (ecolab .migration ()), len (ecolab .species ), sum ([x * x for x in ecolab .interaction .val ()])/ len (ecolab .species )** 2 )
74+ print (numX * numY , av (ecolab .mutation ()), av (ecolab .migration ()), len (ecolab .species ), sum ([x * x for x in ecolab .interaction .val ()])/ len (ecolab .species )** 2 )
7975
8076
8177
0 commit comments