@@ -31,8 +31,12 @@ class Simulation():
31
31
mutation_rate (float): Probability of a mutation to occur during copying.
32
32
subpop_set_counts (pd.DataFrame): Collects the number of unique set counts per subpopulation averaged over subpopulations.
33
33
subpop_shannon (pd.DataFrame): Collects the Shannon diversity index per subpopulation averaged over subpopulations.
34
+ subpop_simpson (pd.DataFrame): Collects the Simpson diversity index per subpopulation averaged over subpopulations.
35
+ subpop_gini (pd.DataFrame): Collects the Gini diversity index per subpopulation averaged over subpopulations.
34
36
metapop_set_counts (pd.DataFrame): Collects the number of unique set counts over the whole metapopulation.
35
37
metapop_shannon (pd.DataFrame): Collects the Shannon diversity index over the whole metapopulation.
38
+ metapop_simpson (pd.DataFrame): Collects the Simpson diversity index over the whole metapopulation.
39
+ metapop_gini (pd.DataFrame): Collects the Gini diversity index over the whole metapopulation.
36
40
"""
37
41
def __init__ (self ,
38
42
generations : int ,
@@ -90,15 +94,23 @@ def __init__(self,
90
94
91
95
self .subpop_set_counts = pd .DataFrame ()
92
96
self .subpop_shannon = pd .DataFrame ()
97
+ self .subpop_simpson = pd .DataFrame ()
98
+ self .subpop_gini = pd .DataFrame ()
93
99
self .metapop_set_counts = pd .DataFrame ()
94
100
self .metapop_shannon = pd .DataFrame ()
101
+ self .metapop_simpson = pd .DataFrame ()
102
+ self .metapop_gini = pd .DataFrame ()
95
103
96
104
97
105
def empty_lists (self ):
98
106
self .subpop_set_counts = pd .DataFrame ()
99
107
self .subpop_shannon = pd .DataFrame ()
108
+ self .subpop_simpson = pd .DataFrame ()
109
+ self .subpop_gini = pd .DataFrame ()
100
110
self .metapop_set_counts = pd .DataFrame ()
101
111
self .metapop_shannon = pd .DataFrame ()
112
+ self .metapop_simpson = pd .DataFrame ()
113
+ self .metapop_gini = pd .DataFrame ()
102
114
103
115
104
116
def run_single_replicate (self , replicate_id : int ) -> None :
@@ -114,8 +126,12 @@ def run_single_replicate(self, replicate_id: int) -> None:
114
126
115
127
set_counts = []
116
128
shannon = []
129
+ simpson = []
130
+ gini = []
117
131
metapop_counts = []
118
132
metapop_shannon = []
133
+ metapop_simpson = []
134
+ metapop_gini = []
119
135
120
136
start_time = time .time ()
121
137
for t in range (self .generations + 1 ):
@@ -127,8 +143,12 @@ def run_single_replicate(self, replicate_id: int) -> None:
127
143
if t % self .measure_timing == 0 :
128
144
set_counts .append (np .mean (metapopulation .traits_sets_per_subpopulation ()))
129
145
shannon .append (np .mean (metapopulation .shannon_diversity_per_subpopulation ()))
146
+ simpson .append (np .mean (metapopulation .simpson_diversity_per_subpopulation ()))
147
+ gini .append (np .mean (metapopulation .gini_diversity_per_subpopulation ()))
130
148
metapop_counts .append (metapopulation .metapopulation_test_sets ())
131
149
metapop_shannon .append (metapopulation .metapopulation_shannon_diversity ())
150
+ metapop_simpson .append (metapopulation .metapopulation_simpson_diversity ())
151
+ metapop_gini .append (metapopulation .metapopulation_gini_diversity ())
132
152
133
153
134
154
if t > self .burn_in :
@@ -138,8 +158,12 @@ def run_single_replicate(self, replicate_id: int) -> None:
138
158
139
159
self .subpop_set_counts = pd .concat ([self .subpop_set_counts , pd .Series (set_counts , name = replicate_id )], axis = 1 )
140
160
self .subpop_shannon = pd .concat ([self .subpop_shannon , pd .Series (shannon , name = replicate_id )], axis = 1 )
161
+ self .subpop_simpson = pd .concat ([self .subpop_simpson , pd .Series (simpson , name = replicate_id )], axis = 1 )
162
+ self .subpop_gini = pd .concat ([self .subpop_gini , pd .Series (gini , name = replicate_id )], axis = 1 )
141
163
self .metapop_set_counts = pd .concat ([self .metapop_set_counts , pd .Series (metapop_counts , name = replicate_id )], axis = 1 )
142
- self .metapop_shannoneturn = pd .concat ([self .metapop_shannon , pd .Series (metapop_shannon , name = replicate_id )], axis = 1 )
164
+ self .metapop_shannon = pd .concat ([self .metapop_shannon , pd .Series (metapop_shannon , name = replicate_id )], axis = 1 )
165
+ self .metapop_simpson = pd .concat ([self .metapop_simpson , pd .Series (metapop_simpson , name = replicate_id )], axis = 1 )
166
+ self .metapop_gini = pd .concat ([self .metapop_gini , pd .Series (metapop_gini , name = replicate_id )], axis = 1 )
143
167
144
168
if self .verbose :
145
169
end_time = time .time ()
@@ -187,9 +211,13 @@ def save_output(self) -> None:
187
211
Save output to input folder.
188
212
"""
189
213
self .subpop_set_counts .to_csv (f"{ self .output_path } _subpop_set_counts.csv" , sep = "," )
190
- #self.subpop_shannon.to_csv(f"{self.output_path}_subpop_shannon.csv", sep=",")
214
+ self .subpop_shannon .to_csv (f"{ self .output_path } _subpop_shannon.csv" , sep = "," )
215
+ self .subpop_simpson .to_csv (f"{ self .output_path } _subpop_simpson.csv" , sep = "," )
216
+ self .subpop_gini .to_csv (f"{ self .output_path } _subpop_gini.csv" , sep = "," )
191
217
self .metapop_set_counts .to_csv (f"{ self .output_path } _metapop_set_counts.csv" , sep = "," )
192
- #self.metapop_shannon.to_csv(f"{self.output_path}_metapop_shannon.csv", sep=",")
218
+ self .metapop_shannon .to_csv (f"{ self .output_path } _metapop_shannon.csv" , sep = "," )
219
+ self .metapop_simpson .to_csv (f"{ self .output_path } _metapop_simpson.csv" , sep = "," )
220
+ self .metapop_gini .to_csv (f"{ self .output_path } _metapop_gini.csv" , sep = "," )
193
221
194
222
195
223
def create_migration_table (self , type_of_model , migration_rate : float ) -> None :
0 commit comments