Skip to content

Code release of EnergyBoost: Learning-based Control of Home Batteries

License

Notifications You must be signed in to change notification settings

sustainable-computing/EnergyBoost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EnergyBoost: Learning-based Control of Home Batteries

EnergyBoost logo

Description

EnergyBoost is a software program that runs on a Raspberry Pi. It utilizes accurate supervised learning models for predicting the next day available solar energy and household demand, and physical models that closely approximate the output of a solar inverter and the state of charge (SoC) of a lithium-ion battery. It formulates the control of battery charge and discharge operations as an optimal control problem over a finite time horizon. This problem is solved using model-based and model-free control techniques.

EnergyBoost is licensed under MIT. Code is written by Baihong Qi.

Contributing

We welcome contributions to EnergyBoost in many forms, such as bug reports, pull requests, etc.

Documentation

Detailed documentation is available at https://sustainable-computing.github.io/EnergyBoost/

Citing our work

Baihong Qi, Mohammad Rashedi, Omid Ardakanian, "EnergyBoost: Learning-based Control of Home Batteries", In Proceedings of the Tenth ACM International Conference on Future Energy Systems (ACM e-Energy), June 2019

Prerequisites

EnergyBoost is python-based and you can easily install all required library through pip install or conda install for conda users.

Required Packages and versions

Packages Version
pandas 0.23.0
numpy 1.14.2
pvlib 0.5.2
matplotlib 2.1.2
scikit-learn 0.20.2
tensorflow-gpu 1.12.0
cxvpy 1.0.6
gurobipy 8.1.0
gym 0.10.5

Installation

You can easily install all required package by run installation script

For more details and troubleshooting about installation of tensorflow and gurobi, please refer to Gurobi and tensorflow webpages.

Table of contents

  • Raw data processing merges home load data together with associated solar data and seprated them by home id. Output files are saved as data_by_home/processed_hhdata_<home id>.csv

  • Fill missing data will fill any missing data for a year by filling the gap by last available value.

  • Generate ac powerThis is a converter uses pvlib to calulate the ac power of solar output, it will add add one more new column to the data file including the power values.

  • Add history will match data for each time slot with its history data of previous time slot and data one week before, these data can be used as features for prediction.

  • GHI model figure and HL model figure compare differnt models for predicting ac power and home load and generate a plot showing the nRMSE of different models.

  • GHI model and HL model train the best models for all homes predicting ac output and homeload. The trainted models are saved so that it can be used repeatly without training again.

  • Get preidct data call the saved models from last step and saved pridicted home load and ac output for each home. It merges the predcit two values with other features of states and save the output as predicted_data/predicted_hhdata_<home id>.csv.

Contains different rule based baselines for different scenarios.

  • Get no solar Get baseline strategy for no solar and no batery installed.

  • Get no battery Get baseline strategy for no battery installed and with solar installed.

  • Get RBC Get a baseline strategy based on rule based TOU price.

These three implementations will call assocaited environments developed for these different scenarios.

Contains implementation of direct mapping method.

  • Mapping Mapping from avaiable features of each time slots to optimal actions solved by the solver and oracle data.

This part contains implementation of model predictive control.

  • The main code for MPC uses cvxpy and Gurobi solver to solve the problem as a convex optimization problem, several versions of the MPC code are used for solve problem in different scenarios like hourly price and Net metering.

  • Create hourly price changes unix time to UTC time and generate a hourly price table.

  • Create TOU price table creates a TOU price table for a year, so it can be used loaded as matrix in the solver.

Implementation of Reinforcement Learning method

  • A2C Implementation of Actor Critic method which will genetrate the stratgy given states and reward.

  • Environment Formulate the problem into MDP environment, contains features of reset initialize states, calulate reward of a given states, and simulate next states.

Scripts for compile results and genrate plots:

  • Get Feasible Actions Results returned by the contoller using predicted data are sometimes not feasible, it will map the learned action to feasible actions and recalculate the bills and record the feasible actions.

  • Compile results of all homes will compile results of all controllers of one given home or all homes and requried scenrios, will write results of the recalated bill in to a new table and create line plots of cumulative bills of a year.

  • Plot ground truth will plot one week ground truth of one home including home load, solar output and optimal action.

  • Plot controller action will plot learned policy of all controllers of one specific period of year.

  • Genrate ROI table will read in bill results of all controllers and calulate needed information for ROI.

  • Calulate PAR of contoller will calulate the average PAR of all homes of all days of a year.

  • Generate violin plots of bills of all controllers will create violin plots of all contollers to show the distrubution of bills of all homes of a given scenario.

Usage and shell scripts

For code of all controllers:

python <controller_method>.py <solar tariff price> <battery size> <Maximum Charging/Discharging rate> <Data file of one home>

e.g. python MPC.py -0.2 6.4 2 processed_hhdata_59_2.csv

For more details about schedule jobs on compute canada, please refer to running jobs on Compute Canada