-
Notifications
You must be signed in to change notification settings - Fork 119
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
Missing observations in runner logs after running RandomRedispatchingAgent #126
Comments
Update: The current behavior sets the game over to be at the first ambiguous action encountered when reloading, even if logs data keeps going. In that case, it happens at index 34, but data on disk is correct with a 100 timesteps. For some reason, some import grid2op
from grid2op.Agent import DeltaRedispatchRandomAgent
from grid2op.Runner import Runner
from grid2op import make
from grid2op.Episode import EpisodeData
import os
import numpy as np
path_agent_saved='/tmp/redispatch-bug'
os.makedirs(path_agent_saved,exist_ok = True)
#run redispatch agent on one scenario for 100 timesteps
dataset = "rte_case14_realistic"
nb_episode=1
nb_timesteps=100
with make(dataset) as env:
agent = DeltaRedispatchRandomAgent(env.action_space)
runner = Runner(**env.get_params_for_runner(),
agentClass=None,
agentInstance=agent)
nb_episode=1
res = runner.run(nb_episode=nb_episode,
path_save=path_agent_saved,
nb_process=1,
max_iter=nb_timesteps,
env_seeds=[0],
agent_seeds=[0],
pbar=True)
print ("{}/{} steps".format(res[0][3], res[0][4]))
# Load with ambiguous actions
episode_data = EpisodeData.from_disk(path_agent_saved, '000')
# They are nb_timesteps objects
print ("EP objs actions len", len(episode_data.actions.objects))
print ("EP objs obs len", len(episode_data.observations.objects))
# But limited lens due to gameover encountered by ambiguous env action at t34
print ("EP obs len", len(episode_data.observations))
print ("EP actions len", len(episode_data.actions))
# Hack to bypass ambiguous actions gameover
grid2op.Action.BaseAction.check_space_legit = grid2op.Space.GridObjects.check_space_legit
# Reload
episode_data = EpisodeData.from_disk(path_agent_saved, '000')
# They are nb_timesteps objects
print ("bypass EP objs actions len", len(episode_data.actions.objects))
print ("bypass EP objs obs len", len(episode_data.observations.objects))
# With bypass, lens are correct
print ("bypass EP obs len", len(episode_data.observations))
print ("bypass EP actions len", len(episode_data.actions))
# Show where the problems is
print ("Env ramps up", episode_data.actions.helper.gen_max_ramp_up)
print ("Env ramps down", episode_data.actions.helper.gen_max_ramp_down)
print ("Env action index 34:")
print (episode_data.env_actions[34])
print ("Env action index 34 ambiguous:")
print (episode_data.env_actions[34].is_ambiguous()) Outputs:
Here we can see that on reload, env actions are doing redispatching (not expected), and above ramps (even worst) !!! |
This is probably due to the data that does not respect the ramps or pmin / pmax. Thus the environment is forced to take actions, that are ambiguous (and not checked they are because grid2op supposes the input data are consistent, which apparently they are not) |
…dispatch, set the backend action directly instead
Environment
1.1.1
osx
Bug description
When running the RandomRedispatchingAgent on 100 timesteps, the runner runs until the end of the scenario according to the progression bar.
But when reloading the logs of the runner, we only access 35 timesteps of observations
How to reproduce
The text was updated successfully, but these errors were encountered: