Skip to content

Commit

Permalink
Merge pull request #136 from ibpsa/issue135_v050
Browse files Browse the repository at this point in the history
Issue135 v050
  • Loading branch information
javiarrobas authored Nov 11, 2023
2 parents d74faa2 + b51c56e commit a4f9b0e
Show file tree
Hide file tree
Showing 58 changed files with 3,320 additions and 3,294 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI of BOPTEST-Gym using GitHub Actions
on: [push, pull_request]
on: [push]
jobs:
test-local:
runs-on: ubuntu-latest
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ Running BOPTEST locally is substantially faster
2) Run a BOPTEST case with the building emulator model to be controlled (instructions [here](https://github.com/ibpsa/project1-boptest/blob/master/README.md)).
3) Check out the `master` branch of this repository and run the example above replacing the url to be `url = 'http://127.0.0.1:5000'` and avoiding the `testcase` argument to the `BoptestGymEnv` class.

## Versioning and main dependencies

Current BOPTEST-Gym version is `v0.5.0` which is compatible with BOPTEST `v0.5.0`
(BOPTEST-Gym version should always be even with the BOPTEST version used).
The framework has been tested with `gymnasium==0.28.1` and `stable-baselines3==2.0.0`.
You can see [testing/Dockerfile](testing/Dockerfile) for a full description of the testing environment.

## Citing the project

Expand All @@ -90,7 +96,4 @@ Please use the following reference if you used this repository for your research
address = {Bruges, Belgium},
}
```



```
26 changes: 13 additions & 13 deletions boptestGymEnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,14 @@ def find_start_time():

# Initialize the building simulation
res = requests.put('{0}/initialize'.format(self.url),
data={'start_time':self.start_time,
'warmup_period':self.warmup_period}).json()['payload']
json={'start_time':int(self.start_time),
'warmup_period':int(self.warmup_period)}).json()['payload']

# Set simulation step
requests.put('{0}/step'.format(self.url), data={'step':self.step_period})
requests.put('{0}/step'.format(self.url), json={'step':int(self.step_period)})

# Set BOPTEST scenario
requests.put('{0}/scenario'.format(self.url), data=self.scenario)
requests.put('{0}/scenario'.format(self.url), json=self.scenario)

# Initialize objective integrand
self.objective_integrand = 0.
Expand Down Expand Up @@ -537,13 +537,13 @@ def step(self, action):
# Assign values to inputs if any
for i, act in enumerate(self.actions):
# Assign value
u[act] = action[i]
u[act] = float(action[i])

# Indicate that the input is active
u[act.replace('_u','_activate')] = 1.
u[act.replace('_u','_activate')] = float(1)

# Advance a BOPTEST simulation
res = requests.post('{0}/advance'.format(self.url), data=u).json()['payload']
res = requests.post('{0}/advance'.format(self.url), json=u).json()['payload']

