Skip to content

Reset an environment with an observation as "init state" #707

Open

Description

@BDonnot

Is your feature request related to a problem? Please describe.

It is not a problem, but something that could have some values, for example for debugging or even to help understand what is going on.

Today, we can achieve similar behviour by doing:

import grid2op
env_name = "l2rpn_case14_sandbox"
env = grid2op.make(env_name, ...)

obs = ... # an observation, from a runner or another environment.
saved_init_state = {"set_bus": obs.topo_vect, "injections": {"load_p": obs.load_p, "load_q": obs.load_q, "prod_p": obs.gen_p, "prod_v": obs.gen_v}}

similar_obs = obs = env.reset(options={"init state": saved_init_state})

This is pretty verbose and does not consider the cooldowns, timestep_overflow of similar environment attributes.

Describe the solution you'd like

Ex. This is how i would like it to be done:

import grid2op
env_name = ...
env = grid2op.make(env_name, ...)

similar_obs = obs = env.reset(options={"init state": obs})

Additional context

The "core" code should be pretty much done as this kind of feature is used for "ForecastedEnv" and for "obs.simulate" for example.
Only "glue code" should be done.

NB This would not keep the random state of the grid.

Activity

  1. DEUCE1957 commented on May 20, 2025

    @DEUCE1957
    Contributor

    One use case for this could be the ability to set the initial SOC of the energy storage systems. Currently this appears to be 50%, and does not seem to be set in the chronics. Using an action would not work for "init state" in that case, since we might want to set the initial SOC to e.g. 80% which might violate ramping constraints or cause the powerflow to diverge on the first time step (since its an action rather than a state). That would be a non-debug use case though.
    Edit: Can make this a seperate enhancement issue if it seems more appropriate

  2. BDonnot commented on May 20, 2025

    @BDonnot
    CollaboratorAuthor

    Hello,

    The initial state of charge of all batteries can be changed in the parameters of the environment directly. There is a parameters for that.

    And you are correct, this is not possible today to initialize them in another way. An action will not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions