Skip to content

Utils#

smart_control.reinforcement_learning.utils.config #

Reinforcement learning configurations.

get_histogram_path #

get_histogram_path() -> str

Get path to histogram data.

Returns:

Type Description
str

Path to histogram data.

get_histogram_reducer #

get_histogram_reducer() -> Any

Get histogram reducer.

Returns:

Type Description
Any

Histogram reducer.

get_metrics_path #

get_metrics_path() -> str

Get path to metrics.

Returns:

Type Description
str

Path to metrics.

get_reset_temp_values #

get_reset_temp_values() -> np.ndarray

Get reset temperature values.

Returns:

Type Description
ndarray

Reset temperature values.

get_weather_path #

get_weather_path() -> str

Get path to weather data.

Returns:

Type Description
str

Path to weather data.

get_zone_path #

get_zone_path() -> str

Get path to zone data.

Returns:

Type Description
str

Path to zone data.

smart_control.reinforcement_learning.utils.constants #

Reinforcement learning constants.

smart_control.reinforcement_learning.utils.data_processing #

Reinforcement learning data processing functions.

convert_celsius_to_kelvin #

convert_celsius_to_kelvin(
    temperature_celsius: Union[float, ndarray, Series]
) -> Union[float, np.ndarray, pd.Series]

Convert temperature from Celsius to Kelvin.

Parameters:

Name Type Description Default
temperature_celsius Union[float, ndarray, Series]

Temperature in Celsius.

required

Returns:

Type Description
Union[float, ndarray, Series]

Temperature in Kelvin.

convert_kelvin_to_celsius #

convert_kelvin_to_celsius(
    temperature_kelvin: Union[float, ndarray, Series]
) -> Union[float, np.ndarray, pd.Series]

Convert temperature from Kelvin to Celsius.

Parameters:

Name Type Description Default
temperature_kelvin Union[float, ndarray, Series]

Temperature in Kelvin.

required

Returns:

Type Description
Union[float, ndarray, Series]

Temperature in Celsius.

get_action_timeseries #

get_action_timeseries(action_responses: List[Any]) -> pd.DataFrame

Converts action responses to a dataframe.

Parameters:

Name Type Description Default
action_responses List[Any]

List of action response objects.

required

Returns:

Type Description
DataFrame

DataFrame with action timeseries data.

get_energy_timeseries #

get_energy_timeseries(
    reward_infos: List[Any], time_zone: str = DEFAULT_TIME_ZONE
) -> pd.DataFrame

Returns a timeseries of energy rates.

Parameters:

Name Type Description Default
reward_infos List[Any]

List of reward info objects.

required
time_zone str

Time zone for the timestamps.

DEFAULT_TIME_ZONE

Returns:

Type Description
DataFrame

DataFrame with energy timeseries data.

get_latest_episode_reader #

get_latest_episode_reader(metrics_path: str) -> controller_reader.ProtoReader

Get reader for the latest episode.

Parameters:

Name Type Description Default
metrics_path str

Path to metrics directory.

required

Returns:

Type Description
ProtoReader

Reader for the latest episode.

get_outside_air_temperature_timeseries #

get_outside_air_temperature_timeseries(
    observation_responses: List[Any], time_zone: str = DEFAULT_TIME_ZONE
) -> pd.Series

Returns a timeseries of outside air temperature.

Parameters:

Name Type Description Default
observation_responses List[Any]

List of observation response objects.

required
time_zone str

Time zone for the timestamps.

DEFAULT_TIME_ZONE

Returns:

Type Description
Series

Series with outside air temperature timeseries data.

get_reward_timeseries #

get_reward_timeseries(
    reward_infos: List[Any],
    reward_responses: List[Any],
    time_zone: str = DEFAULT_TIME_ZONE,
) -> pd.DataFrame

Returns a timeseries of reward values.

Parameters:

Name Type Description Default
reward_infos List[Any]

List of reward info objects.

required
reward_responses List[Any]

List of reward response objects.

required
time_zone str

Time zone for the timestamps.

DEFAULT_TIME_ZONE

Returns:

Type Description
DataFrame

DataFrame with reward timeseries data.

get_zone_timeseries #

get_zone_timeseries(
    reward_infos: List[Any], time_zone: str = DEFAULT_TIME_ZONE
) -> pd.DataFrame

Converts reward infos to a timeseries dataframe.

Parameters:

Name Type Description Default
reward_infos List[Any]

List of reward info objects.

required
time_zone str

Time zone for the timestamps.

DEFAULT_TIME_ZONE

Returns:

Type Description
DataFrame

DataFrame with zone timeseries data.

smart_control.reinforcement_learning.utils.environment #

Reinforcement learning environment.

create_and_setup_environment #

create_and_setup_environment(
    gin_config_file: str,
    metrics_path: str = None,
    occupancy_normalization_constant: float = DEFAULT_OCCUPANCY_NORMALIZATION_CONSTANT,
)

Creates and sets up the environment.

load_environment #

load_environment(gin_config_file: str)

Returns an Environment from a config file.

smart_control.reinforcement_learning.utils.metrics #

Reinforcement learning metrics.

compute_avg_return #

compute_avg_return(
    environment: Any,
    policy: PyPolicy,
    num_episodes: int = 1,
    time_zone: str = DEFAULT_TIME_ZONE,
    trajectory_observers: Optional[List[Callable]] = None,
    num_steps: int = 6,
) -> Tuple[float, List[List[Any]]]

Computes the average return of the policy on the environment.

Parameters:

Name Type Description Default
environment Any

Environment to evaluate on.

required
policy PyPolicy

Policy to evaluate.

required
num_episodes int

Total number of episodes to run.

1
time_zone str

Time zone for timestamps.

DEFAULT_TIME_ZONE
trajectory_observers Optional[List[Callable]]

List of trajectory observers.

None
num_steps int

Number of steps to take per episode.

6

Returns:

Type Description
float

Tuple of (average return, list of [simulation time, episode return]

List[List[Any]]

pairs).

get_trajectory #

get_trajectory(
    time_step: TimeStep, current_action: PolicyStep
) -> trajectory.Trajectory

Get the trajectory for the current action and time step.

Parameters:

Name Type Description Default
time_step TimeStep

Current time step.

required
current_action PolicyStep

Current action.

required

Returns:

Type Description
Trajectory

Trajectory for the current action and time step.

smart_control.reinforcement_learning.utils.time_utils #

Reinforcement learning time utils.

time_from_sin_cos #

time_from_sin_cos(sin_theta: float, cos_theta: float) -> float

Converts sin/cos representation to radians (time angle).

to_dow #

to_dow(sin_theta: float, cos_theta: float) -> int

Converts sin/cos to day of week (0-6).

to_hod #

to_hod(sin_theta: float, cos_theta: float) -> int

Converts sin/cos to hour of day (0-23).