smartgrid.util.available_energy.RealisticEnergyGenerator¶
- class smartgrid.util.available_energy.RealisticEnergyGenerator(data)[source]¶
Bases:
EnergyGenerator
A realistic generator that generates energy based on real-world data.
The
data
parameter should be a NumPy ndarray giving the ratio of energy for each step, with respect to the maximum amount of energy needed by the agents.For example,
[0.3, 0.8, 0.7]
means that at the 1st step, we should make 30% of the agents’ maximum need available ; 80% at the 2nd step, and 70% at the 3rd step.Methods
__init__
(data)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.
Attributes
Data representing how much of the maximum need should be available each step.
- available_energy_bounds(current_need: int, current_step: int, min_need: int, max_need: 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 ofAgent
s. This also allows scaling the generated amount to[0,1]
. For example, assuming the bounds are[0, 10_000]
, a generated amount of8_000
can be scaled to0.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 themax_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.
- generate_available_energy(current_need: int, current_step: int, min_need: int, max_need: 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 betweenmin_need
andmax_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 theObservation
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.