ahalev / python-microgrid

python-microgrid is a python library to generate and simulate a large number of microgrids.
https://python-microgrid.readthedocs.io
GNU Lesser General Public License v3.0
56 stars 6 forks source link

len(env.state_series()) different than env.observation_space.high.shape[0] #109

Open Alfonso00MA opened 5 days ago

Alfonso00MA commented 5 days ago

Issue Type

Select one:

[] Bug report [X] Question [] Feature Request [] Other

Fill these out:


Question

small_battery = BatteryModule(min_capacity=10,
                              max_capacity=100,
                              max_charge=50,
                              max_discharge=50,
                              efficiency=0.9,
                              init_soc=0.2)

large_battery = BatteryModule(min_capacity=10,
                              max_capacity=1000,
                              max_charge=10,
                              max_discharge=10,
                              efficiency=0.7,
                              init_soc=0.2)

load_ts = 100+100*np.random.rand(24*90) # random load data in the range [100, 200].
pv_ts = 200*np.random.rand(24*90) # random pv data in the range [0, 200].

load = LoadModule(time_series=load_ts)

pv = RenewableModule(time_series=pv_ts)

grid_ts = [0.2, 0.1, 0.5] * np.ones((24*90, 3))

grid = GridModule(max_import=100,
                  max_export=100,
                  time_series=grid_ts)

modules = [
    small_battery,
    large_battery,
    ('pv', pv),
    load,
    grid]

microgrid = Microgrid(modules)

Finally I created a discrete env with the following command:

env = DiscreteMicrogridEnv.from_microgrid(microgrid)

But I noticed the following assertion is not being satisfied. Contrary to what I expected:

assert(len(env.state_series()) == env.observation_space.high.shape[0])

However, the same assertion is satisfied in all the benchmark microgrids:

for i in range(25):
    env = DiscreteMicrogridEnv.from_scenario(microgrid_number=i)
    assert(len(env.state_series()) == env.observation_space.high.shape[0])

Is that the expected behauviour? I am not sure if it should be reported as a bug or not. Any clarification will be appreciated