Giter Club home page Giter Club logo

dragg's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m @corymosiman12. I currently work as a software engineer at PassiveLogic.
  • ๐Ÿ‘€ Iโ€™m interested in industrial automation, scientific machine learning, optimization, bicycles.
  • ๐ŸŒฑ Iโ€™m currently learning:
    • Physical system modeling with Modelica
  • ๐Ÿ“ซ Reach out on LinkedIn.

dragg's People

Contributors

apigott avatar corymosiman12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

apigott ariwoolar

dragg's Issues

Battery charges in 5kW increments

The battery model currently charges in large chunks cycling the battery (typically p_batt_ch = battery_max_rate until SOC = 100%).

This is caused by the GLPK_MI solver which uses the revised simplex method [1]. The revised simplex method promotes a large basis (prefers solutions in which the highest number of decision variables is 0). In the linear case/for the L1 norm this causes large peaks in the decision variable p_batt_ch and other energy storage systems.

A simple example (you can think of c as the TOU price vector and x as p_batt_ch):

max (sum(c*x[i]))
subject to: sum(x[i]) <= 13
x[i] <=5
c = [1, 1, 1, 1.1, 1]

Intuitively there are many solutions to this problem. The non-uniformity of c promotes charging the maximum amount at i=4 but the rest of the time steps have equivalent rewards.

argmax = {[5, 0, 0, 5, 3], or [5, 3, 0, 5, 0], or [2, 2, 2, 5, 2]}. The revised simplex method promotes solutions 1 and 2. However, generally we desire solution 3 in which the battery charges for a longer time period at a slower rate [cite?].

This can be solved linearly if we explicitly penalize the change in charge rate by some weighting factor lambda. Let x_init be the observed rate of charge taken in the last time step.

max (sum(c*x[i]) + lambda * sum [abs(dx)])
subject to: sum(x[i]) <= 13
dx[0] = x_init - x[0]
dx[i] = x[i-1] - x[i]
x[i] <=5
c = [1, 1, 1, 1.1, 1]

image

[1] https://www.gnu.org/software/glpk/
[2] https://www.researchgate.net/publication/226205536_Hyper-Sparsity_in_the_Revised_Simplex_Method_and_How_to_Exploit_it

trying to run main.py ERROR

Hi, i'm trying to use your repository, i installed it and followed in running the main.py in order to do some test and understand how it works, but the following error appears:

Traceback (most recent call last):
  File "main.py", line 7, in <module>
    a.run()
  File "/Users/pietrorandomazzarino/Downloads/dragg-master/dragg/aggregator.py", line 1208, in run
    self.run_rl_agg()
  File "/Users/pietrorandomazzarino/Downloads/dragg-master/dragg/aggregator.py", line 1041, in run_rl_agg
    self.setup_rl_agg_run()
  File "/Users/pietrorandomazzarino/Downloads/dragg-master/dragg/aggregator.py", line 1029, in setup_rl_agg_run
    self.forecast_setpoint = self._gen_setpoint(self.timestep)
  File "/Users/pietrorandomazzarino/Downloads/dragg-master/dragg/aggregator.py", line 804, in _gen_setpoint
    self.tracked_loads[:-1] = self.tracked_loads[1:]
AttributeError: 'Aggregator' object has no attribute 'tracked_loads'

I've seen that the creationg of tracked_loads happens in the function set_dummy_rl_parameters() which is never called in any part of the aggregator script, so I was wondering if this is a usable tool or if needs some changes.
Then if possible I wanted to better understand what's happening and what is tracked_loads, which is its purpose etc..
Thanks a lot for the attention
PRM

battery_only houses aren't prioritizing self-consumption

At some points (ts = [17,18]) the battery_only houses sell electricity back to the grid directly from their battery. This conflicts with the Equation 20 which claims that the power discharged by the battery is consumed behind the meter.

P_{load}^{t-1} + P_{ch}^{t-1} - P_{dis}^{t-1} >= 0 (Eq. 20)

Screen Shot 2020-05-15 at 1 52 05 PM

redis server fills up after 256 timesteps

The Redis server has a (default) memory limit of 256 files on Mac. This can easily be overridden in the terminal with ulimit -n 1024 or any other arbitrary file limit.

However, in order to avoid massive memory requirements I propose flushing the Redis files using .flushall() on a daily basis.

In the meantime I've added a flush off the Redis database on start of each run

IndexError self.tracked_price[0] = self.reward_price[0]

So trying to just get my head back into this. The contents of my config.toml are below. I'm trying to run (what I understand to be):

  • NOT trying to run any RL stuff
  • Just trying to run the original RBO MPC stuff. So I change the run_rbo_mpc param to true and set the others to false

I changed n_nodes=1 as or else it wasn't giving me any useful tracebacks. Anyways:

  1. Updated requirements
  2. Started the redis server: $ redis-server, runs successfully
  3. Try to run: python main.py and get following:

@apigott Thoughts?

cmosiman$ python main.py -u
/Users/cmosiman/.pyenv/versions/dragg/lib/python3.6/site-packages/pandas/compat/__init__.py:120: UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.
  warnings.warn(msg)
