|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | """ |
3 | | -Predator-Prey Hydra Effect Experiments - HPC Version |
4 | | -
|
5 | | -Experimental phases (run sequentially): |
6 | | - Phase 1: Parameter sweep to find critical point (bifurcation + cluster analysis) |
7 | | - Phase 2: Self-organization analysis (evolution toward criticality) |
8 | | - Phase 3: Finite-size scaling at critical point |
9 | | - Phase 4: Sensitivity analysis across parameter regimes |
10 | | - Phase 5: Model extensions (directed hunting comparison) |
11 | | -
|
12 | | -Usage: |
13 | | - python experiments.py --phase 1 # Run phase 1 |
14 | | - python experiments.py --phase 1 --dry-run # Estimate runtime |
15 | | - python experiments.py --phase all # Run all phases |
16 | | - python experiments.py --phase 1 --output results/ # Custom output |
| 3 | +Predator-Prey Hydra Effect Experiments |
| 4 | +====================================== |
| 5 | +
|
| 6 | +HPC-ready experiment runner for investigating the Hydra effect in |
| 7 | +predator-prey cellular automata. |
| 8 | +
|
| 9 | +Experimental Phases |
| 10 | +------------------- |
| 11 | +- **Phase 1**: Parameter sweep to find critical point (bifurcation + cluster analysis) |
| 12 | +- **Phase 2**: Self-organization analysis (evolution toward criticality) |
| 13 | +- **Phase 3**: Finite-size scaling at critical point |
| 14 | +- **Phase 4**: Sensitivity analysis across parameter regimes |
| 15 | +- **Phase 5**: Model extensions (directed hunting comparison) |
| 16 | +
|
| 17 | +Functions |
| 18 | +--------- |
| 19 | +```python |
| 20 | +run_single_simulation # Execute one simulation run and collect metrics. |
| 21 | +run_phase1, run_phase2, run_phase3, run_phase4, run_phase5 # Phase-specific experiment runners. |
| 22 | +``` |
| 23 | +
|
| 24 | +Utilities |
| 25 | +--------- |
| 26 | +```python |
| 27 | +generate_unique_seed # Deterministic seed generation from parameters. |
| 28 | +count_populations # Count species populations on grid. |
| 29 | +get_evolved_stats # Statistics for evolved parameters. |
| 30 | +average_pcfs # Average multiple PCF measurements. |
| 31 | +save_results_jsonl, load_results_jsonl, save_results_npz # I/O functions for experiment results. |
| 32 | +``` |
| 33 | +
|
| 34 | +Command Line Usage |
| 35 | +------------------ |
| 36 | +```bash |
| 37 | +python experiments.py --phase 1 # Run phase 1 |
| 38 | +python experiments.py --phase 1 --dry-run # Estimate runtime |
| 39 | +python experiments.py --phase all # Run all phases |
| 40 | +python experiments.py --phase 1 --output results/ # Custom output |
| 41 | +``` |
| 42 | +
|
| 43 | +Programmatic Usage |
| 44 | +------------------ |
| 45 | +```python |
| 46 | +from experiments import run_single_simulation, run_phase1 |
| 47 | +from models.config import PHASE1_CONFIG |
| 48 | +
|
| 49 | +# Single simulation |
| 50 | +result = run_single_simulation( |
| 51 | + prey_birth=0.2, |
| 52 | + prey_death=0.05, |
| 53 | + predator_birth=0.8, |
| 54 | + predator_death=0.1, |
| 55 | + grid_size=100, |
| 56 | + seed=42, |
| 57 | + cfg=PHASE1_CONFIG, |
| 58 | +) |
| 59 | +
|
| 60 | +# Full phase (writes to output directory) |
| 61 | +import logging |
| 62 | +results = run_phase1(PHASE1_CONFIG, Path("results/"), logging.getLogger()) |
| 63 | +``` |
17 | 64 | """ |
18 | 65 |
|
19 | 66 | import argparse |
|
45 | 92 | from models.numba_optimized import ( |
46 | 93 | compute_all_pcfs_fast, |
47 | 94 | get_cluster_stats_fast, |
48 | | - get_percolating_cluster_fast, |
49 | 95 | warmup_numba_kernels, |
50 | 96 | set_numba_seed, |
51 | 97 | NUMBA_AVAILABLE, |
@@ -419,7 +465,6 @@ def run_single_simulation( |
419 | 465 | "predator_birth": predator_birth, |
420 | 466 | }, |
421 | 467 | seed=seed, |
422 | | - synchronous=cfg.synchronous, |
423 | 468 | directed_hunting=cfg.directed_hunting, |
424 | 469 | ) |
425 | 470 |
|
|
0 commit comments