Commit a734e3b0 authored by Ibrahim's avatar Ibrahim
Browse files

RL control + new feedback signal for cooling towers

parent 51ef52b4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -15,3 +15,4 @@ src/bin/*
*.pyc
__pycache__
*.ipynb_checkpoints
*.mp4
 No newline at end of file
+1 −122
Original line number Diff line number Diff line
@@ -26,128 +26,7 @@ This repository can be downloaded via `git clone` or [directly as a zip file her

### Installation for ESB condenser water control

The controller (`src/controller.py`) imports measurements from BDX (Buildinglogix Data eXchange), and writes a setpoint to a text file. Access to BDX requires login credentials.

To run the controller, (1) review control settings, (2) create/update the production environment, (3) activate it, call the script.

The environment needs to be created only once. Every time after, the environment is activated and the scipt is called.

#### 0. Quick start

Refer to this section if you're aware of how the script is set up, and you just want to restart it.

```
cd CODE_DIRECTORY                             # navigate to code directory
git reset --hard                              # ignore local changes
git pull                                      # update code from remote branch
conda env update -f=./environment.yml         # update virtual environment (assuming already created)
conda activate esb-prod                       # activate environment
python src/controller.py -s src/settings.ini  # run script, giving path to settings file
```

#### 1. Review settings before running the controller

The controller settings can be specified in a settings file. The default settings file is located in `src/settings.ini`. A file can be created at another location but the file path must be specified when running the controller script. To create a custom settings file, just copy `src/settings.ini` to a location of your choice.

1. Fill in the `username` and `password` values for accessing BDX in the settings file, OR:

    1. Optionally, create `src/bdxcredentials.ini` with these contents instead of populating settings fields. This will prevent the `settings.ini` file credentials from being erased when the repository is updated from a remote branch.
    ```
    [DEFAULT]
    username = USERNAME
    password = PASSWORD
    ```

2. Choose which controllers are to be run by adding a comma separated list of sections in the `controllers` field. For e.g. `controllers=CONTROLLER.ESB,CONTROLLER.KISSAM`. Fill their respective fields as well.

3. Change verbosity settings.

4. Override any default settings in any non-`DEFAULT` section. For e.g. if `verbosity` is specified under `DEFAULT` and `CONTROLLER.ESB`, then for the ESB controller, the more specific setting will take effect over default.

#### 2. Create/update the production environment

Using `conda` (Anaconda/Miniconda package manager):

```bash
# Create new environment
conda env create -f=./environment.yml
# OR, update production environment
conda env update -f=./environment.yml
```

#### 3. Activate environment, run scripts

```bash
python src/controller.py --help

usage: controller.py [-h] [-s SETTINGS] [-l LOGS] [-r LOGS_SERVER]
                     [-v {CRITICAL,ERROR,WARNING,INFO,DEBUG}] [-d] [-n]

Condenser set-point optimization script.

optional arguments:
  -h, --help            show this help message and exit
  -s SETTINGS, --settings SETTINGS
                        Location of settings file.
  -l LOGS, --logs LOGS  Location of file to write logs to.
  -r LOGS_SERVER, --logs-server LOGS_SERVER
                        http://host[:port][/path] of remote server to POST
                        logs to.
  -v {CRITICAL,ERROR,WARNING,INFO,DEBUG}, --verbosity {CRITICAL,ERROR,WARNING,INFO,DEBUG}
                        Verbosity level.
  -d, --dry-run         Exit after one action to test script.
  -n, --no-network      For testing code execution: no API calls.

Additional settings can be changed from the specified settings ini file.
```

Example commands:

```bash
# update production environment
conda env update -f environment.yml

# activate production environment
conda activate esb-prod

# This will exit after taking one action as a test run:
# Uses settings from the default location (src/settings.ini)
# Writes to default logs file (./logs.txt)
python src/controller.py --dry-run

# Or, this will read settings from a custom location
# If settings are provided at command line and in settings file, command line
# will take precedence.
python src/controller.py --settings ~/ESB/mysettings.ini

```

### Monitoring controller

Besides logs written to error stream and a local file, the controller can also communicate with a HTTP server or send emails.

The code comes with a `src/monitor.py` script that can listen in as a HTTP server to updates sent by `src/controller.py` running on a different machine. Settings can be specified in the settings ini file. For duplicate settings, the monitor falls back on values in the `DEFAULTS` section in the ini for the controller if it cannot find them in the `MONITOR` section.

```bash
$ python src/monitor.py --help

usage: monitor.py [-h] [-s SETTINGS] [-l LOGS] [-p PORT] [--host HOST]
                  [-v {CRITICAL,ERROR,WARNING,INFO,DEBUG}]

Monitor for condenser set-point optimization script.

optional arguments:
  -h, --help            show this help message and exit
  -s SETTINGS, --settings SETTINGS
                        Location of settings file.
  -l LOGS, --logs LOGS  Location of file to write logs to.
  -p PORT, --port PORT  Port number of server to listen on.
  --host HOST           Host address of server to listen on. e.g. 0.0.0.0
  -v {CRITICAL,ERROR,WARNING,INFO,DEBUG}, --verbosity {CRITICAL,ERROR,WARNING,INFO,DEBUG}
                        Verbosity level.

Additional settings can be changed from the specified settings ini file.
```
Refer to the [controller documentation](docs/8-control.md).

### Development

+6 −4
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ name: esb
channels:
  - conda-forge
dependencies:
  - python=3.7
  - python=3.9
  - numpy
  - pandas
  - matplotlib
@@ -11,11 +11,12 @@ dependencies:
  - jupyter_contrib_nbextensions
  - tqdm
  - scikit-learn
  - pytorch::pytorch=1.8
  - pytorch::pytorch=1.10
  - cudatoolkit=10.2
  - tslearn
  - optuna=2.8.0
  - dash=1.17.0
  - optuna
  - dash
  - pyfmi
  - pip
  - pip:
    - python-dateutil
@@ -25,3 +26,4 @@ dependencies:
    - tensorboardX
    - higher==0.2.1
    - git+https://git.isis.vanderbilt.edu/SmartBuildings/bdx.git@v0.2.6
    - git+https://github.com/CPCLAB-UNIPI/SIPPY@6c233881f32280ee79267cba06b2f56984424ebd#egg=sippy
 No newline at end of file

docs/8-control.md

0 → 100644
+130 −0
Original line number Diff line number Diff line
---
title: 'Kissam Controller Notes'
order: 8
hasequations: false
---

### Installation for ESB condenser water control

The controller (`src/controller.py`) imports measurements from BDX (Buildinglogix Data eXchange), and writes a setpoint to a text file. Access to BDX requires login credentials.

To run the controller, (1) review control settings, (2) create/update the production environment, (3) activate it, call the script.

The environment needs to be created only once. Every time after, the environment is activated and the scipt is called.

#### 0. Quick start

Refer to this section if you're aware of how the script is set up, and you just want to restart it.

```
cd CODE_DIRECTORY                             # navigate to code directory
git reset --hard                              # ignore local changes
git pull                                      # update code from remote branch
conda env update -f=./environment.yml         # update virtual environment (assuming already created)
conda activate esb-prod                       # activate environment
python src/controller.py -s src/settings.ini  # run script, giving path to settings file
```

#### 1. Review settings before running the controller

The controller settings can be specified in a settings file. The default settings file is located in `src/settings.ini`. A file can be created at another location but the file path must be specified when running the controller script. To create a custom settings file, just copy `src/settings.ini` to a location of your choice.

1. Fill in the `username` and `password` values for accessing BDX in the settings file, OR:

    1. Optionally, create `src/bdxcredentials.ini` with these contents instead of populating settings fields. This will prevent the `settings.ini` file credentials from being erased when the repository is updated from a remote branch.
    ```
    [DEFAULT]
    username = USERNAME
    password = PASSWORD
    ```

2. Choose which controllers are to be run by adding a comma separated list of sections in the `controllers` field. For e.g. `controllers=CONTROLLER.ESB,CONTROLLER.KISSAM`. Fill their respective fields as well.

3. Change verbosity settings.

4. Override any default settings in any non-`DEFAULT` section. For e.g. if `verbosity` is specified under `DEFAULT` and `CONTROLLER.ESB`, then for the ESB controller, the more specific setting will take effect over default.

#### 2. Create/update the production environment

Using `conda` (Anaconda/Miniconda package manager):

```bash
# Create new environment
conda env create -f=./environment.yml
# OR, update production environment
conda env update -f=./environment.yml
```

#### 3. Activate environment, run scripts

```bash
python src/controller.py --help

usage: controller.py [-h] [-s SETTINGS] [-l LOGS] [-r LOGS_SERVER]
                     [-v {CRITICAL,ERROR,WARNING,INFO,DEBUG}] [-d] [-n]

Condenser set-point optimization script.

optional arguments:
  -h, --help            show this help message and exit
  -s SETTINGS, --settings SETTINGS
                        Location of settings file.
  -l LOGS, --logs LOGS  Location of file to write logs to.
  -r LOGS_SERVER, --logs-server LOGS_SERVER
                        http://host[:port][/path] of remote server to POST
                        logs to.
  -v {CRITICAL,ERROR,WARNING,INFO,DEBUG}, --verbosity {CRITICAL,ERROR,WARNING,INFO,DEBUG}
                        Verbosity level.
  -d, --dry-run         Exit after one action to test script.
  -n, --no-network      For testing code execution: no API calls.

Additional settings can be changed from the specified settings ini file.
```

Example commands:

```bash
# update production environment
conda env update -f environment.yml

# activate production environment
conda activate esb-prod

# This will exit after taking one action as a test run:
# Uses settings from the default location (src/settings.ini)
# Writes to default logs file (./logs.txt)
python src/controller.py --dry-run

# Or, this will read settings from a custom location
# If settings are provided at command line and in settings file, command line
# will take precedence.
python src/controller.py --settings ~/ESB/mysettings.ini

```

### Monitoring controller

Besides logs written to error stream and a local file, the controller can also communicate with a HTTP server or send emails.

The code comes with a `src/monitor.py` script that can listen in as a HTTP server to updates sent by `src/controller.py` running on a different machine. Settings can be specified in the settings ini file. For duplicate settings, the monitor falls back on values in the `DEFAULTS` section in the ini for the controller if it cannot find them in the `MONITOR` section.

```bash
$ python src/monitor.py --help

usage: monitor.py [-h] [-s SETTINGS] [-l LOGS] [-p PORT] [--host HOST]
                  [-v {CRITICAL,ERROR,WARNING,INFO,DEBUG}]

Monitor for condenser set-point optimization script.

optional arguments:
  -h, --help            show this help message and exit
  -s SETTINGS, --settings SETTINGS
                        Location of settings file.
  -l LOGS, --logs LOGS  Location of file to write logs to.
  -p PORT, --port PORT  Port number of server to listen on.
  --host HOST           Host address of server to listen on. e.g. 0.0.0.0
  -v {CRITICAL,ERROR,WARNING,INFO,DEBUG}, --verbosity {CRITICAL,ERROR,WARNING,INFO,DEBUG}
                        Verbosity level.

Additional settings can be changed from the specified settings ini file.
```
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ order: 1000
hasequations: false
---

Data for setpoint is recorded in BDX trend 3481. Cooling tower 1 and 2 data is in trends 2422, 2841.

## Periods

Timestamps for various system changes.
@@ -22,6 +24,9 @@ Timestamps for various system changes.
    2021-06-15 1403-5   Script errored, couldn't read BDX due to faulty TLS certificates
    2021-06-16 1240-5   Script restarted with correct paths
    2021-06-17 0505-5   Chiller 2 online (check exact time)
    2021-08-15 0610-5   Controller offline. Server was restarted.
    2021-08-17 1214-5   Controller restarted.
    2021-08-31 1100-5   Chiller 1 online

## Timespans to investigate

Loading