Agent

This page is organized as follow:

Objectives

In this RL framework, an Agent is an entity that acts on the Environment (modeled in grid2op as an object of class Environment). In grid2op such entity is modeled by the BaseAgent class. It can alternatively be named “bot” or “controller” in other literature.

This module presents a few possible BaseAgent that can serve either as baseline, or as example on how to implement such agents. NB Stronger baselines are defined in an another repository.

To perform their actions, agent receive two main signals from the grid2op.Environment:

Both these signals can be use to determine what is the best action to perform on the grid. This is actually the main objective of an BaseAgent, and this is done in the BaseAgent.act() method.

To get started coding your agent we encourage you to read the description of the Action to know how to implement your action. Don’t hesitate to have a look at the Easier actions manipulation for an easier / higher level action manipulation.

Once you know how to manipulate a powergrid in case of the grid2op framework, you can easily implement an agent following this example

import grid2op
from grid2op.Agent import BaseAgent

class MyCustomAgent(BaseAgent):
    def __init__(self, action_space, something_else, and_another_something):
        # define here the constructor of your agent
        # here we say our agent needs "something_else" and "and_another_something"
        # to be built just to demonstrate it does not cause any problem to extend the
        # construction of the base class BaseAgent that only takes "action_space" as a constructor
        BaseAgent.__init__(self, action_space)
        self.something_else = something_else
        self.and_another_something = and_another_something

    def act(obs, reward, done=False):
        # this is the only method you need to implement
        # it takes an observation obs (and a reward and a flag)
        # and should return a valid action
        dictionary_describing_the_action = {}  # this can be anything you want that grid2op understands
        my_action = env.action_space(dictionary_describing_the_action)
        return my_action

Detailed Documentation by class

If you still can’t find what you’re looking for, try in one of the following pages:

Still trouble finding the information ? Do not hesitate to send a github issue about the documentation at this link: Documentation issue template

Copyright © Grid2Op a Series of LF Projects, LLC For website terms of use, trademark policy and other project policies please see https://lfprojects.org.