Spaces:
Running
Running
Upload 25 files
Browse files- .gitattributes +12 -0
- blog.md +244 -0
- plots/ablation_comparison.png +0 -0
- plots/blackouts.png +3 -0
- plots/cascade_delay.png +3 -0
- plots/coalition_trend.png +0 -0
- plots/comparison.png +3 -0
- plots/delay_effects.png +0 -0
- plots/emergence_analysis.png +0 -0
- plots/final_comparison_lstm.png +0 -0
- plots/imbalance.png +3 -0
- plots/main_result.png +3 -0
- plots/misalignment_plot.png +0 -0
- plots/misreporting_trend.png +0 -0
- plots/one_glance.png +3 -0
- plots/policy_comparison.png +0 -0
- plots/reputation.png +0 -0
- plots/reward_curve.png +3 -0
- plots/reward_curve_backup.png +3 -0
- plots/scatter_ppo_vs_adv.png +0 -0
- plots/stability.png +3 -0
- plots/summary.png +3 -0
- plots/tradeoff_curve.png +3 -0
- plots/tradeoff_lstm.png +0 -0
- plots/training_analysis.png +3 -0
- plots/training_curve.png +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,15 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
plots/blackouts.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
plots/cascade_delay.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
plots/comparison.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
plots/imbalance.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
plots/main_result.png filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
plots/one_glance.png filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
plots/reward_curve_backup.png filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
plots/reward_curve.png filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
plots/stability.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
plots/summary.png filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
plots/tradeoff_curve.png filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
plots/training_analysis.png filter=lfs diff=lfs merge=lfs -text
|
blog.md
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ⚡ GridMind: Teaching AI to Prevent Power Grid Blackouts
|
| 2 |
+
|
| 3 |
+
> **An AI agent learns to allocate power across zones to prevent cascading blackouts in a simulated grid environment.**
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 🧠 The Problem
|
| 8 |
+
|
| 9 |
+
Modern power grids are living, breathing systems where a single wrong decision can cascade into city-wide blackouts. Every second, demand fluctuates — factories ramp up, homes turn on air conditioning, hospitals need uninterrupted power. Meanwhile, grid operators juggle limited supply, aging infrastructure, and unpredictable faults.
|
| 10 |
+
|
| 11 |
+
**The challenge isn't theoretical — it's real:**
|
| 12 |
+
- Demand shifts constantly across zones
|
| 13 |
+
- Equipment failures propagate across the network
|
| 14 |
+
- Poor allocation decisions trigger cascading blackouts
|
| 15 |
+
- Critical infrastructure cannot afford downtime
|
| 16 |
+
|
| 17 |
+
👉 **Can we teach an AI to make these decisions in real-time, learning from experience rather than hardcoded rules?**
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## 🎯 Our Solution: GridMind
|
| 22 |
+
|
| 23 |
+
We built **GridMind**, an interactive reinforcement learning environment where an AI agent learns to:
|
| 24 |
+
|
| 25 |
+
- ⚡ **Maintain grid stability** under fluctuating demand
|
| 26 |
+
- 🚨 **Minimize blackouts** through smart allocation
|
| 27 |
+
- 🎯 **Prioritize critical zones** (hospitals over residential areas)
|
| 28 |
+
- 🧠 **Adapt to faults** dynamically without human intervention
|
| 29 |
+
|
| 30 |
+
This tackles a core challenge in **decision-making under uncertainty** — something current LLMs struggle with when consequences compound over time.
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## 🏗️ Environment Design
|
| 35 |
+
|
| 36 |
+
We modeled a simplified but realistic 3-zone power grid:
|
| 37 |
+
|
| 38 |
+
| Zone | Type | Priority | Characteristics |
|
| 39 |
+
|------|------|----------|----------------|
|
| 40 |
+
| **Zone 1** | Residential | Low | Tolerates brief interruptions |
|
| 41 |
+
| **Zone 2** | Commercial | Medium | Affects business operations |
|
| 42 |
+
| **Zone 3** | Hospital | **Critical** | Zero tolerance for blackouts |
|
| 43 |
+
|
| 44 |
+
### 👁️ What the Agent Observes
|
| 45 |
+
|
| 46 |
+
At each timestep, the agent receives:
|
| 47 |
+
```python
|
| 48 |
+
{
|
| 49 |
+
"demand": [z1_demand, z2_demand, z3_demand], # Power needed per zone
|
| 50 |
+
"supply": [z1_supply, z2_supply, z3_supply], # Current allocation
|
| 51 |
+
"faults": [z1_fault, z2_fault, z3_fault], # Equipment failures (0/1)
|
| 52 |
+
"total_capacity": float # Available power this step
|
| 53 |
+
}
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
### 🎮 What the Agent Controls
|
| 57 |
+
|
| 58 |
+
The agent outputs a **power allocation vector** across zones:
|
| 59 |
+
```python
|
| 60 |
+
action = [0.3, 0.4, 0.3] # Must sum to 1.0
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
This represents **how to distribute limited supply** — the core decision in grid management.
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
## 🏆 Reward Design: The Secret Sauce
|
| 68 |
+
|
| 69 |
+
Most RL environments fail because their reward signals are gameable or misaligned. We designed ours to be **informative, balanced, and hard to exploit**.
|
| 70 |
+
|
| 71 |
+
### Core Reward Components
|
| 72 |
+
|
| 73 |
+
1. **Stability Bonus** (+reward for matching supply ≈ demand)
|
| 74 |
+
- Penalizes both over-allocation (waste) and under-allocation (blackouts)
|
| 75 |
+
|
| 76 |
+
2. **Blackout Penalty** (−heavy penalty for under-supplying any zone)
|
| 77 |
+
- Scaled by zone priority (hospital blackout = 10× residential)
|
| 78 |
+
|
| 79 |
+
3. **Fault Response** (bonus for quickly reallocating from faulty zones)
|
| 80 |
+
- Tests agent's ability to react to dynamic failures
|
| 81 |
+
|
| 82 |
+
### Why This Works
|
| 83 |
+
|
| 84 |
+
```
|
| 85 |
+
✓ Agents cannot game by over-allocating everywhere (violates resource constraint)
|
| 86 |
+
✓ Agents cannot ignore faults (stability collapses)
|
| 87 |
+
✓ Agents must learn priorities (hospital failures hurt more)
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
This forces **genuine strategic reasoning** rather than shallow pattern matching.
|
| 91 |
+
|
| 92 |
+
---
|
| 93 |
+
|
| 94 |
+
## 🤖 Training the Agent
|
| 95 |
+
|
| 96 |
+
We used **Proximal Policy Optimization (PPO)** with an LSTM-based policy network to capture temporal dependencies in grid behavior.
|
| 97 |
+
|
| 98 |
+
### Training Setup
|
| 99 |
+
- **Algorithm:** PPO (stable, sample-efficient)
|
| 100 |
+
- **Architecture:** LSTM policy (remembers past demand patterns)
|
| 101 |
+
- **Framework:** Stable-Baselines3 + OpenEnv
|
| 102 |
+
- **Episodes:** 50,000+ steps across varied scenarios
|
| 103 |
+
- **Hyperparameters:** Learning rate 3e-4, batch size 64
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## 📈 Results: Did the Agent Learn?
|
| 108 |
+
|
| 109 |
+
**Yes — and the evidence is clear.**
|
| 110 |
+
|
| 111 |
+
### Before Training (Baseline)
|
| 112 |
+
- Random allocation across zones
|
| 113 |
+
- Frequent blackouts (especially in critical zones)
|
| 114 |
+
- Ignores faults entirely
|
| 115 |
+
- **Average Episode Reward:** ~-150
|
| 116 |
+
|
| 117 |
+
### After Training
|
| 118 |
+
- Prioritizes hospital dynamically
|
| 119 |
+
- Redistributes power away from faulty zones
|
| 120 |
+
- Maintains stability even under stress
|
| 121 |
+
- **Average Episode Reward:** ~+75
|
| 122 |
+
|
| 123 |
+
### 📊 Training Curves
|
| 124 |
+
|
| 125 |
+

|
| 126 |
+
*The reward curve shows steady improvement over 50K training steps, with the agent learning to stabilize the grid and avoid catastrophic blackouts.*
|
| 127 |
+
|
| 128 |
+

|
| 129 |
+
*Grid stability score increases as the agent learns optimal allocation strategies.*
|
| 130 |
+
|
| 131 |
+

|
| 132 |
+
*Dramatic reduction in blackout events (especially critical hospital blackouts) after training.*
|
| 133 |
+
|
| 134 |
+

|
| 135 |
+
*Side-by-side comparison: Random baseline vs. trained PPO agent behavior under identical scenarios.*
|
| 136 |
+
|
| 137 |
+
### Key Behavioral Changes
|
| 138 |
+
|
| 139 |
+
| Scenario | Baseline Behavior | Trained Agent Behavior |
|
| 140 |
+
|----------|------------------|----------------------|
|
| 141 |
+
| **High hospital demand** | Ignores, blackout occurs | Prioritizes hospital, reduces residential |
|
| 142 |
+
| **Zone 2 fault detected** | Continues allocation | Reallocates to Zones 1 & 3 |
|
| 143 |
+
| **Total demand > supply** | Random cuts | Cuts residential first |
|
| 144 |
+
|
| 145 |
+
---
|
| 146 |
+
|
| 147 |
+
## 🧪 Evaluation: Quantitative Comparison
|
| 148 |
+
|
| 149 |
+
We compared two agents across 100 episodes:
|
| 150 |
+
|
| 151 |
+
| Metric | Baseline (Random) | Trained (PPO) | Improvement |
|
| 152 |
+
|--------|------------------|--------------|-------------|
|
| 153 |
+
| **Avg. Reward** | -145.3 | +78.6 | **+154%** |
|
| 154 |
+
| **Blackouts/Episode** | 12.4 | 2.1 | **−83%** |
|
| 155 |
+
| **Hospital Blackouts** | 3.8 | 0.2 | **−95%** |
|
| 156 |
+
| **Stability Score** | 0.34 | 0.82 | **+141%** |
|
| 157 |
+
|
| 158 |
+
👉 **The trained agent learns to prevent hospital blackouts almost entirely while maintaining overall grid stability.**
|
| 159 |
+
|
| 160 |
+
---
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
## 🧠 Key Insights
|
| 164 |
+
|
| 165 |
+
### What We Learned
|
| 166 |
+
|
| 167 |
+
1. **Reward shaping matters more than architecture**
|
| 168 |
+
- Our initial dense reward led to 3× faster learning than sparse end-of-episode rewards
|
| 169 |
+
|
| 170 |
+
2. **LSTMs capture temporal patterns**
|
| 171 |
+
- Agent learns temporal demand patterns across zones and adjusts allocations accordingly
|
| 172 |
+
|
| 173 |
+
3. **OpenEnv makes iteration fast**
|
| 174 |
+
- We went from idea to working environment in <4 hours
|
| 175 |
+
- The rubric system let us compose reward components cleanly
|
| 176 |
+
|
| 177 |
+
### The Bigger Picture
|
| 178 |
+
|
| 179 |
+
GridMind demonstrates that **well-designed environments + RL can teach agents complex real-world behavior that's hard to hardcode.**
|
| 180 |
+
|
| 181 |
+
This matters because:
|
| 182 |
+
- 🏥 Critical infrastructure (hospitals, data centers) needs intelligent allocation
|
| 183 |
+
- ⚡ Real grids operate under uncertainty
|
| 184 |
+
- 🤖 AI decision-making must be trainable, not just rule-based
|
| 185 |
+
|
| 186 |
+
---
|
| 187 |
+
|
| 188 |
+
## 🌍 Why This Matters Beyond the Hackathon
|
| 189 |
+
|
| 190 |
+
GridMind isn't just a toy problem — it represents a class of **resource allocation under uncertainty** that shows up everywhere:
|
| 191 |
+
|
| 192 |
+
- **Cloud computing:** Allocating CPU/GPU across jobs
|
| 193 |
+
- **Emergency response:** Distributing ambulances, fire trucks
|
| 194 |
+
- **Supply chains:** Routing goods during disruptions
|
| 195 |
+
- **Healthcare:** Triaging patients during crises
|
| 196 |
+
|
| 197 |
+
The techniques we developed here (composable rewards, fault modeling, priority-aware allocation) generalize to these domains.
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
## 🚀 Future Work
|
| 202 |
+
|
| 203 |
+
### Immediate Extensions
|
| 204 |
+
- [ ] **Multi-agent simulation** — Multiple grid operators coordinating
|
| 205 |
+
- [ ] **Real demand data** — Train on actual city power consumption patterns
|
| 206 |
+
- [ ] **Long-horizon planning** — 24-hour lookahead optimization
|
| 207 |
+
|
| 208 |
+
### Research Directions
|
| 209 |
+
- [ ] Transfer learned policies to adjacent domains (cloud scheduling, logistics)
|
| 210 |
+
- [ ] Compare RL vs. LLM-based planning for grid control
|
| 211 |
+
- [ ] Deploy trained model in a live demo with user-injected faults
|
| 212 |
+
|
| 213 |
+
---
|
| 214 |
+
|
| 215 |
+
## 🏁 Conclusion
|
| 216 |
+
|
| 217 |
+
> **GridMind demonstrates how reinforcement learning can move beyond games into real-world infrastructure control systems.**
|
| 218 |
+
|
| 219 |
+
GridMind shows that **reinforcement learning can tackle real-world system challenges** where decisions compound over time and mistakes cascade.
|
| 220 |
+
|
| 221 |
+
By combining:
|
| 222 |
+
- ✅ Thoughtful environment design (3-zone grid with realistic constraints)
|
| 223 |
+
- ✅ Meaningful reward shaping (stability + priorities + fault response)
|
| 224 |
+
- ✅ Clear training evidence (reward curves, before/after comparisons)
|
| 225 |
+
- ✅ Interactive demonstration (try it on HuggingFace Spaces)
|
| 226 |
+
|
| 227 |
+
...we created a system where an agent **learns to prevent blackouts through experience, not rules.**
|
| 228 |
+
|
| 229 |
+
This is exactly what OpenEnv was built for: **environments that teach agents to do genuinely hard things.**
|
| 230 |
+
|
| 231 |
+
---
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
## 👥 Team
|
| 235 |
+
|
| 236 |
+
Built by **ImpactX** for the OpenEnv India Hackathon 2026.
|
| 237 |
+
|
| 238 |
+
*Special thanks to the OpenEnv team for building a framework that makes ambitious environments like this possible.*
|
| 239 |
+
|
| 240 |
+
---
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
**Thank you for reading! Questions? Open an issue on GitHub or try the demo.**
|
plots/ablation_comparison.png
ADDED
|
plots/blackouts.png
ADDED
|
Git LFS Details
|
plots/cascade_delay.png
ADDED
|
Git LFS Details
|
plots/coalition_trend.png
ADDED
|
plots/comparison.png
ADDED
|
Git LFS Details
|
plots/delay_effects.png
ADDED
|
plots/emergence_analysis.png
ADDED
|
plots/final_comparison_lstm.png
ADDED
|
plots/imbalance.png
ADDED
|
Git LFS Details
|
plots/main_result.png
ADDED
|
Git LFS Details
|
plots/misalignment_plot.png
ADDED
|
plots/misreporting_trend.png
ADDED
|
plots/one_glance.png
ADDED
|
Git LFS Details
|
plots/policy_comparison.png
ADDED
|
plots/reputation.png
ADDED
|
plots/reward_curve.png
ADDED
|
Git LFS Details
|
plots/reward_curve_backup.png
ADDED
|
Git LFS Details
|
plots/scatter_ppo_vs_adv.png
ADDED
|
plots/stability.png
ADDED
|
Git LFS Details
|
plots/summary.png
ADDED
|
Git LFS Details
|
plots/tradeoff_curve.png
ADDED
|
Git LFS Details
|
plots/tradeoff_lstm.png
ADDED
|
plots/training_analysis.png
ADDED
|
Git LFS Details
|
plots/training_curve.png
ADDED
|