@@ -31,8 +31,12 @@ class Simulation():
3131 mutation_rate (float): Probability of a mutation to occur during copying.
3232 subpop_set_counts (pd.DataFrame): Collects the number of unique set counts per subpopulation averaged over subpopulations.
3333 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.
3436 metapop_set_counts (pd.DataFrame): Collects the number of unique set counts over the whole metapopulation.
3537 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.
3640 """
3741 def __init__ (self ,
3842 generations : int ,
@@ -90,15 +94,23 @@ def __init__(self,
9094
9195 self .subpop_set_counts = pd .DataFrame ()
9296 self .subpop_shannon = pd .DataFrame ()
97+ self .subpop_simpson = pd .DataFrame ()
98+ self .subpop_gini = pd .DataFrame ()
9399 self .metapop_set_counts = pd .DataFrame ()
94100 self .metapop_shannon = pd .DataFrame ()
101+ self .metapop_simpson = pd .DataFrame ()
102+ self .metapop_gini = pd .DataFrame ()
95103
96104
97105 def empty_lists (self ):
98106 self .subpop_set_counts = pd .DataFrame ()
99107 self .subpop_shannon = pd .DataFrame ()
108+ self .subpop_simpson = pd .DataFrame ()
109+ self .subpop_gini = pd .DataFrame ()
100110 self .metapop_set_counts = pd .DataFrame ()
101111 self .metapop_shannon = pd .DataFrame ()
112+ self .metapop_simpson = pd .DataFrame ()
113+ self .metapop_gini = pd .DataFrame ()
102114
103115
104116 def run_single_replicate (self , replicate_id : int ) -> None :
@@ -114,8 +126,12 @@ def run_single_replicate(self, replicate_id: int) -> None:
114126
115127 set_counts = []
116128 shannon = []
129+ simpson = []
130+ gini = []
117131 metapop_counts = []
118132 metapop_shannon = []
133+ metapop_simpson = []
134+ metapop_gini = []
119135
120136 start_time = time .time ()
121137 for t in range (self .generations + 1 ):
@@ -127,8 +143,12 @@ def run_single_replicate(self, replicate_id: int) -> None:
127143 if t % self .measure_timing == 0 :
128144 set_counts .append (np .mean (metapopulation .traits_sets_per_subpopulation ()))
129145 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 ()))
130148 metapop_counts .append (metapopulation .metapopulation_test_sets ())
131149 metapop_shannon .append (metapopulation .metapopulation_shannon_diversity ())
150+ metapop_simpson .append (metapopulation .metapopulation_simpson_diversity ())
151+ metapop_gini .append (metapopulation .metapopulation_gini_diversity ())
132152
133153
134154 if t > self .burn_in :
@@ -138,8 +158,12 @@ def run_single_replicate(self, replicate_id: int) -> None:
138158
139159 self .subpop_set_counts = pd .concat ([self .subpop_set_counts , pd .Series (set_counts , name = replicate_id )], axis = 1 )
140160 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 )
141163 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 )
143167
144168 if self .verbose :
145169 end_time = time .time ()
@@ -187,9 +211,13 @@ def save_output(self) -> None:
187211 Save output to input folder.
188212 """
189213 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 = "," )
191217 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 = "," )
193221
194222
195223 def create_migration_table (self , type_of_model , migration_rate : float ) -> None :
0 commit comments