# Compute reward of this (state-action-state') tuple
reward = self.get_reward()
Expand Down Expand Up @@ -717,9 +717,9 @@ def get_observations(self, res):
regr_index = res['time']-self.step_period*np.arange(1,self.regr_n+1)
for var in self.regressive_vars:
res_var = requests.put('{0}/results'.format(self.url),
data={'point_names':[var],
'start_time':regr_index[-1],
'final_time':regr_index[0]}).json()['payload']
json={'point_names':[var],
'start_time':int(regr_index[-1]),
'final_time':int(regr_index[0])}).json()['payload']
# fill_value='extrapolate' is needed for the very few cases when
# res_var['time'] is not returned to be exactly between
# regr_index[-1] and regr_index[0] but shorter. In these cases
Expand All @@ -733,9 +733,9 @@ def get_observations(self, res):
# Get predictions if this is a predictive agent.
if self.is_predictive:
predictions = requests.put('{0}/forecast'.format(self.url),
data={'point_names': self.predictive_vars,
'horizon': self.predictive_period,
'interval': self.step_period}).json()['payload']
json={'point_names': self.predictive_vars,
'horizon': int(self.predictive_period),
'interval': int(self.step_period)}).json()['payload']
for var in self.predictive_vars:
for i in range(self.pred_n):
observations.append(predictions[var][i])
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/test_and_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def plot_results(env, rewards, points=['reaTZon_y','reaTSetHea_y','reaTSetCoo_y'
# point from the initialization period to don't confuse it with
# actions taken by the agent in a previous episode.
res = requests.put('{0}/results'.format(env.url),
data={'point_names':points,
json={'point_names':points,
'start_time':env.start_time+1,
'final_time':3.1536e7}).json()['payload']

Expand Down
5 changes: 3 additions & 2 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

BOPTEST-Gym has two main dependencies: BOPTEST and Stable-Baselines3. For simplicity, the first two digits of the version number match the same two digits of the BOPTEST version of which BOPTEST-Gym is compatible with. For example, BOPTEST-Gym v0.3.x is compatible with BOPTEST v0.3.x. The last digit is reserved for other internal edits specific to this repository only. See [here](https://github.com/ibpsa/project1-boptest/blob/master/releasenotes.md) for BOPTEST release notes.

## BOPTEST-Gym v0.4.0-dev
## BOPTEST-Gym v0.5.0

Released on xx/xx/xxxx.
Released on 11/11/2023.

- Update for `BOPTEST v0.5.0`. This is for [#135](https://github.com/ibpsa/project1-boptest-gym/pull/136).
- Remove arbitrarily small offset when requesting forecasts. This is for [#127](https://github.com/ibpsa/project1-boptest-gym/issues/127).
- Implement CI and testing using GitHub Actions. This is for [#23](https://github.com/ibpsa/project1-boptest-gym/issues/23).

Expand Down
26 changes: 20 additions & 6 deletions testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ ROOT ?= $(shell dirname \
IMG_NAME=boptestgym
IMG_HOME=/home/developer/boptestgym

# Name of remote registry image
IMG_REGI=javierarroyo/boptestgym

# BOPTEST commit used for the tests
BOPTEST_COMMIT=1fd96639518853c1ddc41355a8f9e29edce3242d
BOPTEST_COMMIT=12ceafe42983d42e535385dee1daa1d25673e2aa

# Define current BOPTEST-Gym version (should be even with BOPTEST version defined in commit above)
VERSION = 0.5.0

build-boptestgym:
docker build -f ${ROOT}/testing/Dockerfile \
Expand Down Expand Up @@ -52,19 +58,27 @@ exec-boptestgym:

push-boptestgym:
# requires `docker login` first
docker tag boptestgym javierarroyo/boptestgym
docker push javierarroyo/boptestgym
docker tag ${IMG_NAME} ${IMG_REGI}:${VERSION}
docker push ${IMG_REGI}:${VERSION}

pull-boptestgym:
docker pull javierarroyo/boptestgym
docker tag javierarroyo/boptestgym boptestgym
docker pull ${IMG_REGI}:${VERSION}
docker tag ${IMG_REGI}:${VERSION} ${IMG_NAME}

run-boptest-case:
make download-doptest:
curl -L -o boptest.zip https://github.com/ibpsa/project1-boptest/archive/${BOPTEST_COMMIT}.zip
unzip -o -q boptest.zip

run-boptest-case:
make download-doptest
cd project1-boptest-${BOPTEST_COMMIT} && \
TESTCASE=bestest_hydronic_heat_pump docker-compose up -d --quiet-pull

run-boptest-case-no-cache:
make download-doptest
cd project1-boptest-${BOPTEST_COMMIT} && \
TESTCASE=bestest_hydronic_heat_pump docker-compose up -d --force-recreate --build

stop-boptest-case:
cd project1-boptest-${BOPTEST_COMMIT} && docker-compose down

Expand Down
100 changes: 50 additions & 50 deletions testing/references/actions_A2C_A_peak.csv
Original file line number Diff line number Diff line change
@@ -1,97 +1,97 @@
time,0
0,-0.012297921
1,-0.01229467
2,-0.012291396
1,-0.012294669
2,-0.012291397
3,-0.012288108
4,-0.012215504
5,-0.0122121805
6,-0.0122088455
7,-0.012205495
5,-0.012212181
6,-0.012208845
7,-0.012205494
8,-0.012212538
9,-0.012209164
9,-0.012209163
10,-0.012205776
11,-0.012202373
12,-0.011803008
13,-0.01179955
12,-0.011803007
13,-0.011799549
14,-0.011796076
15,-0.011792586
16,-0.011901509
15,-0.011792587
16,-0.011901508
17,-0.011897998
18,-0.0118944775
19,-0.011890944
20,-0.012229996
18,-0.011894477
19,-0.011890943
20,-0.012229995
21,-0.0122264605
22,-0.012222918
22,-0.012222917
23,-0.012219366
24,-0.0124417655
25,-0.012438213
26,-0.01243465
27,-0.012431075
28,-0.01273407
29,-0.012730183
30,-0.012726506
24,-0.012441765
25,-0.0124382125
26,-0.012434651
27,-0.012431076
28,-0.0127340695
29,-0.012730182
30,-0.012726505
31,-0.012722848
32,-0.013007072
33,-0.013003429
34,-0.012999782
32,-0.013007071
33,-0.013003428
34,-0.012999781
35,-0.012996132
36,-0.012909439
37,-0.012905759
38,-0.012902068
39,-0.012898384
40,-0.013040699
39,-0.012898382
40,-0.0130407
41,-0.0130371405
42,-0.013033651
43,-0.013030281
43,-0.013030283
44,-0.01274053
45,-0.012737559
45,-0.012737557
46,-0.012734575
47,-0.012731375
48,-0.012509742
48,-0.012509741
49,-0.012505986
50,-0.012502143
51,-0.012498308
52,-0.012379342
50,-0.012502144
51,-0.012498307
52,-0.012379341
53,-0.0123755075
54,-0.012371669
55,-0.012367824
54,-0.012371668
55,-0.012367825
56,-0.012386765
57,-0.012382914
58,-0.01237905
59,-0.012375172
59,-0.012375171
60,-0.012399587
61,-0.012395692
62,-0.012391782
62,-0.012391783
63,-0.012387857
64,-0.012438072
64,-0.012438071
65,-0.012434157
66,-0.012430262
67,-0.012426357
68,-0.012983199
69,-0.012979205
70,-0.0129750995
70,-0.012975099
71,-0.012970982
72,-0.012375802
73,-0.012371713
74,-0.012367624
75,-0.012363531
76,-0.012438373
75,-0.01236353
76,-0.012438374
77,-0.012434269
78,-0.012430156
79,-0.012426028
78,-0.012430155
79,-0.012426029
80,-0.012163673
81,-0.012159603
82,-0.012155428
83,-0.012151219
84,-0.012070566
85,-0.0120663345
86,-0.012062097
87,-0.012057845
85,-0.012066336
86,-0.012062096
87,-0.0120578455
88,-0.011926071
89,-0.011921791
90,-0.011917499
91,-0.011913193
89,-0.011921792
90,-0.0119175
91,-0.011913192
92,-0.012128407
93,-0.01212407
93,-0.012124069
94,-0.012119722
95,-0.012115365
95,-0.012115366
Loading

0 comments on commit a4f9b0e

Please sign in to comment.