Rules of the Game¶
-
class
grid2op.Rules.
AlwaysLegal
[source]¶ This subclass doesn’t implement any rules regarding the legality of the actions. All actions are legal.
-
__call__
(action, env)[source]¶ All actions being legal, this returns always true. See
BaseRules.__call__()
for a definition of the parameters of this function.
-
-
class
grid2op.Rules.
BaseRules
[source]¶ This class is a base class that determines whether or not an action is legal in certain environment. See the definition of
BaseRules.__call__()
for more information.Basically, this is an empty class with an overload of the __call__ operator that should return
True
orFalse
depending on the legality of the action.In
grid2op.Environment
, only action of the users are checked for legality.-
abstractmethod
__call__
(action, env)[source]¶ As opposed to “ambiguous action”, “illegal action” are not illegal per se. They are legal or not on a certain environment. For example, disconnecting a powerline that has been cut off for _maintenance is illegal. Saying to action to both disconnect a powerline and assign it to bus 2 on it’s origin end is ambiguous, and not tolerated in Grid2Op.
- Parameters
action (
grid2op.Action.Action
) – The action of which the legality is tested.env (
grid2op.Environment.Environment
) – The environment on which the action is performed.
- Returns
res – Whether the action is legal or not
- Return type
bool
-
abstractmethod
-
class
grid2op.Rules.
DefaultRules
[source]¶ This subclass combine both
LookParam
andPreventReconnection
. An action is declared legal if and only if:It doesn’t diconnect / reconnect more power lines than what stated in the actual game _parameters
grid2op.Parameters
It doesn’t attempt to act on more substations that what is stated in the actual game _parameters
grid2op.Parameters
It doesn’t attempt to reconnect a powerline out of service.
-
__call__
(action, env)[source]¶ See
BaseRules.__call__()
for a definition of the _parameters of this function.
-
class
grid2op.Rules.
LookParam
[source]¶ This subclass only check that the number of powerlines reconnected / disconnected by the agent.
This class doesn’t require any environment information. The “env” argument is only used to look for the game rules implemented in
grid2op.Parameters
.See
BaseRules.__call__()
for a definition of the parameters of this function.-
__call__
(action, env)[source]¶ See
BaseRules.__call__()
for a definition of the parameters of this function.
-
-
class
grid2op.Rules.
PreventReconnection
[source]¶ A subclass is used to check that an action will not attempt to reconnect a powerlines disconnected because of an overflow, or to check that 2 actions acting on the same powerline are distant from the right number of timesteps (see
grid2op.Parameters.Parameters.NB_TIMESTEP_LINE_STATUS_REMODIF
) or if two topological modification of the same substation are too close in time (seegrid2op.Parameters.Parameters.NB_TIMESTEP_TOPOLOGY_REMODIF
)-
__call__
(action, env)[source]¶ This function check only that the action doesn’t attempt to reconnect a powerline that has been disconnected due to an overflow.
See
BaseRules.__call__()
for a definition of the parameters of this function.
-
-
class
grid2op.Rules.
RulesChecker
(legalActClass=<class 'grid2op.Rules.AlwaysLegal.AlwaysLegal'>)[source]¶ Class that defin the rules of the game.
-
__call__
(action, env)[source]¶ Says if an action is legal or not.
- Parameters
action (
grid2op.Action.Action
) – The action that need to be testedenv (
grid2op.Environment.Environment
) – The current used environment.
- Returns
res – Assess if the given action is legal or not.
True
: the action is legal,False
otherwise- Return type
bool
-
__init__
(legalActClass=<class 'grid2op.Rules.AlwaysLegal.AlwaysLegal'>)[source]¶ - Parameters
legalActClass (
type
) – The class that will be used to tell if the actions are legal or not. The class must be given, and not an object of this class. It should derived fromBaseRules
.
-
__weakref__
¶ list of weak references to the object (if defined)
-
If you still can’t find what you’re looking for, try in one of the following pages: