citylearn.multi_community module
- class citylearn.multi_community.MultiCommunityEnv(*, communities: Sequence[Mapping[str, Any]], render_directory: str | Path = None, render_session_name: str = None)[source]
Bases:
EnvSynchronize multiple independent
CityLearnEnvcommunities.V1 is an orchestration layer only: every child environment keeps its own physics, demand response state, reward and KPIs. The wrapper coordinates reset/step calls and adds portfolio-level KPI rows from district totals.
- PORTFOLIO_COMMUNITY_ID = '__portfolio__'
- PORTFOLIO_NAME = 'Portfolio'
- property action_space: Mapping[str, Any]
Action spaces keyed by community id.
- property central_agent: bool
Common child environment central-agent mode.
- property community_ids: List[str]
Community identifiers in deterministic execution order.
- property entity_specs: Mapping[str, Any]
Entity interface specifications keyed by community id.
- property episode_time_steps: int
Effective episode length in synchronized child environments.
- evaluate_v2(control_condition: EvaluationCondition = None, baseline_condition: EvaluationCondition = None, comfort_band: float = None, include_business_as_usual: bool = True) DataFrame[source]
Return local child KPIs plus portfolio rows aggregated from district KPIs.
- export_final_kpis(model: Any = None, filepath: str = 'exported_kpis_multi_community.csv', include_business_as_usual: bool = True, export_business_as_usual_timeseries: bool = True, kpi_round_decimals: int = None, export_community_kpis: bool = True, community_filepath: str = 'exported_kpis.csv')[source]
Export child KPIs to child folders and global multi-community KPIs.
- property interface: str
Common child environment interface mode.
- property observation_space: Mapping[str, Any]
Observation spaces keyed by community id.
- property observations: Mapping[str, Any]
Current child observations keyed by community id.
- render() Mapping[str, Any][source]
Render every child environment into its own community subfolder.
- reset(seed: int = None, options: Mapping[str, Any] = None) Tuple[Mapping[str, Any], Mapping[str, Any]][source]
Reset every child environment and return observations by community.
- property rewards: Mapping[str, Any]
Child reward histories keyed by community id.
- property seconds_per_time_step: float
Common step duration in seconds.
- step(actions: Mapping[str, Any]) Tuple[Mapping[str, Any], Mapping[str, Any], bool, bool, Mapping[str, Any]][source]
Apply one action payload per community and advance all child envs once.
- property terminated: bool
Whether any child environment has terminated.
- property time_step: int
Current synchronized time step.
- property time_steps: int
Number of time steps in the synchronized episode.
- property truncated: bool
Whether any child environment has truncated.
- property unwrapped: MultiCommunityEnv
Returns the base non-wrapped environment.
- Returns:
The base non-wrapped
gymnasium.Envinstance- Return type:
Env
- property weights: Dict[str, float]
Portfolio aggregation weights by community id.