Inspiration

Modern microgrids and Positive Energy Districts (PEDs) operate under extreme operational volatility: rapid fluctuations in solar generation, unpredictable electricity tariffs, battery storage constraints, and sudden grid outages. Traditional microgrid controllers rely either on static, hardcoded rules or unconstrained numerical optimization. Under severe market price spikes or emergency power deficits, a purely economic optimizer can make dangerous recommendations—such as shedding power to life-safety infrastructure (hospitals, emergency communication, or clean water pumping) to minimize short-term cost.

EquiGrid District was born out of a core guiding principle: Optimize what can be optimized. Protect what must be protected. We envisioned a cyber-physical control architecture that leverages Gemini 3.5 Flash for high-level operational reasoning and price arbitrage, wrapped within an un-bypassable, deterministic safety policy boundary aligned with IEA EBC Annex 83 (Positive Energy Districts) and IEEE 2030.7 (Microgrid Controllers).


What it does

EquiGrid District is an autonomous, multi-agent control agent designed for microgrids and PEDs. The system ingests live district telemetry, synthesizes market and weather context, computes optimal economic dispatch, and enforces hard policy guardrails before any action reaches the grid hardware.

1. Mathematical Formulation The system balances cost reduction against explicit security invariants using a constrained decision model:

  • Economic Dispatch Objective Function: $$\min_{P(t)} \sum_{t=1}^{T} \left[ C_{\text{tariff}}(t) \cdot P_{\text{grid}}(t) + C_{\text{deg}} \cdot \vert{}P_{\text{battery}}(t)\vert{} + \sum_{k} \omega_k \cdot P_{\text{shed}, k}(t) \right]$$

where $C_{\text{tariff}}(t)$ is the spot price, $P_{\text{grid}}(t)$ is imported power, $C_{\text{deg}}$ represents battery degradation cost, and $\omega_k$ represents the penalty weighting for shedding flexible load tier $k$.

  • Deterministic Hard Safety Constraint: $$P_{\text{supplied}, i}(t) = P_{\text{demand}, i}(t) \quad \forall t, \quad \text{for all } i \in { \text{PROTECTED_UNINTERRUPTED} }$$

No economic benefit $C_{\text{tariff}}(t)$ or load-shedding penalty $\omega_k$ is permitted to override this invariant.

2. Decision Outcomes

The guardrail agent evaluates dispatch proposals and returns one of three actions:

  • ALLOW: The proposal satisfies all physical and policy safety constraints.
  • MODIFY: The proposal is adjusted (e.g., throttling battery discharge or reducing non-critical loads) to maintain reserve margins.
  • BLOCK: The proposal violates a critical safety boundary (e.g., attempting to shed a hospital load during a grid outage) and is rejected in favor of a hardcoded safe state.

How we built it

EquiGrid District is engineered using a decoupled, multi-agent architecture built on top of the Google Agent Development Kit (ADK):

  • Telemetry & Forecasting Agent: Normalizes district electrical demand, solar output, battery State-of-Charge (SoC), spot pricing, and regional weather parameters across global hubs (Mountain View, Frankfurt, Tokyo, Dublin).

  • Gemini 3.5 Flash Reasoning Core: Synthesizes operational state context, market pricing signals, and severe weather forecasts into dynamic strategy proposals.

  • Economic Dispatch Agent: Evaluates available energy flexibility, plans battery charge/discharge cycles, and calculates tier-based demand reduction.

  • Policy & Safety Guardrail Agent (Google ADK): Intercepts proposals at the deterministic boundary to preserve critical infrastructure protection rules.

  • Backend & Cloud Infrastructure: Powered by FastAPI, containerized with Docker, deployed on Google Cloud Run, and backed by Google Cloud Firestore for immutable, time-stamped decision audit trails.


Challenges we ran into

  • Bounding Probabilistic LLM Outputs: Preventing the reasoning core from acting as an unrestricted control authority required building an isolated deterministic layer in Python where policy logic operates independently of Gemini output.

  • Graceful Degradation & Resilience: Handling transient cloud service issues (e.g., API rate spikes or database connection delays) without breaking physical grid operations. We implemented fallback safe-state logic so the control pipeline defaults to deterministic safety rules if an upstream API fails.

  • Non-Blocking Audit Persistence: Ensuring high-frequency telemetry writes to Firestore did not block the real-time dispatch loop required isolating database operations within asynchronous exception handlers.


Accomplishments that we're proud of

  • Zero Safety Violations Under Outages: Successfully demonstrated complete main-grid failure simulations where 100% of non-critical loads (EV charging, commercial HVAC) were shed while life-safety assets maintained uninterrupted power supply.

  • Standards Alignment: Integrated formal engineering paradigms from IEEE 2030.7 microgrid control standards and IEA Annex 83 Positive Energy District frameworks directly into the decision matrix.

  • Production Deployment: Deployed a fully containerized, live web service on Google Cloud Run with real-time UI dashboard updates, dynamic scenario controls, and automated audit logging.


What we learned

  • AI Assists, Policy Governs: LLMs are extraordinarily effective at synthesizing complex multi-variable context and market forecasting, but safety-critical physical systems must enforce a strict boundary where deterministic software retains absolute veto authority.

  • Auditability is Mandatory: Cyber-physical AI agents require transparent, explainable decision records. Logging operational states, AI rationale, and guardrail verdicts into Firestore proved essential for system debugging and operational trust.


What's next for EquiGrid District — Autonomous PED Control Agent

  • Multi-Horizon Predictive Dispatch: Incorporating short-term probabilistic solar forecasting and dynamic load profiling into multi-period battery optimization.

  • Hardware-in-the-Loop (HIL) Integration: Adding Modbus TCP and IEC 61850 protocol adapters to interface directly with physical microgrid controllers and battery management systems.

  • District Digital Twin: Expanding regional profiles into a full multi-node digital twin for simulated urban resilience stress-testing.

Built With

  • ai-safety
  • cyber-physical-systems
  • docker
  • energy-management
  • fastapi
  • gemini-api
  • google-adk
  • google-cloud-firestore
  • google-cloud-run
  • javascript
  • microgrids
  • multi-agent-systems
  • python
  • smart-grid
Share this project:

Updates

Submission history