diff --git a/smart_control/dataset/dataset.py b/smart_control/dataset/dataset.py index 435f7ed1..a66bb6dc 100644 --- a/smart_control/dataset/dataset.py +++ b/smart_control/dataset/dataset.py @@ -71,18 +71,18 @@ def zip_filepath(self): def building_dirpath(self): """The local directory containing the building's dataset, after it has been extracted from the local zip file. - """ + """ # pylint: disable=line-too-long return os.path.join(DATA_DIR, self.dataset_id) def download(self, timeout=60): """Downloads the building's dataset from Google Cloud Storage. Only downloads and unzips the dataset if it doesn't already exist at the - expected [`building_dirpath`](./#smart_control.dataset.dataset.BuildingDataset.building_dirpath) + expected [`building_dirpath`][smart_control.dataset.dataset.BuildingDataset.building_dirpath] location. Otherwise it will load the existing local data. Download speed is fairly quick, but unzipping takes a few moments. - """ + """ # pylint: disable=line-too-long if os.path.isdir(self.building_dirpath): print("Using previously-downloaded data...") print(os.path.abspath(self.building_dirpath)) @@ -119,9 +119,9 @@ def floorplan(self) -> np.ndarray: + 1: wall / boundary + 2: outside / external space - Use the [`display_floorplan`](./#smart_control.dataset.dataset.BuildingDataset.display_floorplan) + Use the [`display_floorplan`][smart_control.dataset.dataset.BuildingDataset.display_floorplan] method to view an image of the floorplan. - """ + """ # pylint: disable=line-too-long return np.load(self.floorplan_filepath) @property @@ -149,8 +149,8 @@ def display_floorplan( show (bool): Whether or not to show the image. save (bool): Whether or not to save the image (as a .png file). image_filepath (str): An optional custom filepath to use when saving the - image. Only applies if `save=True`. By default, saves to the [`floorplan_image_filepath`](./#smart_control.dataset.dataset.BuildingDataset.floorplan_image_filepath) - """ + image. Only applies if `save=True`. By default, saves to the [`floorplan_image_filepath`][smart_control.dataset.dataset.BuildingDataset.floorplan_image_filepath] + """ # pylint: disable=line-too-long plt.imshow(self.floorplan, interpolation="nearest", cmap=cmap) if show: plt.show() diff --git a/smart_control/dataset/partition.py b/smart_control/dataset/partition.py index ebfee3fc..f911c684 100644 --- a/smart_control/dataset/partition.py +++ b/smart_control/dataset/partition.py @@ -84,7 +84,7 @@ def metadata_filepath(self): @cached_property def metadata(self) -> dict: - """Metadata describing the partition [`data`](./#smart_control.dataset.partition.BuildingDatasetPartition.data). + """Metadata describing the partition [`data`][smart_control.dataset.partition.BuildingDatasetPartition.data]. Returns: A dictionary containing the following keys: @@ -99,7 +99,7 @@ def metadata(self) -> dict: Each of these keys has a corresponding public method for convenience. See corresponding documentation below for more information about each. - """ + """ # pylint: disable=line-too-long metadata = pickle.load(open(self.metadata_filepath, "rb")) # renaming keys: metadata = { @@ -146,20 +146,20 @@ def action_ids_map(self) -> dict: """A mapping of unique action identifiers. Returns: - A dictionary where the keys are the [`action_ids`](./#smart_control.dataset.partition.BuildingDatasetPartition.action_ids) + A dictionary where the keys are the [`action_ids`][smart_control.dataset.partition.BuildingDatasetPartition.action_ids] and the values are unique integers referencing column indices in the - [`action_value_matrix`](./#smart_control.dataset.partition.BuildingDatasetPartition.action_value_matrix) + [`action_value_matrix`][smart_control.dataset.partition.BuildingDatasetPartition.action_value_matrix] For example: - ```py +```py { '12945159110931775488@supply_air_temperature_setpoint': 0, '13761436543392677888@supply_water_temperature_setpoint': 1, '14409954889734029312@supply_air_temperature_setpoint': 2 } - ``` - """ +``` + """ # pylint: disable=line-too-long return self.metadata["action_ids_map"] @cached_property @@ -167,20 +167,20 @@ def observation_ids_map(self) -> dict: """A mapping of unique observation identifiers. Returns: - A dictionary where the keys are the [`observation_ids`](./#smart_control.dataset.partition.BuildingDatasetPartition.observation_ids) + A dictionary where the keys are the [`observation_ids`][smart_control.dataset.partition.BuildingDatasetPartition.observation_ids] and the values are unique integers referencing column indices in the - [`observation_value_matrix`](./#smart_control.dataset.partition.BuildingDatasetPartition.observation_value_matrix). + [`observation_value_matrix`][smart_control.dataset.partition.BuildingDatasetPartition.observation_value_matrix]. For example: - ```py +```py { '202194278473007104@building_air_static_pressure_setpoint', 0, ... '2640423556868160@zone_air_temperature_sensor': 1197 } - ``` - """ +``` + """ # pylint: disable=line-too-long return self.metadata["observation_ids_map"] @cached_property @@ -190,19 +190,19 @@ def reward_info_ids_map(self) -> dict: See: `RewardInfo` in "smart_control/proto/smart_control_reward.proto". Returns: - A dictionary where the keys are the [`reward_info_ids`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_info_ids) - and the values are unique integers referencing column indices in the [`reward_info_value_matrix`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_info_value_matrix). + A dictionary where the keys are the [`reward_info_ids`][smart_control.dataset.partition.BuildingDatasetPartition.reward_info_ids] + and the values are unique integers referencing column indices in the [`reward_info_value_matrix`][smart_control.dataset.partition.BuildingDatasetPartition.reward_info_value_matrix]. For example: - ```py +```py { 'rooms/9028552126@heating_setpoint_temperature': 0 ... '14409954889734029312@air_conditioning_electrical_energy_rate': 3251 } - ``` - """ +``` + """ # pylint: disable=line-too-long return self.metadata["reward_info_ids_map"] @cached_property @@ -212,9 +212,9 @@ def reward_ids_map(self) -> dict: See: `RewardResponse` in "smart_control/proto/smart_control_reward.proto". Returns: - A dictionary where the keys are the [`reward_ids`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_ids) - and the values are unique integers referencing column indices in the [`reward_value_matrix`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_value_matrix). - """ + A dictionary where the keys are the [`reward_ids`][smart_control.dataset.partition.BuildingDatasetPartition.reward_ids] + and the values are unique integers referencing column indices in the [`reward_value_matrix`][smart_control.dataset.partition.BuildingDatasetPartition.reward_value_matrix]. + """ # pylint: disable=line-too-long return { "agent_reward_value": 0, "productivity_reward": 1, @@ -235,6 +235,7 @@ def reward_ids_map(self) -> dict: "normalized_carbon_emission": 16, } + @cached_property def action_ids(self) -> list[str]: """A list of unique action identifiers. @@ -340,13 +341,12 @@ def _construct_time_series_df(self, matrix_name, ids_name, timestamps_name): @cached_property def actions_df(self) -> pd.DataFrame: - # pylint: disable=line-too-long """A time-series dataframe of numeric action values, constructed from the following components: - + Columns are the [`action_ids`](./#smart_control.dataset.partition.BuildingDatasetPartition.action_ids) - + Row indices are the [`action_timestamps`](./#smart_control.dataset.partition.BuildingDatasetPartition.action_timestamps) - + Cell values are from the [`action_value_matrix`](./#smart_control.dataset.partition.BuildingDatasetPartition.action_value_matrix) + + Columns are the [`action_ids`][smart_control.dataset.partition.BuildingDatasetPartition.action_ids] + + Row indices are the [`action_timestamps`][smart_control.dataset.partition.BuildingDatasetPartition.action_timestamps] + + Cell values are from the [`action_value_matrix`][smart_control.dataset.partition.BuildingDatasetPartition.action_value_matrix] Returns: A `pandas.DataFrame`. Here is an example of the structure: @@ -359,8 +359,7 @@ def actions_df(self) -> pd.DataFrame: | 2022-01-01 00:15:00+00:00 | 288.703705 | ... | 291.481476 | | 2022-01-01 00:20:00+00:00 | 288.703705 | ... | 291.481476 | - """ - # pylint: enable=line-too-long + """ # pylint: disable=line-too-long return self._construct_time_series_df( matrix_name="action_value_matrix", ids_name="action_ids_map", @@ -369,13 +368,12 @@ def actions_df(self) -> pd.DataFrame: @cached_property def observations_df(self) -> pd.DataFrame: - # pylint: disable=line-too-long """A time-series dataframe of numeric observation values, constructed from the following components: - + Columns are the [`observation_ids`](./#smart_control.dataset.partition.BuildingDatasetPartition.observation_ids) - + Row indices are the [`observation_timestamps`](./#smart_control.dataset.partition.BuildingDatasetPartition.observation_timestamps) - + Cell values are from the [`observation_value_matrix`](./#smart_control.dataset.partition.BuildingDatasetPartition.observation_value_matrix) + + Columns are the [`observation_ids`][smart_control.dataset.partition.BuildingDatasetPartition.observation_ids] + + Row indices are the [`observation_timestamps`][smart_control.dataset.partition.BuildingDatasetPartition.observation_timestamps] + + Cell values are from the [`observation_value_matrix`][smart_control.dataset.partition.BuildingDatasetPartition.observation_value_matrix] Returns: A `pandas.DataFrame`. Here is an example of the structure: @@ -388,8 +386,7 @@ def observations_df(self) -> pd.DataFrame: | 2022-01-01 00:15:00+00:00 | 7.472401 | ... | 68.000000 | | 2022-01-01 00:20:00+00:00 | 7.472401 | ... | 68.000000 | - """ - # pylint: enable=line-too-long + """ # pylint: disable=line-too-long return self._construct_time_series_df( matrix_name="observation_value_matrix", ids_name="observation_ids_map", @@ -398,13 +395,12 @@ def observations_df(self) -> pd.DataFrame: @cached_property def rewards_df(self) -> pd.DataFrame: - # pylint: disable=line-too-long """A time-series dataframe of numeric reward values, constructed from the following components: - + Columns are the [`reward_ids`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_ids) - + Row indices are the [`reward_timestamps`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_timestamps) - + Cell values are from the [`reward_value_matrix`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_value_matrix) + + Columns are the [`reward_ids`][smart_control.dataset.partition.BuildingDatasetPartition.reward_ids] + + Row indices are the [`reward_timestamps`][smart_control.dataset.partition.BuildingDatasetPartition.reward_timestamps] + + Cell values are from the [`reward_value_matrix`][smart_control.dataset.partition.BuildingDatasetPartition.reward_value_matrix] Returns: A `pandas.DataFrame`. Here is an example of the structure: @@ -416,8 +412,8 @@ def rewards_df(self) -> pd.DataFrame: | 2022-01-01 00:05:00+00:00 | -1.002312e-08 | ... | 1.782538e-08 | | 2022-01-01 00:10:00+00:00 | -1.002312e-08 | ... | 1.782538e-08 | | 2022-01-01 00:15:00+00:00 | -5.737567e-09 | ... | 1.020384e-08 | - """ - # pylint: enable=line-too-long + + """ # pylint: disable=line-too-long return self._construct_time_series_df( matrix_name="reward_value_matrix", ids_name="reward_ids_map", @@ -426,13 +422,12 @@ def rewards_df(self) -> pd.DataFrame: @cached_property def reward_infos_df(self) -> pd.DataFrame: - # pylint: disable=line-too-long """A time-series dataframe of numeric reward info values, constructed from the following components: - + Columns are the [`reward_info_ids`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_info_ids) - + Row indices are the [`reward_info_timestamps`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_info_timestamps) - + Cell values are from the [`reward_info_value_matrix`](./#smart_control.dataset.partition.BuildingDatasetPartition.reward_info_value_matrix) + + Columns are the [`reward_info_ids`][smart_control.dataset.partition.BuildingDatasetPartition.reward_info_ids] + + Row indices are the [`reward_info_timestamps`][smart_control.dataset.partition.BuildingDatasetPartition.reward_info_timestamps] + + Cell values are from the [`reward_info_value_matrix`][smart_control.dataset.partition.BuildingDatasetPartition.reward_info_value_matrix] Returns: A `pandas.DataFrame`. Here is an example of the structure: @@ -444,8 +439,8 @@ def reward_infos_df(self) -> pd.DataFrame: | 2022-01-01 00:05:00+00:00 | 294.0 | ... | 0.0 | | 2022-01-01 00:10:00+00:00 | 294.0 | ... | 0.0 | | 2022-01-01 00:15:00+00:00 | 294.0 | ... | 0.0 | - """ - # pylint: enable=line-too-long + + """ # pylint: disable=line-too-long return self._construct_time_series_df( matrix_name="reward_info_value_matrix", ids_name="reward_info_ids_map", diff --git a/smart_control/simulator/building_radiation_utils.py b/smart_control/simulator/building_radiation_utils.py index 180ef1e5..e1b0dc1f 100644 --- a/smart_control/simulator/building_radiation_utils.py +++ b/smart_control/simulator/building_radiation_utils.py @@ -82,7 +82,7 @@ def calculate_ifa_inv(F: np.ndarray, A_inv: np.ndarray) -> np.ndarray: $$IFA_{inv} = (I - F) \tilde{A}^{-1}$$ - See [`net_radiative_heatflux_function_of_T`](./#smart_control.simulator.building_radiation_utils.net_radiative_heatflux_function_of_T) for more details. + See [`net_radiative_heatflux_function_of_T`][smart_control.simulator.building_radiation_utils.net_radiative_heatflux_function_of_t] for more details. Args: F (np.ndarray): The view factor matrix. @@ -90,7 +90,7 @@ def calculate_ifa_inv(F: np.ndarray, A_inv: np.ndarray) -> np.ndarray: Returns: IFA_inv : The IFA inverse matrix. - """ + """ # pylint: disable=line-too-long n = F.shape[0]