Inspiration
Urban energy grids lose 15–30% of generated power through suboptimal distribution routing. For a mid-sized city, that's hundreds of megawatts wasted daily — translating to unnecessary CO₂ emissions and inflated electricity costs. Static routing rules cannot adapt to real-time demand spikes. During peak hours, critical nodes like hospitals often receive sub-optimal supply while other parts of the grid are over-provisioned. NEXUS GRID turns this into a solved computational problem.
What it does
NEXUS GRID is a full-stack urban energy optimization platform that models a city's power grid as a weighted directed graph and continuously rebalances energy flows using three classical algorithms — Genetic Algorithm, Simulated Annealing, and Min-Cost Flow — to minimize transmission losses, reduce CO₂ emissions, and guarantee supply to critical infrastructure like hospitals and data centers. The platform features: +Live 60fps animated grid visualization — energy particles flow through the transmission network, lines change color from green → amber → red as capacity loads up, and every node displays a real-time demand satisfaction indicator. +Three switchable optimization algorithms** with configurable hyperparameters and live convergence curves. +AI Grid Intelligence powered by the Claude API — a natural language interface where operators can ask about failure scenarios, optimization logic, and demand predictions. +24-hour demand forecasting showing predicted, actual, and post-optimization consumption curves. +Impact dashboard tracking energy saved, CO₂ reduced, and cost savings in real time.
How we built it
+Graph Model: The city is modeled as a directed weighted graph with 12 nodes (2 power sources, 4 substations, 6 district hubs including critical nodes) and 18 transmission edges. Each edge carries capacity, transmission cost, and resistance (for I²R loss calculation). +Multi-Objective Fitness Function: F(flows) = -(transmission_cost + 0.6 × I²R_losses + demand_penalty) +Critical nodes (hospital, data center) carry 22× demand penalty vs 9× for standard districts, ensuring they are always prioritized. +Genetic Algorithm: Population-based evolutionary search. Tournament selection from elite pool, uniform crossover, Gaussian mutation, configurable elitism. Runs 250 generations, typically converging in ~150. +Simulated Annealing: Boltzmann-schedule probabilistic acceptance of worse states allows escape from local minima. Temperature anneals from [100–5000] at a configurable cooling rate [0.80–0.99]. +Min-Cost Flow: Successive shortest paths via Bellman-Ford relaxation. Each step identifies the most under-served demand node and augments flow along the minimum-cost path. Guarantees globally optimal flow in polynomial time. +Visualization: HTML Canvas API with a custom particle system — particles are spawned at source nodes, travel along transmission edges at speeds proportional to flow rate, and fade out at destination nodes. Edge thickness and color encode current load. +AI Layer: Claude API (claude-sonnet-4-20250514) with a structured system prompt containing the live grid state — node-by-node demand satisfaction %, edge load percentages, current algorithm and generation. Operators get intelligent, data-grounded answers in natural language.
Challenges we ran into
1.Algorithm correctness vs. visual appeal: The genetic algorithm needs to be fast enough for 75ms intervals while still being mathematically valid. I had to carefully balance population size, elitism rate, and mutation scale to avoid premature convergence while keeping the visualization responsive.
2.Multi-objective optimization: Balancing three competing objectives (cost, I²R loss, demand satisfaction) required careful weight tuning. The critical-node penalty weight (22×) was empirically determined to ensure hospitals never dip below 90% satisfaction.
3.Canvas performance: Rendering 300+ particles at 60fps alongside glow effects and 18 edge lines required strict particle lifecycle management and selective glow rendering (only applied when load > 72%).
Accomplishments that we're proud of
-Three completely independent algorithm implementations that all operate on the same graph model and fitness function — making them directly comparable:
- A convergence visualization that makes abstract algorithmic behavior legible to a non-technical audience.
- The AI integration gives the platform a genuine "control room" feel — you can ask "what happens if Substation Alpha fails?" and get a data-grounded answer about cascade effects.
What we learned
Implementing all three algorithms from scratch revealed how differently they explore the search space. GA rapidly finds good regions via parallel search but can plateau. SA's temperature schedule makes it deterministically converge but slowly. MCF is blazingly fast for well-structured graphs but struggles with the multi-objective framing. The best real-world system would use a hybrid: MCF for initial feasibility, then GA/SA for multi-objective fine-tuning.
What's next for NEXUS GRID — Urban Energy Intelligence Platform
+Real grid data integration: Connect to IEEE power grid benchmark datasets (IEEE 14-bus, 30-bus) for realistic validation. +Failure mode simulation: Click a node to "cut" it and watch the algorithms reroute flows in real time Multi-period optimization: Extend from single-snapshot to 24-hour rolling optimization with demand forecasting in the loop +Renewable integration: Add weather-dependent solar/wind generation nodes with stochastic output modeling +Digital twin deployment: Package as a REST API that can sit alongside real SCADA systems.
Built With
- anthropicclaudeapi
- googlefonts
- html5canvaapi
- javascript
- vercel
Log in or sign up for Devpost to join the conversation.