Skip to main content

Hyperspace Neighbour Penetration package

Project description

https://img.shields.io/pypi/v/hnp.svg Documentation Status License

Data center temperature control is a critical process for maintaining high quality of service. While maintaining temperatures in appropriate temperature bands is paramount, it is also important to consider that every heating or cooling strategy has associated environmental and economic costs. For example, a cooling strategy that makes excessive or unnecessary use of air conditioning will consume more energy than a strategy that better leverages free cooling. As long as operational constraints are satisfied, opportunities to discover temperature control solutions that minimize energy utilization are highly valuable. This repository provides a solution for training a reinforcement learning (RL) agent to perform temperature control in a room. Click here for detailed documentation.

Features

  • Innovative discretization method: The provided solution leverages an innovation in state space design called Hyperspace Neighbour Penetration (HNP), which allows slowly-changing continuous variables to be approximated as discrete variables.

  • Support for building control environments: The HNP package has built-in support for Sinergym - a building control simulation environment, as well as Beobench - a toolkit providing unified access to building control environments.

  • Ready-to-use RL agents: A HNP-enabled Q-Learning agent and two baseline agents are provided in the package.

HNP

A key assumption in HNP is that continuous state spaces with very incremental, locally linear transitions can be effectively discretized into relatively coarse ranges or bands of values as tiles. When this type of coarse discretization is applied to a slowly-changing variable (e.g. temperature), it can lead to situations where an action (e.g. changing the setpoints) results in such a small change to the subsequent state observation that no discrete state transition has actually occurred. A naïve solution could be to increase the granularity of the state space, i.e. to consider much smaller changes in temperature as distinct elements of the state space, but it is computationally expensive or impossible to establish an extremely granular grid system. Alternatively, HNP computes multiple values from tile boundaries and then aggregates them using a weighted norm. This enables state-action pairs to result in steps towards other states and their corresponding values.

HNP is fully described in its foundational paper.

Supported Environments

Sinergym

Sinergym is a building control environment that follows OpenAI Gym interface and uses EnergyPlus simulator. To use Sinergym, see detailed instruction on how to install here.

Beobench

Beobench is a toolkit providing unified access to building control environments for RL (Sinergym also supported). It uses docker to manage all environment dependencies in the background. See detailed instruction on how to use Beobench here.

Supported Agents

The HNP package provides the following agents:

  • Random Action Agent: An agent that takes a random action

  • Fixed Action Agent: An agent that always take a pre-defined action

  • HNP-enabled Q-Learning Agent: A Q-learning agent with built-in HNP that allows different types of observation variables

Quickstart

Requirements

  • Python ≥ 3.9

  • Sinergym == 2.2.0

Installation

To install hnp from PyPI:

pip install hnp

Example Usage

This is a minimalist example of using the HNP Q-Learning agent in Sinergym

import numpy as np

from hnp.agents import QLearningAgent
from hnp.environment import ObservationWrapper, create_env

config = {
    "agent": {
        "num_episodes": 100,
        "horizon": 24,
        "gamma": 0.99,
        "num_tiles": 20,
        "initial_epsilon": 1,
        "epsilon_annealing": 0.999,
        "learning_rate": 0.1,
        "learning_rate_annealing": 0.999
    },
    "env": {
        "name": "Eplus-5Zone-hot-discrete-v1",
        "normalize": True,
        "obs_to_keep": [4, 5, 13],
        "mask": [0, 0, 0]
    }
}

obs_to_keep = np.array(config["env"]["obs_to_keep"])
mask = np.array(config["env"]["mask"])

env = create_env(config["env"])
env = ObservationWrapper(env, obs_to_keep)

agent = QLearningAgent(
    env,
    config["agent"]["params"],
    mask,
)
agent.train()
agent.save_results()
env.close()

Documentation

Detailed package documentation: HNP Docs

License

The code in this repository is published under 3-Clause BSD license (see LICENSE file).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hnp-1.0.3.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

hnp-1.0.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file hnp-1.0.3.tar.gz.

File metadata

  • Download URL: hnp-1.0.3.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for hnp-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7fb40e2321f18c4585c8d1ec7c4372daa149a53163925ec51e7d70ca59a84bf2
MD5 9410e4668116f89c7a2976bc691b6116
BLAKE2b-256 3d7bda24d9f74b54e80f8926a5c8f441fd9219f3300045af84de44af3249ef75

See more details on using hashes here.

File details

Details for the file hnp-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: hnp-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for hnp-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3f707081dbaa0ffed073eb9795df4d7b373d8c495c71ccd00a1132c76ed2a8e5
MD5 afdd4e4c112d0e9e302d10b576aabc03
BLAKE2b-256 9921345cfa2f18ab31c0805602a22c9b83f3904af17d2a2f22b9bc0e7a4aa107

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page