Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions smart_control/environment/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def compute_action_regularization_cost(
Returns the L2 Norm of the actions as a penalty term for large changes.

Args:
action_history: Seqential array of actions taken in the episode.
action_history: Sequential array of actions taken in the episode.

Returns:
A smoothing cost applied to the reward function for applying big changes.
Expand Down Expand Up @@ -986,7 +986,7 @@ def _normalized_observation_response_to_observation_map_single_timeseries(
continuous_value = single_observation_response.continuous_value

if not single_observation_response.observation_valid:
logging.warn(
logging.warning(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Invalid observation reported %s %s %f",
device_id,
measurement_name,
Expand Down
4 changes: 2 additions & 2 deletions smart_control/environment/environment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ class EnvironmentTest(parameterized.TestCase, tf.test.TestCase):
2.236067,
),
)
def test_comput_actions_regularization_cost_valid(
def test_compute_actions_regularization_cost_valid(
self, action_history, expected
):
cost = environment.compute_action_regularization_cost(action_history)
self.assertAlmostEqual(expected, cost, places=3)

def test_comput_actions_regularization_cost_invalid(self):
def test_compute_actions_regularization_cost_invalid(self):
action_history = [np.array([1, 0]), np.array([1, 0, 1])]
with self.assertRaises(ValueError):
_ = environment.compute_action_regularization_cost(action_history)
Expand Down
2 changes: 1 addition & 1 deletion smart_control/environment/environment_test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Shared test utiltiles for environment tests."""
"""Shared test utilities for environment tests."""

import collections
from typing import Sequence
Expand Down
2 changes: 1 addition & 1 deletion smart_control/models/base_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def wait_time(self) -> None:

@abc.abstractmethod
def reset(self) -> None:
"""Resets the building, throwing an RuntimeError if this is impossible."""
"""Resets the building, throwing a RuntimeError if this is impossible."""

@property
@abc.abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion smart_control/models/base_energy_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def carbon(
"""Returns the mass of carbon emitted from the energy consumption.

The energy-to-carbon emission is source specific. Assuming a constant
rate of energy consumption (W) of the time interval bounded by
rate of energy consumption (W) over the time interval bounded by
start_time and end_time, we can estimate total energy use (J). The type
of source will convert energy into carbon mass (kg).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def populate_replay_buffer(
'This buffer path already exists. This would override the existing'
' buffer. Please use another name'
)
raise FileExistsError('Buffer name already exists, would be overriden') from err # pylint: disable=line-too-long
raise FileExistsError('Buffer name already exists, would be overridden') from err # pylint: disable=line-too-long

# Load environment
logger.info('Loading environment from standard config')
Expand Down
2 changes: 1 addition & 1 deletion smart_control/reinforcement_learning/scripts/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def train_agent(
for i in range(train_iterations):
# Get current training step value before operations
current_step = train_step.numpy()
logger.exception(
logger.info(
'Starting training loop iteration %d (step %d)', i, current_step
)

Expand Down
2 changes: 1 addition & 1 deletion smart_control/reinforcement_learning/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# pylint: enable=unused-import

# Relative filepaths. Consider moving to reinforcement_learning/constants.py
# Relative file paths. Consider moving to reinforcement_learning/constants.py
# fmt: off
# pylint: disable=line-too-long
DATA_PATH = os.path.join(ROOT_DIR, "smart_control", "configs", "resources", "sb1")
Expand Down
2 changes: 1 addition & 1 deletion smart_control/reward/base_setpoint_energy_carbon_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _sum_electricity_energy_rate(
def _sum_natural_gas_energy_rate(
self, energy_reward_info: smart_control_reward_pb2.RewardInfo
) -> float:
"""Returns the sum of nat gas energy rate over the interval in W."""
"""Returns the sum of natural gas energy rate over the interval in W."""

# Sum up the power in Watts for the total power.
gas_energy_rate = 0.0
Expand Down
2 changes: 1 addition & 1 deletion smart_control/reward/electricity_energy_cost_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_cost(self, start_time, end_time, energy_rate, expected_cost):
0.4410,
),
])
def test_carbon_emisison(
def test_carbon_emission(
self, start_time, end_time, energy_rate, expected_carbon
):
cost = electricity_energy_cost.ElectricityEnergyCost()
Expand Down
2 changes: 1 addition & 1 deletion smart_control/reward/natural_gas_energy_cost_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_energy_cost(self, month, expected_cost):
cost_estimate = cost.cost(start_time, end_time, energy_rate)
self.assertAlmostEqual(expected_cost, cost_estimate, 2)

def test_carbon_emisison(self):
def test_carbon_emission(self):
# Source:
# https://www.eia.gov/environment/emissions/co2_vol_mass.php
# 1 million BTUs nat gas generate 53.1 kg C02.
Expand Down
2 changes: 1 addition & 1 deletion smart_control/reward/setpoint_energy_carbon_regret.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
For this pilot there are three principal factors that contribute to the
reward function:
* Setpoint: Maintaining the zone temperatures within heating and cooling
setpoints results in a positive reward, and any temperature outside of
setpoints results in a positive reward, and any temperature outside of
setpoints may also result in a negative reward (i.e., penalty).
* Cost: The cost of electricity and natural gas is a negative reward (cost).
Then by minimizing negative rewards/maximizing positive reward, the agent
Expand Down
2 changes: 1 addition & 1 deletion smart_control/reward/setpoint_energy_carbon_reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
s(setpoint) is the reward for maintaining setpoint
f(cost) is the cost of consuming electrical and natural gas energy
g(carbon) is the cost of emitting carbon,
and u, w are weighing factors for cost and carbon depending on the policy.
and u, w are weighting factors for cost and carbon depending on the policy.

The fundamental metric unit of energy is the Joule (J), and the unit of energy
applied over a fixed time interval (energy rate) is power measured in J/sec or
Expand Down
5 changes: 3 additions & 2 deletions smart_control/simulator/air_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

@gin.configurable
class AirHandler(smart_device.SmartDevice):
"""Models an air hander with heating/cooling, input/exhaust and recirculation.
"""
Models an air handler with heating/cooling, input/exhaust and recirculation.

Attributes:
recirculation: Proportion of air recirculated.
Expand Down Expand Up @@ -45,7 +46,7 @@ def __init__(
):
if cooling_air_temp_setpoint <= heating_air_temp_setpoint:
raise ValueError(
'cooling_air_temp_setpoint must greater than'
'cooling_air_temp_setpoint must be greater than'
' heating_air_temp_setpoint'
)

Expand Down
4 changes: 2 additions & 2 deletions smart_control/simulator/air_handler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_get_mixed_air_temp(
):
"""Calculates the mixed air temperature.

This function is calculated by muliplying the recirculation_temp by
This function is calculated by multiplying the recirculation_temp by
the recirculation factor, and the ambient_temp
by 1 minus the recirculation factor, and adding the two.

Expand All @@ -129,7 +129,7 @@ def test_get_mixed_air_temp(

@parameterized.named_parameters(
('below setpoint window case 1', 0.3, 280, 240, 270),
('below setpount window case 2', 0.6, 244, 270, 270),
('below setpoint window case 2', 0.6, 244, 270, 270),
('above setpoint window case 1', 0.1, 210, 316, 288),
('above setpoint window case 2', 0.4, 250, 316, 288),
('in setpoint window case 1', 0.4, 286, 266, 0.4 * 286 + 0.6 * 266),
Expand Down
4 changes: 2 additions & 2 deletions smart_control/simulator/boiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ def compute_thermal_dissipation_rate(
) -> float:
"""Returns the amount of thermal loss in W from a boiler tank.

Thermal dissipation is the loss of heat due from the tank to the environment
Thermal dissipation is the loss of heat from the tank to the environment
due to imperfect insulation, measured in Watts.

The tank is assumed to be a cylindrical annulus, with an internal radius
internal length, and an insulation thickness. Heat is dissapated only
internal length, and an insulation thickness. Heat is dissipated only
through the cylinder walls, and no heat is lost through the ends/caps.

The equation is computed by applying an energy balance of:
Expand Down
4 changes: 2 additions & 2 deletions smart_control/simulator/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _construct_cv_type_array(
) -> np.ndarray:
"""Fills once the CV type matrix and save it.

In the original imlementation,
In the original implementation,
the sweep() function would call the get_cv_type() function every time,
repeating logic that only needed to be computed once and saved.

Expand Down Expand Up @@ -390,7 +390,7 @@ class Building(BaseSimulatorBuilding):
length of the building.
temp: The current temp in K of each control volume.
conductivity: Thermal conductivity in of each control volume W/m/K.
heat_capacity: Thermal heat cpacity of each control volume in J/kg/K.
heat_capacity: Thermal heat capacity of each control volume in J/kg/K.
density: Material density in kg/m3 of each control volume.
input_q: Heat energy applied (sign indicates heating/cooling) at the CV in W
(J/s).
Expand Down
6 changes: 3 additions & 3 deletions smart_control/simulator/building_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ def test_enlarge_exterior_walls(self):
[0, 0, 0, 0, 0, 0, 0],
])

expexted_interior_output = np.array([
expected_interior_output = np.array([
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
Expand All @@ -823,7 +823,7 @@ def test_enlarge_exterior_walls(self):
with self.subTest("exterior_output"):
np.testing.assert_array_equal(exterior_output, expected_exterior_output)
with self.subTest("interior_output"):
np.testing.assert_array_equal(interior_output, expexted_interior_output)
np.testing.assert_array_equal(interior_output, expected_interior_output)

def test_interior_air_values(self):
initial_temp = 292.0
Expand Down Expand Up @@ -1691,7 +1691,7 @@ def test_stochastic_convection_simulator_shuffle_max_dist(
continue
self.assertEqual(b.temp[i][j], 292.0)

# lets reset and try again, to make sure the chache works
# lets reset and try again, to make sure the cache works
# now lets change the temps in a room
b.temp[2][2] = 1
b.temp[2][3] = 2
Expand Down
6 changes: 3 additions & 3 deletions smart_control/simulator/building_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def save_images_to_cns_for_debugging(
def guarantee_air_padding_in_frame(
floor_plan: FileInputFloorPlan,
) -> FileInputFloorPlan:
"""Adds a row or column of air if a building is abuts its frame edge.
"""Adds a row or column of air if a building abuts its frame edge.

Future computation relies on buildings being surrounded by at least one
layer of air CVs between them and the edge of the floor plan frame.
Expand Down Expand Up @@ -175,7 +175,7 @@ def determine_row_size_of_exterior_space_to_add() -> np.ndarray:
)

def determine_column_size_of_exterior_space_to_add() -> np.ndarray:
"""A helper function to recompute a columns row to add from floor plan dim.
"""A helper function to recompute a column row to add from floor plan dim.

Returns:
a column of constants.EXTERIOR_SPACE_VALUE_IN_FILE_INPUT's to concat if
Expand Down Expand Up @@ -283,7 +283,7 @@ def _set_exterior_space_neg(
"""Modifies the connections array so that exterior space is negative.

Encoding the exterior space as negative is important in the connections array
as it will encode an aribtrarily large number of rooms as positive integers.
as it will encode an arbitrarily large number of rooms as positive integers.
Thus, setting the exterior space as negative ensures that we will always be
able to deal with it as its own category of space.

Expand Down
14 changes: 4 additions & 10 deletions smart_control/simulator/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
# that designates exterior space in the file input.
EXTERIOR_SPACE_VALUE_IN_FILE_INPUT = 2

# Here we designate a specific placeholder to help use demarcate which CVs
# Here we designate a specific placeholder to help us demarcate which CVs
# are for exterior space once processed in the function. It is intentionally
# set to -1 so that the connectedComponent function can have access to all
# nonzero integers to count upwards in an unbounded way.
EXTERIOR_SPACE_VALUE_IN_FUNCTION = -1

# Here we designate a specific placeholder to help use demarcate which CVs
# Here we designate a specific placeholder to help us demarcate which CVs
# are for exterior space are noted in the component. It is intentionally
# set to -1 so that the connectedComponent function can have access to all
# nonzero integers to count upwards in an unbounded way.
Expand All @@ -52,7 +52,7 @@

# Here we pick out a specific value that we know will code for interior space
# after connectedComponents() processes it. We know this because we have ensured
# that the CV at index (0,0) will always be an "space" CV when ready for
# that the CV at index (0,0) will always be a "space" CV when ready for
# input to connectedComponents, but we previously index the exterior space CVs
# in their own data array. Thus, after overwriting the exterior space CVs to
# the value _EXTERIOR_SPACE_VALUE_IN_FUNCTION, all connectedComponents of
Expand Down Expand Up @@ -82,17 +82,11 @@
# returning expanded exterior walls when calling enlarge_component()
WALLS_AND_EXPANDED_BOOLS = 2

# Here we wish to specifically set exterior space as indistinguishable
# from exterior walls, as we wish to perform connectedComponents only on
# connected groups of interior space. Thus, we set exterior space to a generic
# space value, i.e. 0.
GENERIC_SPACE_VALUE_IN_CONNECTION_INPUT = 0

Comment on lines -85 to -90
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed a duplicated block

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MJR TODO: verify duplicate block exists

# Here we use a specific placeholder value, matching with the file input schema,
# that designates interior space in the file input.
INTERIOR_WALL_VALUE_IN_FILE_INPUT = 1

# Here we designate a specific placeholder to help use demarcate which CVs
# Here we designate a specific placeholder to help us demarcate which CVs
# are for interior walls once processed in the function. It is intentionally
# set to -3 so that the connectedComponent function can have access to all
# nonzero integers to count upwards in an unbounded way.
Expand Down
2 changes: 1 addition & 1 deletion smart_control/simulator/hvac.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(

Args:
zone_coordinates: List of 2-tuple containing zone coordinates to service.
air_handler: the air handler for hte HVAC
air_handler: the air handler for the HVAC
boiler: the boiler for the HVAC
schedule: the setpoint_schedule for the thermostats
vav_max_air_flow_rate: the max airflow rate for the vavs
Expand Down
2 changes: 1 addition & 1 deletion smart_control/simulator/hvac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def test_vav_device_ids(self):

self.assertListEqual(vav_ids, expected_vav_ids)

def test_id_comfort_mode(self):
def test_is_comfort_mode(self):
zone_coordinates = [(0, 0), (1, 0), (1, 1), (0, 1)]
handler = _get_default_air_handler()
b = _get_default_boiler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class ZoneOccupant:
"""Represents a single occupant in a zone.

Attributes:
earliest_expected_arrival_hour: earliest arrivel, 0 - 22
latest_expected_arrival_hour: latest arrivel, 1 - 23
earliest_expected_arrival_hour: earliest arrival, 0 - 22
latest_expected_arrival_hour: latest arrival, 1 - 23
earliest_expected_departure_hour: earliest departure, 0 - 22
latest_expected_departure_hour: latest departure, 1 - 23
random_state: random state used to generate events
Expand Down Expand Up @@ -82,16 +82,16 @@ def _get_event_probability(self, start_hour, end_hour):
# The halfway point is the firts half of the trials.
n_halfway = window / self._step_size / 2.0
# We'd like to return the probability of event happening in a single time-
# step. This follow a geometric distribution, where E[X] = 1/p, where
# E[x] is the expected number of events before the first success. If
# step. This follows a geometric distribution, where E[X] = 1/p, where
# E[X] is the expected number of events before the first success. If
# E[X] is the halfway point, then p = 1 / n_halfway.
return 1.0 / n_halfway

def _occupant_arrived(self, timestamp):
"""Makes a random draw to determine whether occupant arrives."""

local_timestamp = self._to_local_time(timestamp)
# TODO(sipple): Consider effects when time crosses DST>
# TODO(sipple): Consider effects when time crosses DST.
if (
local_timestamp.hour < self._earliest_expected_arrival_hour
or local_timestamp.hour > self._latest_expected_arrival_hour
Expand Down Expand Up @@ -138,8 +138,8 @@ class RandomizedArrivalDepartureOccupancy(BaseOccupancy):

Attributes:
zone_assignment: number of occupants in a zone
earliest_expected_arrival_hour: earliest arrivel, 0 - 22
latest_expected_arrival_hour: latest arrivel, 1 - 23
earliest_expected_arrival_hour: earliest arrival, 0 - 22
latest_expected_arrival_hour: latest arrival, 1 - 23
earliest_expected_departure_hour: earliest departure, 0 - 22
latest_expected_departure_hour: latest departure, 1 - 23
seed: integer used to set the random state for repeatability
Expand Down
2 changes: 1 addition & 1 deletion smart_control/simulator/rejection_simulator_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@gin.configurable
class RejectionSimulatorBuilding(BaseBuilding):
"""A Building that throws exception while agent is awaiting authorization."""
"""A Building that throws exceptions while agent is awaiting authorization."""

def __init__(
self, base_building: BaseBuilding, initial_rejection_count: int = 0
Expand Down
Loading