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

pv_gen appears to vary across tasks #19

Closed
enjeeneer opened this issue Oct 13, 2022 · 1 comment
Closed

pv_gen appears to vary across tasks #19

enjeeneer opened this issue Oct 13, 2022 · 1 comment

Comments

@enjeeneer
Copy link

enjeeneer commented Oct 13, 2022

  • bauwerk version: 0.21
  • Python version: 3.8
  • Operating System: macOS

Description

I'm finding that pv_gen varies across tasks which is unexpected as I presumed it be task-independent.

What I Did

build_dist_b = bauwerk.benchmarks.BuildDistB()
tasks = build_dist_b.train_tasks

for i, task in enumerate(tasks):
    env = build_dist_b.make_env()
    env.set_task(task)
    actions = bauwerk.solve(env)
    task_obs = []
    env = ObsWrapper(env)
    obs = env.reset()
    
    for action in actions[0]:
        obs, reward, done, info = env.step(np.array(action, dtype=np.float32))
        task_obs.append(obs)

    task_obs = np.concatenate(task_obs).reshape(len(actions[0]),-1)
    print('task {} max pv_gen: {:.2f}'.format(i, np.max(task_obs[:, 2])))
------------------------
task 0 max pv_gen: 7.50
task 1 max pv_gen: 7.46
task 2 max pv_gen: 5.13
task 3 max pv_gen: 7.50
task 4 max pv_gen: 7.50
task 5 max pv_gen: 7.50
task 6 max pv_gen: 7.50
task 7 max pv_gen: 7.50
task 8 max pv_gen: 7.49
task 9 max pv_gen: 7.50
task 10 max pv_gen: 7.50
task 11 max pv_gen: 7.50
task 12 max pv_gen: 7.38
task 13 max pv_gen: 7.50
task 14 max pv_gen: 7.43
task 15 max pv_gen: 7.50
task 16 max pv_gen: 5.58
task 17 max pv_gen: 6.00
task 18 max pv_gen: 7.46
task 19 max pv_gen: 6.81

For reference my ObsWrapper is taking the dictionary values form obs and flattening into an array:

class ObsWrapper(gym.Wrapper):
    def __init__(self, env):
        super(ObsWrapper, self).__init__(env)
        self.env = env

    def step(self, action):
        """
        Steps simulator given action and flattens observation.
        :param action: array of shape [act_dim, ]
        :return:
        """
        obs_dict, reward, done, info = self.env.step(action)

        # modify obs
        vals = []
        for _, value in obs_dict.items():
            vals.append(value)
        obs_array = np.concatenate(vals, axis=0, dtype=np.float32)

        return obs_array, reward, done, info
@enjeeneer
Copy link
Author

This was my mistake, above I'm accidentally indexing battery_cont not pv_gen. When I correctly index pv_gen the behaviour is as expected, and there is no 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

No branches or pull requests

1 participant