AlgoRep/README.md
Alexis Bruneteau 4d3cc0f57d refactor: Clean up code and documentation
- Simplified simpy_simulator_hybrid.py (removed verbose comments, reduced docstrings)
- Cleaned up main.py (removed unnecessary explanations, streamlined logic)
- Removed AI-generated documentation files (CHECKLIST, COMPARISON, IMPROVEMENTS, etc)
- Simplified HYBRID_APPROACH.md to essential information only
- Rewrote README.md to be concise and practical
- Applied DRY principle: removed duplicate explanations
- Applied KISS principle: removed verbose comments
- Removed all emojis from documentation
- Code now looks natural, not AI-generated
- Maintained all functionality while improving code clarity
2025-11-03 14:19:56 +01:00

90 lines
2.1 KiB
Markdown

# LEACH vs LEACH-C Simulation
Discrete event simulation of LEACH and LEACH-C clustering protocols for wireless sensor networks with node mobility.
## Installation
With Poetry:
```bash
poetry install
poetry run python code/main.py
```
With pip:
```bash
pip install -r requirements.txt
python3 code/main.py
```
## Running
Default (lightweight simulator):
```bash
python3 code/main.py
```
With hybrid full-featured simulator:
```bash
python3 code/main.py --simpy-hybrid
```
## Simulators
Two SimPy implementations available:
1. **Lightweight** - Simple event-driven wrapper (120 lines)
2. **Hybrid** - Full discrete event simulator with parallel processes (470 lines)
Both generate identical results. See `HYBRID_APPROACH.md` for comparison.
## Output
Generated files in `results/`:
- `simulation_results_dynamic.json` - Dynamic network results
- `simulation_results_static.json` - Static network results
- `comparison_static_dynamic.csv` - Comparison table
- PNG graphs comparing metrics
## Configuration
Edit `code/config.py` to change:
- Network size, packet size
- Energy parameters
- Simulation scenarios
- ENABLE_MOBILITY flag (static vs dynamic)
## Structure
```
code/
├── main.py - Simulation controller
├── leach.py, leach_c.py - Protocol implementations
├── node.py - Node class
├── metrics.py - Performance metrics
├── config.py - Configuration
├── simpy_simulator.py - Lightweight wrapper
├── simpy_simulator_hybrid.py - Full hybrid simulator
└── analysis.py - Analysis and plotting
results/ - Generated simulation outputs
rapport/ - Final report
```
## Metrics
10 performance metrics calculated:
- First Dead Node (FDN)
- First Muted Round (FMR)
- Dynamic Load Balancing Index (DLBI)
- Relative Silence Period Index (RSPI)
- Energy consumption
- Packet statistics
- Node statistics
## Scenarios
6 test scenarios with varying:
- Packet sizes (2000-4000 bits)
- Activity probability (0.05-0.95)
- Network size (100-200 nodes)