How citylearn-project/citylearn works
CityLearn is a Gymnasium environment for simulating building-energy communities and evaluating controllers. The principal workflow is: configure a community and dataset, create an environment and agent, reset and repeatedly exchange observations and actions, then evaluate KPIs and optionally export results. The graph includes the documented capabilities for flexible assets, demand response, electrical constraints, community sharing, dynamic topology, and robustness. Some internals are unsampled; edges to those subsystems are based on the environment’s indexed references or README statements, not inspection of their implementation.
Main entry points: citylearn.py CityLearn environment · building.py Building simulation · base.py Agent API · loading.py Scenario loading
Components 22
Simulation core
- CityLearn environment
citylearn/citylearn.py - Scenario loading
citylearn/internal/loading.py - Dataset access
citylearn/data.py - Episode and time state
citylearn/base.py - Multi-community runs
citylearn/multi_community.py
Buildings and assets
- Building simulation
citylearn/building.py - Energy devices
citylearn/energy_model.py - Electric vehicles
citylearn/electric_vehicle.py - EV chargers
citylearn/electric_vehicle_charger.py - Building dynamics
citylearn/dynamics.py
Controllers
- Agent API
citylearn/agents/base.py - Built-in baselines
citylearn/agents/baseline.py - Rule-based control
citylearn/agents/rbc.py - RL controllers
citylearn/agents
Community services
- Demand response
citylearn/internal/demand_response.py - Dynamic topology
citylearn/internal/topology.py - Failure handling
citylearn/internal/robustness.py - Electrical constraints
citylearn/internal/physics_invariants.py
Evaluation and output
- Reward functions
citylearn/reward_function.py - Community KPIs
citylearn/internal/kpi.py - Result export
citylearn/exporter.py
Other components
- Simulation user
Connections 23
- Simulation user → CityLearn environment: configures and runs
README.md - Simulation user → Agent API: selects controller
README.md - Agent API → CityLearn environment: reads observations; sends actions
README.md - Built-in baselines → Agent API: implements
citylearn/agents/baseline.py - Rule-based control → Agent API: extends
citylearn/agents/rbc.py - RL controllers → Agent API: implements
citylearn/agents/baseline.py - CityLearn environment → Scenario loading: loads scenarios
citylearn/citylearn.py - Scenario loading → Dataset access: retrieves data
citylearn/internal/loading.py - CityLearn environment → Building simulation: coordinates buildings
citylearn/citylearn.py - CityLearn environment → Episode and time state: tracks episodes
citylearn/citylearn.py - Building simulation → Energy devices: uses device models
citylearn/building.py - Building simulation → Electric vehicles: integrates EVs
citylearn/building.py - Building simulation → EV chargers: uses chargers
citylearn/building.py - Building simulation → Building dynamics: uses dynamics
citylearn/building.py - CityLearn environment → Multi-community runs: supports synchronized runs
README.md - CityLearn environment → Demand response: coordinates response
citylearn/citylearn.py - CityLearn environment → Dynamic topology: manages topology
citylearn/citylearn.py - CityLearn environment → Failure handling: handles failures
citylearn/citylearn.py - CityLearn environment → Electrical constraints: checks constraints
citylearn/citylearn.py - CityLearn environment → Reward functions: computes rewards
citylearn/internal/loading.py - CityLearn environment → Community KPIs: evaluates outcomes
citylearn/citylearn.py - CityLearn environment → Result export: exports results
citylearn/citylearn.py - CityLearn environment → Dataset access: uses dataset access
citylearn/citylearn.py