pymgrid.modules.LoadModule#
- class pymgrid.modules.LoadModule(time_series, forecaster=None, forecast_horizon=23, forecaster_increase_uncertainty=False, forecaster_relative_noise=False, initial_step=0, final_step=-1, normalized_action_bounds=(0, 1), raise_errors=False)[source]#
A renewable energy module.
The classic examples of renewables are photovoltaics (PV) and wind turbines.
Parameters#
- time_seriesarray-like, shape (n_steps, )
Time series of load demand.
- forecastercallable, float, “oracle”, or None, default None.
Function that gives a forecast n-steps ahead.
If
callable, must take as arguments(val_c: float, val_{c+n}: float, n: int), whereval_cis the current value in the time series:self.time_series[self.current_step]val_{c+n}is the value in the time series n steps in the futuren is the number of steps in the future at which we are forecasting.
The output
forecast = forecaster(val_c, val_{c+n}, n)must have the same sign as the inputsval_candval_{c+n}.If
float, serves as a standard deviation for a mean-zero gaussian noise function that is added to the true value.If
"oracle", gives a perfect forecast.If
None, no forecast.
- forecast_horizonint.
Number of steps in the future to forecast. If forecaster is None, ignored and 0 is returned.
- forecaster_increase_uncertaintybool, default False
Whether to increase uncertainty for farther-out dates if using a GaussianNoiseForecaster. Ignored otherwise.
- normalized_action_boundstuple of int or float, default (0, 1).
Bounds of normalized actions. Change to (-1, 1) for e.g. an RL policy with a Tanh output activation.
- raise_errorsbool, default False
Whether to raise errors if bounds are exceeded in an action. If False, actions are clipped to the limit possible.
Methods
as_sink(energy_excess)Act as an energy sink to the microgrid.
as_source(energy_demand)Act as an energy source to the microgrid.
dump([stream])Save a module to a YAML buffer.
An action space bounded by the current step's maximum consumption and production.
forecast()Forecast the module's time series from the current state.
from_normalized(value[, act, obs])Un-normalize an action or observation.
load(stream)Load a module from yaml representation.
log_dict()Module's log as a dict.
Module's log as a DataFrame.
reset()Reset the module to step zero and flush the log.
sample_action([strict_bound])Sample an action from the module's action space.
Return the attributes of the module that represent the module's current state for serialization.
serialize(dumper_stream)Serialize module.
set_forecaster(forecaster[, ...])Set the forecaster for this module.
state_dict([normalized])Current state of the module as a dictionary.
step(action[, normalized])Take one step in the module, attempting to draw or send
actionamount of energy.to_normalized(value[, act, obs])Normalize an action or observation.
update(external_energy_change[, as_source, ...])Update the state of the module given an energy request.
verbose_eq(other[, indent])Attributes
Expected marginal cost of energy absorption.
Action spaces of the module.
Current load.
Current observation.
Current step of the module.
The number of steps until which the module forecasts.
View of the forecaster.
Whether the module is a sink.
Whether the module is a source.
Module's log as a DataFrame.
The module's logger.
The most recent entry in the log.
Average marginal cost of producing with the module.
Maximum action that the module allows.
Maximum amount of consumption at the current time step.
Maximum observation that the module gives.
Maximum amount of production at the current time step.
Minimum action that the module allows.
Minimum observation that the module gives.
Minimum amount of production at the current time step.
Type of the module.
Observation space of the module.
Expected marginal cost of energy production.
Current state of the module as a vector.
Labels of the components of each entry in the module's time series.
View of the module's time series.
Tag used for yaml serialization.