INFO:aggregator:Set the version write out to ['dn-wd-v4', 'dn-wd-v4-avg']
INFO:aggregator:Start: 2015-01-01T00:00:00; End: 2015-01-02T00:00:00; Number of hours: 24
INFO:aggregator:Made it to Aggregator Run
INFO:aggregator:Flushing Redis
INFO:aggregator:Homes looking ok!
INFO:aggregator:Performing baseline run for horizon: 6
multiprocess.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/Users/cmosiman/.pyenv/versions/dragg/lib/python3.6/site-packages/multiprocess/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/Users/cmosiman/.pyenv/versions/dragg/lib/python3.6/site-packages/multiprocess/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/Users/cmosiman/.pyenv/versions/dragg/lib/python3.6/site-packages/pathos/helpers/mp_helper.py", line 15, in <lambda>
    func = lambda args: f(*args)
  File "/Users/cmosiman/Github/dragg/dragg/mpc_calc.py", line 28, in manage_home
    home.run_home()
  File "/Users/cmosiman/Github/dragg/dragg/mpc_calc.py", line 716, in run_home
    self.solve_type_problem()
  File "/Users/cmosiman/Github/dragg/dragg/mpc_calc.py", line 692, in solve_type_problem
    self.set_environmental_variables()
  File "/Users/cmosiman/Github/dragg/dragg/mpc_calc.py", line 270, in set_environmental_variables
    self.cast_redis_curr_rps()
  File "/Users/cmosiman/Github/dragg/dragg/mpc_calc.py", line 684, in cast_redis_curr_rps
    self.tracked_price[0] = self.reward_price[0]
IndexError: list index out of range
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "main.py", line 7, in <module>
    a.run()
  File "/Users/cmosiman/Github/dragg/dragg/aggregator.py", line 1174, in run
    self.run_baseline()
  File "/Users/cmosiman/Github/dragg/dragg/aggregator.py", line 875, in run_baseline
    self.run_iteration()
  File "/Users/cmosiman/Github/dragg/dragg/aggregator.py", line 819, in run_iteration
    results = pool.map(manage_home, self.as_list)
  File "/Users/cmosiman/.pyenv/versions/dragg/lib/python3.6/site-packages/pathos/multiprocessing.py", line 137, in map
    return _pool.map(star(f), zip(*args)) # chunksize
  File "/Users/cmosiman/.pyenv/versions/dragg/lib/python3.6/site-packages/multiprocess/pool.py", line 266, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/Users/cmosiman/.pyenv/versions/dragg/lib/python3.6/site-packages/multiprocess/pool.py", line 644, in get
    raise self._value
IndexError: list index out of range
[community]
total_number_homes = [ 10, 0,]
homes_battery = [ 0, 0,]
homes_pv = [ 3, 0,]
homes_pv_battery = [ 0, 0,]
overwrite_existing = true
house_p_avg = 1.0

[simulation]
start_datetime = "2015-01-01 00"
end_datetime = "2015-01-02 00"
loop_days = true
random_seed = 12
n_nodes = 1
load_zone = "LZ_HOUSTON"
check_type = "all"
run_rbo_mpc = true
run_rl_agg = false
run_rl_simplified = false
checkpoint_interval = "daily"

[rl]
version = [ "dn-wd-v4", "dn-wd-v4-avg"]

[rl.parameters]
learning_rate = [ 0.01,]
discount_factor = [ 1.0,]
batch_size = [ 4, 32,]
exploration_rate = [ 0.01,]
twin_q = false

[rl.utility]
rl_agg_action_horizon = [ 6, 4,]
rl_agg_forecast_horizon = 1
base_price = 0.1
action_space = [ -1.0, 1.0,]
hourly_steps = [ 1,]
minutes_per_step = 120
tou_enabled = false

[rl.simplified]
response_rate = 0.3
offset = 0.2

[home.hvac]
r_dist = [ 6.8, 9.199999999999999,]
c_dist = [ 4.25, 5.75,]
p_cool_dist = [ 3.5, 3.5,]
p_heat_dist = [ 3.5, 3.5,]
temp_sp_dist = [ 18, 22,]
temp_deadband_dist = [ 2, 3,]

[home.wh]
r_dist = [ 18.7, 25.3,]
c_dist = [ 4.25, 5.75,]
p_dist = [ 2.5, 2.5,]
sp_dist = [ 45.5, 48.5,]
deadband_dist = [ 9, 12,]
size_dist = [ 200, 300,]

[home.battery]
max_rate = 5
capacity = 13.5
cap_bounds = [ 0.15, 0.85,]
charge_eff = 0.95
discharge_eff = 0.99
cons_penalty = 0.005

[home.pv]
area = 32
efficiency = 0.2

[home.hems]
prediction_horizon = [ 6,]
price_uncertainty = 0.3
sub_subhourly_steps = [ 4,]
solver = "GLPK_MI"

[rl.utility.tou]
shoulder_times = [ 9, 21,]
shoulder_price = 0.09
peak_times = [ 14, 18,]
peak_price = 0.13

[home.wh.waterdraws]
n_big_draw_dist = [ 2, 5,]
n_small_draw_dist = [ 0, 0,]
big_draw_size_dist = [ 25, 40,]
small_draw_size_dist = [ 7.5, 15.0,]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.