Skip to content

wesenu/energy-py-linear

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

energy-py-linear

energy-py-linear is a library for optimizing energy systems using mixed integer linear programming. Linear programming can guarantee convergence to the optimal solution of convex linear equations.

Battery storage and combined heat and power are two examples of energy systems that can be optimized as linear programs.

Usage

import energypylinear as epl

model = epl.Battery(power=2, capacity=4, efficiency=1.0)

prices = [10, 50, 10, 50, 10]

#  returns a list of ordered dictionaries
info = model.optimize(prices, timestep='30min')

#  pandas can be used to make the output human readable

import pandas as pd

pd.DataFrame().from_dict(info)

   Import [MW]  Export [MW]  Power [MW]  Charge [MWh]
0          2.0          0.0         2.0      0.000000
1          0.0          2.0        -2.0      0.066667
2          2.0          0.0         2.0      0.000000
3          0.0          2.0        -2.0      0.066667
4          NaN          NaN         NaN      0.000000

Note that the last row is all NaN except for the Charge - this is because the Charge indicates the battery position at the start of each interval. The last row is included so we can see the battery level at the end of the optimization run.

It is also possible to send in forecast prices along with actual prices, and to change the initial charge. The model optimizes for the forecasts - this allows measurement of forecast quality by comparing actual with forecast costs.

#  a forecast that is the inverse of the prices we used above
>>> forecasts = [50, 10, 50, 10, 50]

>>> info = model.optimize(prices, forecasts=forecasts, timestep='30min')

Installation

$ git clone https://github.com/ADGEfficiency/energy-py-linear

$ python setup.py install

The main dependency of this project is PuLP. For further reading on PuLP:

About

Optimizing energy systems using mixed integer linear programming

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 54.7%
  • Jupyter Notebook 45.3%