Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Alfonso00MA opened this issue Sep 23, 2024 · 1 comment · Fixed by #112
Closed

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

Alfonso00MA opened this issue Sep 23, 2024 · 1 comment · Fixed by #112

Comments

@Alfonso00MA
Copy link

Issue Type

Select one:

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

Fill these out:

  • python version: Python 3.10.13
  • python-microgrid version: python-microgrid==1.4.1

Question

  • Question:

I have been following the "Quick Start" section in the docs:

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

@ahalev
Copy link
Owner

ahalev commented Dec 21, 2024

This is a bug, thanks for calling this out. Will be fixed in #112 and merged into a future version. For use now, feel free to pull that PR.

@ahalev ahalev linked a pull request Dec 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants