sustaingym.algorithms.base
#
Module Contents#
Classes#
Base abstract class for running an agent in an environment. |
|
Wrapper for RLLib RL agent. |
|
Random action. |
- class sustaingym.algorithms.base.BaseAlgorithm(env: gymnasium.Env | pettingzoo.ParallelEnv, multiagent: bool = False)[source]#
Base abstract class for running an agent in an environment.
Subclasses are expected to implement the
get_action()
method.- Parameters:
env (gymnasium.Env | pettingzoo.ParallelEnv) – environment to run algorithm on
multiagent (bool) – whether the environment is multiagent
- abstract get_action(observation: dict[str, Any]) numpy.ndarray | dict[str, numpy.ndarray] [source]#
Returns an action based on gym observations.
- Parameters:
observation (dict[str, Any]) –
- Return type:
numpy.ndarray | dict[str, numpy.ndarray]
- run(seeds: collections.abc.Sequence[int] | int) pandas.DataFrame [source]#
Runs the scheduling algorithm and returns the resulting rewards.
Runs the scheduling algorithm for the date period of event generation and returns the resulting reward.
- Parameters:
seeds (collections.abc.Sequence[int] | int) – if a list, on each episode run,
self.env
is reset using the seed. If an integer, a list is created usingrange(seeds)
and used to reset the env instead.- Returns:
results – DataFrame of length len(seeds) or seeds containing reward info
column dtype seed int return float64
- Return type:
pandas.DataFrame
- class sustaingym.algorithms.base.RLLibAlgorithm(env: gymnasium.Env | pettingzoo.ParallelEnv, algo: ray.rllib.algorithms.algorithm.Algorithm, multiagent: bool = False)[source]#
Bases:
BaseAlgorithm
Wrapper for RLLib RL agent.
- Parameters:
env (gymnasium.Env | pettingzoo.ParallelEnv) –
algo (ray.rllib.algorithms.algorithm.Algorithm) –
multiagent (bool) –
- class sustaingym.algorithms.base.RandomAlgorithm(env: gymnasium.Env | pettingzoo.ParallelEnv, multiagent: bool = False)[source]#
Bases:
BaseAlgorithm
Random action.
- Parameters:
env (gymnasium.Env | pettingzoo.ParallelEnv) –
multiagent (bool) –