Skip to content

Commit c5a6c03

Browse files
committed
Merge branch 'main' of https://github.com/codegithubka/CSS_Project into storm
2 parents 16e5749 + 518d444 commit c5a6c03

15 files changed

Lines changed: 3915 additions & 939 deletions

benchmarks/benchmark.txt

Lines changed: 0 additions & 110 deletions
This file was deleted.

benchmarks/benchmark_plots.png

-151 KB
Binary file not shown.

benchmarks/simulation_profile.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

docs/SOC_ANALYSIS_README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Self-Organized Criticality (SOC) Analysis - Summary
2+
3+
## File Created
4+
**Location:** `scripts/soc_analysis.py`
5+
6+
## Overview
7+
This comprehensive Python analysis script tests whether your prey-predator cellular automaton exhibits **self-organized criticality** (SOC), with focus on perturbations from initial configurations and diverse parameter sampling.
8+
9+
## Key Features
10+
11+
### 1. **Four SOC Properties Analyzed**
12+
- **Slow Drive:** Gradual parameter drift without immediate release
13+
- **Stress Build-up:** Interface-based metric tracking potential energy accumulation
14+
- **Intermittent Release:** Detection of avalanche cascades in population dynamics
15+
- **Self-Organization:** Robustness across diverse parameter combinations
16+
17+
### 2. **Parameter Variations** (Beyond just death/birth rates)
18+
- Grid sizes: 16×16 to 64×64
19+
- Initial densities: prey (0.1–0.4), predator (0.02–0.15)
20+
- Neighborhood types: Neumann & Moore
21+
- Update modes: Synchronous & Asynchronous
22+
- Rate parameters: randomly varied across valid ranges
23+
24+
### 3. **Metrics Computed**
25+
- **Stress Metric:** Normalized count of (predator/prey)↔empty adjacent pairs
26+
- Represents friction and interface gradient (potential energy)
27+
- **Avalanche Detection:** Population change magnitude thresholds
28+
- **Population Variance:** Rolling window variance of prey/predator counts
29+
- **Robustness Metrics:**
30+
- Avalanche count mean/std across configurations
31+
- Magnitude consistency
32+
- Coefficient of variation (measures criticality robustness)
33+
34+
### 4. **Perturbation Experiment Design**
35+
Each experiment runs 230 total steps:
36+
- **Equilibration phase (0–80 steps):** System reaches quasi-steady state
37+
- Stress accumulates during slow drive
38+
- No parameter perturbation
39+
- **Observation phase (80–230 steps):** Gradual parameter drift
40+
- Predator death rate increases by +0.05 (slow drive)
41+
- System responds with cascading events if critical
42+
- Stress release and avalanche events detected
43+
44+
## Visualization Output
45+
46+
The script generates `soc_analysis_results.png` with a **2×2 grid displaying the 4 core SOC properties**:
47+
48+
1. **Panel 1 (Top-Left) - Slow Drive:** Gradual parameter drift over time with equilibration and perturbation phases marked
49+
2. **Panel 2 (Top-Right) - Build-up of Stress:** Stress accumulation with avalanche event thresholds marked as orange stars
50+
3. **Panel 3 (Bottom-Left) - Intermittent Release:** Prey and predator population dynamics showing cascade events during perturbation
51+
4. **Panel 4 (Bottom-Right) - Self-Organization:** Stress-density relation across diverse configurations, colored by avalanche activity
52+
53+
## Usage
54+
55+
```bash
56+
python scripts/soc_analysis.py
57+
```
58+
59+
Output:
60+
- Console report with findings
61+
- PNG visualization saved to workspace root: `soc_analysis_results.png`
62+
63+
## Key Observations from Test Run
64+
65+
- **8 diverse configurations** sampled with varied grid sizes, densities, neighborhoods
66+
- **Avalanche detection:** 1/8 experiments showed clear cascade events
67+
- **Stress persistence:** Mean stress ~0.1529 across all configurations
68+
- **Robustness metric:** Coefficient of Variation = 2.646 (indicates some parameter-dependence; lower values → more robust SOC)
69+
- **Population variance:** Consistent across runs (signature of intermittent release mechanism)
70+
71+
## Code Structure
72+
73+
### Main Functions
74+
- `compute_grid_stress()` – Interface-based stress metric
75+
- `compute_population_variance()` – Rolling window variance calculation
76+
- `detect_avalanche_events()` – Identify cascading population changes
77+
- `sample_parameter_configurations()` – Generate diverse parameter sets
78+
- `run_soc_perturbation_experiment()` – Single experiment with slow drive
79+
- `analyze_soc_robustness()` – Cross-configuration robustness metrics
80+
- `visualize_soc_properties()` – Comprehensive 8-panel figure
81+
- `main()` – Orchestrates full analysis pipeline
82+
83+
### Configuration Space
84+
- **Grid size:** Affects stability and relaxation dynamics
85+
- **Densities:** Controls predator-prey interaction frequency
86+
- **Neighborhood:** Changes spatial coupling strength
87+
- **Rates:** Direct influence on birth/death thresholds
88+
89+
## Scientific Interpretation
90+
91+
The analysis tests the hypothesis:
92+
> *"Does the prey-predator CA exhibit self-organized criticality independent of specific parameter choices?"*
93+
94+
If coefficient of variation is **low** (< 1.0) → SOC is **robust** (self-organized)
95+
If coefficient of variation is **high** (> 1.0) → Behavior is **parameter-dependent** (requires tuning)
96+
97+
---
98+
99+
**Created:** January 2026
100+
**Framework:** NumPy, Matplotlib, custom CA simulation

docs/kimon_prompts.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,9 @@ For parallel simulations, use different seeds per worker (e.g., base_seed + work
362362
7. Use the attached legacy simulation function to compute benchmarking resukts for our optimization. Include functionality to save in a csv and plots showing the most significant results. Include flags to run with or without plots and csv output.
363363

364364

365-
8. Write a few run mock tests for the analysis file to see that the plots render properly.
365+
8. Write a few run mock tests for the analysis file to see that the plots render properly.
366+
367+
368+
## Refactoring Main Experiment Script
369+
370+
Help me create a skeletal version of the updated experiments script for HPC that meets tha phase requirements outlined. The config class has been migrated to config.py.

docs/kimon_updates.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,20 @@ NOTE:
297297
Warmup and Measurement time must be scaled according to grid size. We need to write a method to estimate the approximate simulaiton time required. (Sary is working on that.)
298298

299299

300+
## Updates (25/1)
301+
302+
303+
Refactored ```experiments.py``` according to ```experiments.md```. Phase 4 and Phase 6 of the implementation are still unclear to me:
304+
305+
- Phase 4: We are currently varying ```predator_birth``` and ```predator_birth``` only.
306+
307+
- Phase 6: Will implement if all the other phases pass successfully.
308+
309+
TODO: We need to start drafting a proper version of the analyis (```analysis.py```) for postprocessing of all the data we are currenlty collecting and plotting utilities to visualize them.
310+
311+
312+
313+
300314

301315

302316

0 commit comments

Comments
 (0)