Skip to content

Latest commit

 

History

History
68 lines (50 loc) · 2.79 KB

agent.rst

File metadata and controls

68 lines (50 loc) · 2.79 KB

grid2op.Agent

Agent

This page is organized as follow:

Table of Contents

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:

  • the grid2op.Reward.BaseReward that states how good the previous has been
  • the grid2op.Observation.BaseObservation that is a (partial) view on the state of the 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-module to know how to implement your action. Don't hesitate to have a look at the action-module-converter 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

grid2op.Agent