grid2op.Converter
This page is organized as follow:
Table of Contents
In this module of grid2op, the "converters" are defined.
A converter is a specific class of grid2op.Action.ActionSpace
(ie of BaseAction Space) that allows the agent to manipulate this action to have a different representation of it.
For example, suppose we are dealing with grid2op.Action.TopologyAndDispatchAction
(only manipulating the graph of the powergrid). This is a discrete "action space". Often, it's custom to deal with such action space by enumerating all actions, and then assign to all valid actions a unique ID.
This can be done easily with the IdToAct
class.
More concretely, the diagram of an agent is:
- receive an observation (in a form of an object of class
grid2op.Observation.BaseObservation
) - implement the
grid2op.Agent.BaseAgent.act
taking as input angrid2op.Observation.BaseObservation
and returning angrid2op.Action.BaseAction
- this
grid2op.Action.BaseAction
is then digested by the environment
Introducing some converters lead to the following:
- receive an observation (
grid2op.Observation.BaseObservation
) - the transformer automatically (using
Converter.convert_obs
) to a transformed observation - implement the function
grid2op.Agent.AgentWithConverter.my_act
that takes as input a transformed observation and returns an encoded action - the transformer automatically transforms back the encoded action into a proper
grid2op.Action.BaseAction
- this
grid2op.Action.BaseAction
is then digested by the environment
This simple mechanism allows people to focus on iii) above (typically implemented with artificial neural networks) without having to worry each time about the complex representations of actions and observations.
More details and a concrete example is given in the documentation of the class grid2op.Agent.AgentWithConverter
.
Some examples of converters are given in IdToAct
and ToVect
.
grid2op.Converter