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

Incorrect reward on end of episode without error #164

Closed
bwitherspoon opened this issue Dec 12, 2020 · 2 comments
Closed

Incorrect reward on end of episode without error #164

bwitherspoon opened this issue Dec 12, 2020 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@bwitherspoon
Copy link
Contributor

Environment

  • Grid2op version: 1.4.0
  • System: Fedora 32

Bug description

According to the documentation for the Reward object, if has_error is false and is_done is true this should indicate the end of an episode without error (i.e. success). However, it appears that is_done is not being set on the final step. Maybe related to #146.

How to reproduce

Code snippet

import grid2op
from grid2op.Reward import BaseReward
from grid2op.dtypes import dt_float
from grid2op.Exceptions import DivergingPowerFlow

class Reward(BaseReward):
    def __init__(self):
        super().__init__()
        self.reward_min = dt_float(-1.0)
        self.reward_max = dt_float(1.0)

    def __call__(self, action, env, has_error, is_done, is_illegal, is_ambiguous):
        if has_error:
            return self.reward_min
        elif is_done:
            return self.reward_max

        return dt_float(0.0)

env = grid2op.make("l2rpn_case14_sandbox", reward_class=Reward)
max_timestep = env.chronics_handler.max_timestep()

obs = env.reset()
env.fast_forward_chronics(max_timestep - 100)
obs = env.get_obs()

while True:
    obs, reward, done, info = env.step(env.action_space())

    for ex in info["exception"]:
        print(ex)

    if done:
        print("reward:", reward)
        break

Current output

reward: 0.0

Expected output

reward: 1.0
@bwitherspoon bwitherspoon added the bug Something isn't working label Dec 12, 2020
@BDonnot BDonnot added the good first issue Good for newcomers label Jan 4, 2021
@BDonnot
Copy link
Collaborator

BDonnot commented Jan 4, 2021

Hello,

I could reproduce this bug. Thanks a lot for the detail explanation and the code snippet :-)

I will push the fix in the next release of grid2op (probably before the end of January 2021, but i'm not sure).

Thanks

Benjamin

BDonnot referenced this issue in BDonnot/Grid2Op Jan 4, 2021
Push fix to issue rte-france#164
@BDonnot
Copy link
Collaborator

BDonnot commented Mar 31, 2021

Fixed in release 1.5.0

@BDonnot BDonnot closed this as completed Mar 31, 2021
BDonnot added a commit that referenced this issue Jan 11, 2023
update for version 1.8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants