Skip to content

Commit

Permalink
Merge pull request #17 from airboxlab/upgrade-energyplus-ray
Browse files Browse the repository at this point in the history
EnergyPlus 23.2 / Ray 2.8.0
  • Loading branch information
antoine-galataud authored Nov 28, 2023
2 parents 382e1e8 + 10d1b5a commit 3a37b3c
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ jobs:
- name: Install EnergyPlus
run: |
ENERGYPLUS_VERSION="23.1.0"
ENERGYPLUS_SHA="87ed9199d4"
ENERGYPLUS_VERSION="23.2.0"
ENERGYPLUS_SHA="7636e6b3e9"
ENERGYPLUS_DOWNLOAD_URL="https://github.com/NREL/EnergyPlus/releases/download/v${ENERGYPLUS_VERSION}/EnergyPlus-${ENERGYPLUS_VERSION}-${ENERGYPLUS_SHA}-Linux-Ubuntu22.04-x86_64.sh"
wget --quiet "${ENERGYPLUS_DOWNLOAD_URL}" -O /tmp/eplus_install.sh
(echo "y"; echo ""; echo "y";) | sudo bash /tmp/eplus_install.sh
- name: Execute tests
env:
PYTHON_KEYRING_BACKEND: keyring.backends.null.Keyring
PYTHONPATH: "/usr/local/EnergyPlus-23-1-0/:.:$PYTHONPATH"
PYTHONPATH: "/usr/local/EnergyPlus-23-2-0/:.:$PYTHONPATH"
run: |
python tests/__init__.py
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Run the container
docker run --rm --name rllib-energyplus -it rllib-energyplus
```

If you want to use tensorboard, start the container with `--network host` parameter.

If you want to use a GPU, start the container with `--gpus all` parameter.

Inside the container, run the experiment

```shell
Expand All @@ -48,7 +52,7 @@ pip install -r requirements.txt
Add EnergyPlus folder to `PYTHONPATH` environment variable:

```shell
export PYTHONPATH="/usr/local/EnergyPlus-23-1-0/:$PYTHONPATH"
export PYTHONPATH="/usr/local/EnergyPlus-23-2-0/:$PYTHONPATH"
```

Make sure you can import EnergyPlus API by printing its version number
Expand Down
8 changes: 5 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM ubuntu:22.04

LABEL org.opencontainers.image.source="https://github.com/airboxlab/rllib-energyplus"
LABEL org.opencontainers.image.description="RLlib + EnergyPlus for Reinforcement Learning in Building Energy Management Systems"

ARG EPLUS_VERSION=23-1-0
ARG EPLUS_DL_URL=https://github.com/NREL/EnergyPlus/releases/download/v23.1.0/EnergyPlus-23.1.0-87ed9199d4-Linux-Ubuntu22.04-x86_64.sh
ARG EPLUS_VERSION=23-2-0
ARG EPLUS_DL_URL=https://github.com/NREL/EnergyPlus/releases/download/v23.2.0/EnergyPlus-23.2.0-7636e6b3e9-Linux-Ubuntu22.04-x86_64.sh

