CoolFace
Apppublic

Thrishu/disaster-response-env

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

๐ŸŒŠ Disaster Response Coordinator Agent

Overview

A flood disaster is unfolding across multiple zones. You are the AI coordinator. You have limited rescue teams, medical kits, food supplies, helicopters, and flood barriers. Roads wash out. Floods intensify. Storms arrive without warning.

Your decisions directly determine how many people survive.

This is a real operational problem โ€” disaster response coordinators face exactly this resource-allocation-under-uncertainty challenge in real emergencies. The environment models the core trade-offs: triage vs. fairness, flood prevention vs. immediate rescue, and helicopter deployment for cut-off zones.


Observation Space

FieldTypeDescription
zones[].idstrZone identifier
zones[].populationintTotal residents
zones[].injuredintCurrently injured people
zones[].flood_levelint (0โ€“10)Flood severity; โ‰ฅ8 causes rapid new casualties
zones[].accessstropen / road_blocked / air_only
zones[].shelteredintPeople moved to safe shelter
zones[].flood_control_levelint (0โ€“5)Deployed barrier strength
resources.rescue_teamsintAvailable rescue teams
resources.food_unitsintAvailable food units
resources.medical_kitsintAvailable medical kits
resources.helicoptersintHelicopters (required for blocked zones)
resources.flood_barriersintDeployable flood barriers
weatherstrclear / heavy_rain / storm
time_stepintCurrent step in episode
total_rescuedintCumulative rescues this episode
total_casualtiesintCumulative fatalities this episode

Action Space

All fields are Dict[zone_id, int]. Total allocations across zones must not exceed available resources.

FieldEffect
allocate_rescueEach team rescues up to 10 injured (1.5ร— if helicopter co-deployed)
send_foodProvides survival support; bonus scales with injury ratio
send_medicalEach kit heals up to 3 injured
deploy_helicoptersRequired to reach road_blocked or air_only zones; also boosts rescue efficiency
deploy_barriersIncreases flood_control_level, reducing future flood rise
evacuateMoves civilians to shelter, reducing future injury exposure

Key constraint: road_blocked and air_only zones receive no rescue, medical, or food unless helicopters are also sent there.


Reward Function

Rewards are shaped across the full trajectory (not just end-of-episode):

  • โ€”+0.03 per person rescued via rescue teams
  • โ€”+0.015 per person healed via medical kits
  • โ€”+0.003โ€“0.006 per food unit (scaled by zone need)
  • โ€”+0.02 per flood barrier deployed
  • โ€”+0.005 per person evacuated
  • โ€”โˆ’0.05 to โˆ’0.25 per step for high flood levels (โ‰ฅ7 and โ‰ฅ9)
  • โ€”โˆ’0.1 to โˆ’0.3 per step for high injury ratios (>15% and >30%)
  • โ€”โˆ’0.15 for over-allocating resources (exceeding available stock)
  • โ€”โˆ’0.2 for taking no action (idle penalty)

Grader

Final episode score (0.0โ€“1.0) combines:

ComponentWeightDescription
Survival rate35%1 - (total_injured / total_population)
Casualty control20%Penalises cumulative fatalities
Flood control20%Average final flood level below critical
Equity15%Worst-zone survival relative to average
Shelter rate10%Proportion of population sheltered

Tasks

๐ŸŸข Easy

  • โ€”Zones: 1 (open access)
  • โ€”Steps: 10
  • โ€”Challenge: Basic allocation, moderate flood
  • โ€”Baseline (rule-based): ~0.50โ€“0.60
  • โ€”Good agent target: ~0.75โ€“0.85

๐ŸŸก Medium

  • โ€”Zones: 2 (one road-blocked)
  • โ€”Steps: 15
  • โ€”Challenge: Must use helicopters to reach blocked zone; heavier injuries
  • โ€”Baseline (rule-based): ~0.35โ€“0.45
  • โ€”Good agent target: ~0.65โ€“0.75

๐Ÿ”ด Hard

  • โ€”Zones: 3 (one road-blocked, one air-only from start)
  • โ€”Steps: 20
  • โ€”Challenge: Active storm, only 2 helicopters for 2 blocked zones โ€” agent must triage
  • โ€”Baseline (rule-based): ~0.20โ€“0.30
  • โ€”Good agent target: ~0.55โ€“0.65

API

\POST /reset?task=easy|medium|hard   โ†’ initial observation
POST /step                          โ†’ next observation, reward, done, info
POST /grade                         โ†’ final episode score (0.01โ€“0.99)
GET  /state                         โ†’ current observation
GET  /health                        โ†’ {"status": "ok"}

Example: Reset and Step

python
import requests, json

BASE = "http://localhost:7860"

obs = requests.post(f"{BASE}/reset?task=medium").json()

action = {
    "allocate_rescue":    {"A": 2, "B": 1},
    "send_food":          {"A": 20, "B": 15},
    "send_medical":       {"A": 10, "B": 8},
    "deploy_helicopters": {"B": 1},   # B is road_blocked โ€” helicopter required!
    "deploy_barriers":    {"B": 1},
    "evacuate":           {"A": 50}
}

result = requests.post(f"{BASE}/step", json=action).json()
print(result["reward"], result["done"])

Setup

Docker

bash
docker build -t disaster-response-env .
docker run -p 7860:7860 disaster-response-env

Local (Python)

bash
pip install fastapi uvicorn pydantic openai openenv-core
uvicorn server.app:app --host 0.0.0.0 --port 7860

Run Inference

bash
export API_BASE_URL=https://api.openai.com/v1
export MODEL_NAME=gpt-4o-mini
export HF_TOKEN=hf_...   # required โ€” passed as OpenAI client api_key (see submission guidelines)

python inference.py

Project Structure

.
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ openenv.yaml
โ”œโ”€โ”€ inference.py          # baseline inference script
โ”œโ”€โ”€ env.py                # core DisasterEnv
โ”œโ”€โ”€ models.py             # Observation, Action, Reward pydantic models
โ”œโ”€โ”€ grader.py             # deterministic episode scorer
โ”œโ”€โ”€ tasks/
โ”‚   โ”œโ”€โ”€ easy.py
โ”‚   โ”œโ”€โ”€ medium.py
โ”‚   โ””โ”€โ”€ hard.py
โ””โ”€โ”€ server/
    โ””โ”€โ”€ app.py            # FastAPI server

Author

Thrishank