in src/energy_storage_system/envs.py [0:0]
def __init__(self, env_config: Dict):
# Capacity: Min energy storage level (MWh)
self.ENERGY_MIN = 0.0
# Capacity: Max energy storage level (MWh), battery capacity
self.ENERGY_MAX = 80.0
# Starting capacity
self.STARTING_ENERGY = 40.0
# Power rating: Max charge rate (MW)
self.MAX_CHARGE_PWR = 4.0
# Power rating: Max discharge rate (MW)
self.MAX_DISCHARGE_PWR = 2.0
# wear and tear ($/MW)
self.BETA = 1.0
# every step is 1 hour
self.DURATION = 1
# efficiency constant
self.EFF = 1.0
# Historical price horizon for states
self.HIST_PRICE_HORIZON = 5
# Each trajectories is one week (168h)
self.MAX_STEPS_PER_EPISODE = 168
self.LOCAL = None
self.FILEPATH = None
# Default environment configuration. which will be added to env_config
config_defaults = {
"ENERGY_MIN": 0.0,
"ENERGY_MAX": 80.0,
"STARTING_ENERGY": 40.0,
"MAX_CHARGE_PWR": 4.0,
"MAX_DISCHARGE_PWR": 2.0,
"BETA": 1.0,
"DURATION": 1,
"EFF": 1.0,
"HIST_PRICE_HORIZON": 5,
"MAX_STEPS_PER_EPISODE": 168,
"FILEPATH": DATA,
"LOCAL": True,
}
# Add new environment config passed in as params
for key, default_val in config_defaults.items():
# Get value for key, if none then return 'val'. env_config take priority
new_val = env_config.get(
key, default_val
) # Override defaults with constructor parameters
self.__dict__[key] = new_val
if key not in env_config:
env_config[key] = new_val
# Load energy price ($/MWh)
if self.LOCAL:
self.df_price = self._get_data(self.FILEPATH)
else:
self.df_price = self._get_data_s3()
self.price_length = self.df_price.shape[0]
# TODO Create features
# self.df_price["time"] = self.df_price["time"]
# self.df_price["hour"] = self.df_price.time.dt.hour
# self.df_price["week"] = self.df_price.time.dt.week
# self.df_price["sin_time"] = np.sin(2 * PI * self.df_price.hour / 24)
# self.df_price["cos_time"] = np.cos(2 * PI * self.df_price.hour / 24)
# self.df_price["sin_week"] = np.sin(2 * PI * self.df_price.week / 52)
# self.df_price["cos_week"] = np.cos(2 * PI * self.df_price.week / 52)
# ACTION/OBSERVATION space, this will change according hist horizon
self.action_space = Discrete(3)
self.observation_space = Box(
-np.inf, np.inf, shape=(3 + self.HIST_PRICE_HORIZON,), dtype=np.float64
)
self.initialized = False