smartgrid.rewards.reward_collection.RewardCollection

class smartgrid.rewards.reward_collection.RewardCollection(rewards: List[Reward])[source]

Bases: object

The RewardCollection holds all desired reward functions, and computes the rewards.

This class allows for multi-objective reinforcement learning, by holding several reward functions, and returning dicts of rewards (names -> values), instead of using a single reward function.

The multiple reward functions can be aggregated (scalarized) to adapt to single-objective learning algorithms, by using a RewardAggregator wrapper over the environment.

__init__(rewards: List[Reward])[source]

Create a RewardCollection based on a list of “reward functions”.

Parameters:

rewards – The list of “reward functions” (actually instances of the Reward class). This list must contain at least 1 element.

Methods

__init__(rewards)

Create a RewardCollection based on a list of "reward functions".

compute(world, agent)

Compute the list of Reward for the Agent.

reset()

Reset the reward functions.

compute(world: World, agent: Agent) Dict[str, float][source]

Compute the list of Reward for the Agent.

Parameters:
  • world – reference on the world for global information.

  • agent – reference on the agent for local information.

Returns:

A dictionary mapping the rewards’ name to their value, for each reward function in this Reward Collection.

reset()[source]

Reset the reward functions.