Skip to content

Commit

Permalink
(v3.2.8) - RBC with fixed setpoint values (#401)
Browse files Browse the repository at this point in the history
* RBCDatacenter created and change name to the old RBCDatacenter to RBCIncrementalDatacenter

* RBCDatacenter renamed to RBCIncrementalDatacenter, then created RBCDatacenter with fixed setpoint values

* Tests created

* Updated Sinergym version from 3.2.7 to 3.2.8
  • Loading branch information
AlejandroCN7 authored Mar 26, 2024
1 parent b7f0545 commit b4052e2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
27 changes: 27 additions & 0 deletions sinergym/utils/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,33 @@ class RBCDatacenter(object):
def __init__(self, env: EplusEnv) -> None:
"""Agent based on static rules for controlling 2ZoneDataCenterHVAC setpoints.
Follows the ASHRAE recommended temperature ranges for data centers described in ASHRAE TC9.9 (2016).
Args:
env (EplusEnv): Simulation environment
"""

self.env = env
self.observation_variables = env.get_wrapper_attr(
'observation_variables')
self.action_variables = env.get_wrapper_attr('action_variables')

# ASHRAE recommended temperature range = [18, 27] Celsius
self.range_datacenter = (18, 27)

def act(self) -> Sequence[Any]:
"""Select same action always, corresponding with comfort range.
Returns:
Sequence[Any]: Action chosen.
"""
return self.range_datacenter


class RBCIncrementalDatacenter(object):

def __init__(self, env: EplusEnv) -> None:
"""Agent based on rules for controlling 2ZoneDataCenterHVAC setpoints in a incremental way.
Follows the ASHRAE recommended temperature ranges for data centers described in ASHRAE TC9.9 (2016).
Args:
env (EplusEnv): Simulation environment
"""
Expand Down
2 changes: 1 addition & 1 deletion sinergym/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.7
3.2.8
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,11 @@ def zone5_controller(env_5zone):
def datacenter_controller(env_datacenter):
return RBCDatacenter(env=env_datacenter)


@ pytest.fixture(scope='function')
def datacenter_incremental_controller(env_datacenter):
return RBCIncrementalDatacenter(env=env_datacenter)

# ---------------------------------------------------------------------------- #
# Building and weather python models #
# ---------------------------------------------------------------------------- #
Expand Down
9 changes: 7 additions & 2 deletions tests/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ def test_controller_5Zone(zone5_controller):


def test_controller_datacenter(datacenter_controller):
env = datacenter_controller.env
action = datacenter_controller.act()
assert action == datacenter_controller.range_datacenter


def test_incremental_controller_datacenter(datacenter_incremental_controller):
env = datacenter_incremental_controller.env
obs, info = env.reset()

for i in range(3):
action = datacenter_controller.act(obs)
action = datacenter_incremental_controller.act(obs)
assert isinstance(action, tuple)
for value in action:
assert value is not None
Expand Down

0 comments on commit b4052e2

Please sign in to comment.