pymgrid.modules.RenewableModule#

class pymgrid.modules.RenewableModule(time_series, raise_errors=False, forecaster=None, forecast_horizon=23, forecaster_increase_uncertainty=False, forecaster_relative_noise=False, initial_step=0, final_step=-1, normalized_action_bounds=(0, 1), provided_energy_name='renewable_used')[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 renewable production.

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), where

    • val_c is 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 future

    • n 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 inputs val_c and val_{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.

provided_energy_name: str, default “renewable_used”

Name of the energy provided by this module, to be used in logging.

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.

dynamic_action_space()

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.

log_frame()

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.

serializable_state_attributes()

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 action amount 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

absorption_marginal_cost

Expected marginal cost of energy absorption.

action_space

Action spaces of the module.

current_obs

Current observation.

current_renewable

Current renewable production.

current_step

Current step of the module.

final_step

forecast_horizon

The number of steps until which the module forecasts.

forecaster

View of the forecaster.

forecaster_increase_uncertainty

View of GaussianNoiseForecaster.increase_uncertainty.

forecaster_relative_noise

View of GaussianNoiseForecaster.relative_noise.

is_sink

Whether the module is a sink.

is_source

Whether the module is a source.

log

Module's log as a DataFrame.

logger

The module's logger.

logger_last

The most recent entry in the log.

marginal_cost

Average marginal cost of producing with the module.

max_act

Maximum action that the module allows.

max_consumption

Maximum amount of consumption at the current time step.

max_obs

Maximum observation that the module gives.

max_production

Maximum amount of production at the current time step.

min_act

Minimum action that the module allows.

min_obs

Minimum observation that the module gives.

min_production

Minimum amount of production at the current time step.

module_type

Type of the module.

observation_space

Observation space of the module.

production_marginal_cost

Expected marginal cost of energy production.

state

Current state of the module as a vector.

state_components

Labels of the components of each entry in the module's time series.

time_series

View of the module's time series.

yaml_tag

Tag used for yaml serialization.