smartgrid.util.available_energy.EnergyGenerator

class smartgrid.util.available_energy.EnergyGenerator[source]

Bases: ABC

An EnergyGenerator is responsible for the production of energy each step.

__init__()[source]

Methods

__init__()

available_energy_bounds(current_need, ...)

Determine the possible min and max bounds for the energy generation.

generate_available_energy(current_need, ...)

Generate an amount of available energy during a single time step.

set_random_generator(random_generator)

_random_generator: Generator

The pseudo-random number generator (PRNG).

EnergyGenerators that are purely deterministic can safely ignore this attribute; those that rely on random generation must use exclusively this attribute, to ensure reproducibility.

To set this attribute (and thus, to set the random seed), use the set_random_generator() method. It is initialized by default, so the EnergyGenerator can be used as-is without needing to configure.

abstract available_energy_bounds(current_need: int, current_step: int, min_need: int, max_need: int) Tuple[int, int][source]

Determine the possible min and max bounds for the energy generation.

This method is used to provide a range (a domain), which is important for specifying the Observation space of Agents. This also allows scaling the generated amount to [0,1]. For example, assuming the bounds are [0, 10_000], a generated amount of 8_000 can be scaled to 0.8, which is easier to use by learning algorithms.

Parameters:
  • current_need – The total energy needed by all agents at the current step.

  • current_step – The current time step.

  • min_need – The minimum energy needed by all agents, for all time steps. This value is used for the same objective as max_need, but it does not need to be accurate, e.g., 0 can be used as a safe default.

  • max_need – The maximum energy needed by all agents, for all time steps. This value can be used to accurately determine the bounds for all time steps, instead of a single time step. The need_at_step should always be lower or equal to the max_need.

Returns:

The min and max bounds of the energy generator, i.e., the minimum and maximum possible values that generate_available_energy() may return. It is important that these bounds are coherent with the method, otherwise scaling may not work properly, and Agents may receive incorrect observations.

abstract generate_available_energy(current_need: int, current_step: int, min_need: int, max_need: int) int[source]

Generate an amount of available energy during a single time step.

EnergyGenerators can use any method to compute this amount, e.g., returning a fixed value, drawing from a distribution, using an array of realistic data for each time step, etc.

Parameters:
  • current_need – The total energy needed by all agents at the current step. This value can be used to effectively scale the generator to the current agent population. This value can also be ignored by the generator. The current_need should be comprised between min_need and max_need.

  • current_step – The current time step. Mostly used by “realistic” or data-based generators that need to know the current date/hour.

  • min_need – The minimum energy needed by all agents, for all time steps. It does not need to be exact, and only serve as a lower bound, e.g., 0 is a perfectly sane value. However, the more accurate this value is, the more accurate the scaling of the Observation space will be.

  • max_need – The maximum energy needed by all agents, for all time steps. It does not need to be exact, and only serves as an upper bound, e.g., any sufficiently high value can be used. However, the more accurate this value is, the more accurate the scaling of the Observation space will be.

Returns:

The amount of available energy, a value in \(\mathbb{R}\). For example, returning 40_000 means that 40,000Wh are available for the current time step.