Skip to content

Commit 9fc4e6c

Browse files
committed
fixed cluster size logic
1 parent 9724773 commit 9fc4e6c

10 files changed

Lines changed: 638 additions & 153 deletions

models/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def estimate_runtime(self, n_cores: int = 32) -> str:
210210
grid_size=100,
211211
n_prey_birth=10,
212212
n_replicates=30,
213-
warmup_steps=300,
214-
measurement_steps=500,
213+
warmup_steps=1000,
214+
measurement_steps=1000,
215215
with_evolution=True,
216216
evolve_sd=0.10,
217217
collect_pcf=False, # Not needed for SOC analysis

notebooks/cluster_powerlaw.png

115 KB
Loading
123 KB
Loading
95.2 KB
Loading
200 KB
Loading

notebooks/phase1.ipynb

Lines changed: 623 additions & 141 deletions
Large diffs are not rendered by default.

notebooks/phase1_summary.png

181 KB
Loading
70.5 KB
Loading
57.7 KB
Loading

scripts/experiments.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,22 @@ def run_single_simulation(
218218
evolved_stds.append(stats["std"])
219219

220220
# Cluster analysis (at end of measurement)
221-
if step == measurement_steps - 1 and prey >= min_count and pred >= (min_count // 4):
222-
prey_stats = get_cluster_stats_fast(model.grid, 1)
223-
pred_stats = get_cluster_stats_fast(model.grid, 2)
221+
if step == measurement_steps - 1:
222+
prey_survived = prey_pops[-1] > min_count
223+
pred_survived = pred_pops[-1] > (min_count // 4)
224224

225-
cluster_sizes_prey = prey_stats['sizes'].tolist()
226-
cluster_sizes_pred = pred_stats['sizes'].tolist()
225+
if prey_survived:
226+
prey_stats = get_cluster_stats_fast(model.grid, 1)
227+
cluster_sizes_prey = prey_stats['sizes'].tolist()
228+
largest_fractions_prey.append(prey_stats['largest_fraction'])
227229

228-
largest_fractions_prey.append(prey_stats['largest_fraction'])
229-
largest_fractions_pred.append(pred_stats['largest_fraction'])
230-
# NOTE: Change in largest fraction calculation if needed for critical point location
230+
if pred_survived:
231+
pred_stats = get_cluster_stats_fast(model.grid, 2)
232+
cluster_sizes_pred = pred_stats['sizes'].tolist()
233+
largest_fractions_pred.append(pred_stats['largest_fraction'])
231234

232-
# PCF
233-
if compute_pcf:
235+
# PCF requires both
236+
if compute_pcf and prey_survived and pred_survived:
234237
max_dist = min(grid_size / 2, cfg.pcf_max_distance)
235238
pcf_data = compute_all_pcfs_fast(model.grid, max_dist, cfg.pcf_n_bins)
236239
pcf_samples['prey_prey'].append(pcf_data['prey_prey'])

0 commit comments

Comments
 (0)