-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Feature Request] Gymnasium: Add options
argument to VecEnv.reset()
#1523
Comments
Hello, However, as for seed, I think it would be ok to provide a
In the meantime, you can always use the
All the differences: https://stable-baselines3.readthedocs.io/en/master/guide/vec_envs.html#vecenv-api-vs-gym-api PS: please don't forget to fill the "alternative" part next time |
This is what I implemented so far: observations = env.reset()
env.env_method("reset", **{"array_x0": array_x0}) When evaluating a trajectory I first call the I would like to run only If I remove the second line to keep the below, env.env_method("reset", **{"array_x0": array_x0}) Do you agree I am going to mess something up with the Monitor wrapper, when logging reward for instance ?
I am not talking about
Thank you!
|
Hello, I meant that with both gym 0.21/0.26 or gymnasium, you can do: class CustomEnv(gym.Env):
def reset(self):
# Use seed and options
self._reset_state(self._seed, self._options)
# Reset seed and options
self._options = {}
self._seed = None
return self.get_obs()
def set_seed(self, seed: int):
self._seed = seed
def set_options(self, options):
# Set options for the next reset
self._options = options
vec_env = DummyVecEnv([lambda: CustomEnv()])
vec_env.env_method("set_seed", 0)
vec_env.env_method("set_options", dict(a=1))
vec_env.reset() and you don't need anything more to have the same features. As I said, I would welcome a PR that would implement something similar to #1486 for options.
(One can also say that gym>=0.28 signatures don't match Anyway, The consistency of |
🚀 Feature
Hello,
As
gymnasium
implements the very usefuloptions
argument in the.reset()
method, it would be nice to propagate it to theVecEnv.reset()
notably to reset the environment in various states (useful for instance during evaluation phases).Same for the
seed
argument even though an other workaround has been chosen.Would it cause issues if we just add
option=None
to the signatures ?PS: When writing gymnasium environments now, IDE (e.g PyCharm) triggers warnings if the signature of the custom environments don't match with the abstract class, so it encourages defining
options
andseed
arguments.Have a good day,
Thanks,
Motivation
No response
Pitch
No response
Alternatives
No response
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: