barcli-mesa / README.md
Jokar-man's picture
Upload 6 files
de9025d verified
|
Raw
History Blame Contribute Delete
1.89 kB
metadata
title: Barcli Mesa API
emoji: 🌑️
colorFrom: blue
colorTo: red
sdk: docker
pinned: false
short_description: Mesa ABM simulation API for Barcelona climate vulnerability

Barcli Mesa API

FastAPI backend providing Mesa-based agent simulation for the Barcli frontend.

Endpoints

Method Path Description
GET /health Liveness check
POST /simulate/single Single-agent A* pathfinding with climate weighting
POST /simulate/multi 20-agent shelter-seeking with 4 personas

POST /simulate/single

{
  "start": [-2.1734, 41.3851],
  "end":   [-2.1700, 41.3900],
  "climate_weight": 0.5,
  "baseline_index": null,
  "policy_index":   null
}

Returns baseline_path, policy_path (arrays of [lng, lat]) and baseline_profile, policy_profile (vulnerability scores 0–1 per node).

POST /simulate/multi

{
  "shelter_coord": [-2.1720, 41.3870],
  "baseline_index": null,
  "policy_index":   null,
  "seed": 42
}

Returns per-frame baseline_snapshots/policy_snapshots and persona_breakdown with arrived counts per persona.

Data files required

Place these in the data/ directory (same files as the frontend's public/data/):

  • data/climate_isochrone.geojson β€” road network (LineString features)
  • data/data.geojson β€” climate vulnerability points (heat, SPEI, urban_health fields)
  • data/climate_shelters.geojson β€” shelter locations (Point features)

Files

β”œβ”€β”€ app.py            FastAPI app + graph loading + routes
β”œβ”€β”€ mesa_single.py    Mesa single-agent A* model
β”œβ”€β”€ mesa_multi.py     Mesa multi-agent shelter model
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
└── data/
    β”œβ”€β”€ climate_isochrone.geojson
    β”œβ”€β”€ data.geojson
    └── climate_shelters.geojson