CoolFace
Apppublic

channu07/microgrid-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

AI Custodire Resilience Engine for Next-Gen Microgrids

Why This Matters

Power grids are failing. Climate change brings unpredictable solar generation. EV adoption spikes demand overnight. A single fault can cascade into blackouts affecting millions. Today, human operators make split-second decisions about battery dispatch, load shedding, and fault isolation under pressure, with incomplete information.

AI Custodire trains RL agents to do this automatically. An agent that masters microgrid management could prevent blackouts, reduce energy waste, and accelerate the clean energy transition. This is not a toy problem - utilities like ERCOT, NTPC, and Adani Green face these exact challenges daily.

Environment Description

A simulated microgrid with solar generation, battery storage, variable load demand, and circuit switching. The agent acts as an autonomous grid operator, balancing power supply and demand while responding to faults and optimizing operational cost.

Action Space

FieldTypeRangeDescription
battery_dispatchfloat-10 to +10 MWPositive = discharge (supply power), Negative = charge (store power)
load_shedfloat0.0 to 1.0Fraction of load to curtail (0 = none, 1 = cut all)
switch_cmdint0-30=no change, 1=open seg1, 2=open seg2, 3=restore all

Observation Space

FieldTypeNormal RangeDescription
voltage_pufloat0.95-1.05Grid voltage in per-unit
frequency_hzfloat49.5-50.5Grid frequency in Hz
load_mwfloat2-15 MWTotal demand
solar_mwfloat0.5-10 MWSolar generation
battery_socfloat0-1Battery state of charge
netbalancemwfloat-Generation minus demand
fault_activebool-Active fault present
fault_segmentint0-2Faulted segment (0=none)
seg1_energizedbool-Segment 1 powered
seg2_energizedbool-Segment 2 powered

Tasks

TaskDifficultyStepsObjective
load_balanceEasy20Keep netbalancemw near zero across variable solar and load
fault_recoveryMedium30Detect fault at step 6, isolate faulted segment, restore grid
optimal_dispatchHard40Minimize battery cycling cost while maintaining voltage and frequency stability

Reward Design

Rewards are dense every step - agents get continuous feedback, not just end-of-episode:

  • —load_balance: 0-1 per step based on balance quality. Penalizes load shedding and active faults
  • —fault_recovery: -0.4 per step with unhandled fault. +0.4 bonus for correct isolation. 0-0.6 for post-recovery stability
  • —optimal_dispatch: Stability score minus operational cost. Clamped to [0.0, 1.0]

Setup

pip install -e . uvicorn server.app:app --host 0.0.0.0 --port 7860 --reload

Docker

docker build -t microgrid-env . docker run -d -p 7860:7860 microgrid-env

API Endpoints

EndpointMethodDescription
/healthGETHealth check
/resetPOSTReset with task name
/stepPOSTExecute action
/stateGETCurrent state
/tasksGETList tasks with graders
/graderPOSTScore a task episode
/metadataGETEnvironment metadata
/schemaGETAction and observation schemas

Baseline Scores (Qwen2.5-72B-Instruct)

TaskScoreSuccess
load_balance0.920true
fault_recovery0.351true
optimal_dispatch0.776true