ENV DEBIAN_FRONTEND=noninteractive \
HOME=/home/ray \
Expand Down Expand Up @@ -34,7 +35,8 @@ RUN \
# cleanup
apt autoremove -qq -y && apt-get clean -qq && rm -rf /var/lib/apt/lists/*

COPY model.idf LUX_LU_Luxembourg.AP.065900_TMYx.2004-2018.epw run.py /root/rllib-energyplus/
COPY model.idf LUX_LU_Luxembourg.AP.065900_TMYx.2004-2018.epw /root/rllib-energyplus/
COPY rllibenergyplus /root/rllib-energyplus/rllibenergyplus

ENV PYTHONPATH="/usr/local/EnergyPlus-${EPLUS_VERSION}"
ENTRYPOINT "/bin/bash"
29 changes: 19 additions & 10 deletions model.idf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version,22.2;
Version,23.2;

Timestep,4;

Expand Down Expand Up @@ -801,7 +801,14 @@
No, !- Account for Dedicated Outdoor Air System
, !- Dedicated Outdoor Air System Control Strategy
, !- Dedicated Outdoor Air Low Setpoint Temperature for Design {C}
; !- Dedicated Outdoor Air High Setpoint Temperature for Design {C}
, !- Dedicated Outdoor Air High Setpoint Temperature for Design {C}
, !- Zone Load Sizing Method
, !- Zone Latent Cooling Design Supply Air Humidity Ratio Input Method
, !- Zone Dehumidification Design Supply Air Humidity Ratio {kgWater/kgDryAir}
, !- Zone Cooling Design Supply Air Humidity Ratio Difference {kgWater/kgDryAir}
, !- Zone Latent Heating Design Supply Air Humidity Ratio Input Method
, !- Zone Humidification Design Supply Air Humidity Ratio {kgWater/kgDryAir}
; !- Zone Humidification Design Supply Air Humidity Ratio Difference {kgWater/kgDryAir}

Schedule:Constant,Always On Discrete,,1;

Expand Down Expand Up @@ -877,7 +884,8 @@
Outdoor CO2 schedule; !- Outdoor Carbon Dioxide Schedule Name

ZoneAirHeatBalanceAlgorithm,
ThirdOrderBackwardDifference; !- Algorithm
ThirdOrderBackwardDifference, !- Algorithm
No; !- Do Space Heat Balance for Sizing

ZoneCapacitanceMultiplier:ResearchSpecial,
Zone Capacitance Multiplier Research Special, !- Name
Expand Down Expand Up @@ -8425,12 +8433,12 @@
Branch,
Hot Water Loop Supply Branch 1, !- Name
, !- Pressure Drop Curve Name
DistrictHeating, !- Component 1 Object Type
DistrictHeating:Water, !- Component 1 Object Type
District Heating, !- Component 1 Name
Node 14, !- Component 1 Inlet Node Name
Node 17; !- Component 1 Outlet Node Name

DistrictHeating,
DistrictHeating:Water,
District Heating, !- Name
Node 14, !- Hot Water Inlet Node Name
Node 17, !- Hot Water Outlet Node Name
Expand Down Expand Up @@ -8538,7 +8546,7 @@

PlantEquipmentList,
Hot Water Loop Heating Equipment List, !- Name
DistrictHeating, !- Equipment 1 Object Type
DistrictHeating:Water, !- Equipment 1 Object Type
District Heating; !- Equipment 1 Name

OutputControl:ReportingTolerances,
Expand Down Expand Up @@ -8685,12 +8693,12 @@

ZoneInfiltration:DesignFlowRate,
189.1-2009 - SecSchl - Auditorium - CZ4-8 Infiltration 77.0 percent reduction, !- Name
189.1-2009 - SecSchl - Auditorium - CZ4-8, !- Zone or ZoneList Name
189.1-2009 - SecSchl - Auditorium - CZ4-8, !- Zone or ZoneList or Space or SpaceList Name
SecondarySchool Infil, !- Schedule Name
Flow/ExteriorArea, !- Design Flow Rate Calculation Method
, !- Design Flow Rate {m3/s}
, !- Flow per Zone Floor Area {m3/s-m2}
5.211064e-05, !- Flow per Exterior Surface Area {m3/s-m2}
, !- Flow Rate per Floor Area {m3/s-m2}
5.211064e-05, !- Flow Rate per Exterior Surface Area {m3/s-m2}
, !- Air Changes per Hour {1/hr}
1, !- Constant Term Coefficient
-0.1, !- Temperature Term Coefficient
Expand All @@ -8711,7 +8719,7 @@

Output:Meter,Fans:Electricity,TimeStep;

Output:Meter,Heating:DistrictHeating,TimeStep;
Output:Meter,Heating:DistrictHeatingWater,TimeStep;

Output:Meter,HeatingCoils:EnergyTransfer,TimeStep;

Expand Down Expand Up @@ -8745,3 +8753,4 @@
Construction, !- Category
0, !- Cost
ServicePeriod; !- Start of Costs

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ray[rllib]==2.5.0
ray[rllib]==2.8.0
gymnasium
numpy==1.23.5
protobuf==3.20.3
Expand Down
20 changes: 14 additions & 6 deletions rllibenergyplus/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(self, episode: int, env_config: Dict[str, Any], obs_queue: Queue, a
# HVAC elec (J)
"elec": "Electricity:HVAC",
# District heating (J)
"dh": "Heating:DistrictHeating"
"dh": "Heating:DistrictHeatingWater"
}
self.meter_handles: Dict[str, int] = {}

Expand Down Expand Up @@ -447,16 +447,24 @@ def _rescale(
train_batch_size=4000,
sgd_minibatch_size=128,
vf_loss_coeff=0.01,
model={"use_lstm": args.use_lstm},
# TODO: enable learner API once LSTM / Attention nets are supported
_enable_learner_api=False
use_critic=True,
use_gae=True,
model={
"use_lstm": args.use_lstm,
"vf_share_layers": False,
},
_enable_learner_api=True,
)
.rl_module(_enable_rl_module_api=True)
.framework(
framework=args.framework,
eager_tracing=args.framework == "tf2"
eager_tracing=args.framework == "tf2",
)
.resources(num_gpus=args.num_gpus)
.rollouts(num_rollout_workers=args.num_workers)
.rollouts(
num_rollout_workers=args.num_workers,
rollout_fragment_length="auto",
)
)

print("PPO config:", config.to_dict())
Expand Down

0 comments on commit 3a37b3c

Please sign in to comment.