Skip to content

Commit

Permalink
Trigger test multi-action training with the singlezone_commercial_hyd…
Browse files Browse the repository at this point in the history
…ronic test case.
  • Loading branch information
javiarrobas committed Sep 27, 2024
1 parent fbd0661 commit 6685dc9
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ jobs:
sudo apt-get install -y docker-compose
- name: Test local version
run: make test-local-in-container
test-multiaction:
test-local:
runs-on: ubuntu-latest
defaults:
run:
working-directory: testing
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Pull boptestgym image from registry
run: make pull-boptestgym
- name: Pull boptest_base image from registry
run: make pull-boptestbase
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Test local version
run: make test-multiaction-in-container
test-vectorized:
runs-on: ubuntu-latest
defaults:
Expand Down
1 change: 1 addition & 0 deletions boptestGymEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ def __init__(self, env, n_bins_act=10):

# Instantiate discretized action space
self.action_space = spaces.Discrete((n_bins_act+1) ** self.n_act)

def _get_indices(self, action_wrapper):
"""
Returns the indices of the discretized action space corresponding to the given action wrapper.
Expand Down
18 changes: 17 additions & 1 deletion testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ run-boptest-case-no-cache:
cd project1-boptest-${BOPTEST_COMMIT} && \
TESTCASE=bestest_hydronic_heat_pump docker compose up -d --force-recreate --build

run-boptest-case-commercial:
make download-boptest
cd project1-boptest-${BOPTEST_COMMIT} && \
TESTCASE=singlezone_commercial_hydronic docker compose up -d

run-boptest-vectorized:
make download-boptest && \
# make download-boptest && \
cd .. && python3 generateDockerComposeYml.py testing/project1-boptest-${BOPTEST_COMMIT} && \
cd testing/project1-boptest-${BOPTEST_COMMIT} && \
TESTCASE=bestest_hydronic_heat_pump docker compose up -d
Expand All @@ -114,6 +119,9 @@ cleanup-boptest:
test-local:
python3 -m unittest test_boptestGymEnv.BoptestGymEnvTest

test-multiaction:
python3 -m unittest test_boptestGymEnv.BoptestGymEnvMultiActTest

# Vectorized needs to run separate since modifies docker-compose.yml to have multiple boptest instances
test-vectorized:
python3 -m unittest test_boptestGymEnv.BoptestGymVecTest project1-boptest-${BOPTEST_COMMIT}
Expand All @@ -130,6 +138,14 @@ test-local-in-container:
make stop-boptest-case
make cleanup-boptest

test-multiaction-in-container
make run-boptest-case-commercial
make run-boptestgym-detached
make exec-boptestgym ARGS="make test-multiaction"
make stop-boptestgym
make stop-boptest-case
make cleanup-boptest

test-vectorized-in-container:
make run-boptest-vectorized
make run-boptestgym-detached
Expand Down
11 changes: 6 additions & 5 deletions testing/test_boptestGymEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,13 @@ def check_from_cell_output(self, cell_output, str_output):
# Check results
self.compare_ref_json(out_json, file_ref)

class TestMultiActions(unittest.TestCase):
class BoptestGymEnvMultiActTest(unittest.TestCase):
""" Test multi-action training with the `singlezone_commercial_hydronic`
test case.
"""

def setUp(self):
'''Set up the environment and model for testing.'''
# env:singlezone_commercial_hydronic
# Initialize the environment
self.env = BoptestGymEnv(
url=url,
actions=['oveTZonSet_u', 'oveTSupSet_u', 'oveCO2ZonSet_u'],
Expand Down Expand Up @@ -610,9 +612,8 @@ def setUp(self):
learning_rate=5e-4, batch_size=24,
buffer_size=365*24, learning_starts=24, train_freq=1)

def test_training(self):
def test_training_multi_action(self):
'''Test that the environment and RL agent interact as expected.'''
# Main training loop
self.model.learn(total_timesteps=100)

def tearDown(self):
Expand Down

0 comments on commit 6685dc9

Please sign in to comment.