Skip to content

Commit

Permalink
Add 'data' property to unit_commitment benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
giuluck committed Mar 5, 2024
1 parent 4ef8da3 commit 37beacd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 37 deletions.
14 changes: 10 additions & 4 deletions benchmarks/unit_commitment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import joblib
import numpy as np
import pandas as pd
from descriptors import cachedproperty
from powerplantsim import Plant
from powerplantsim.plant import RecourseAction
from powerplantsim.plant.execution import SimulationOutput
Expand Down Expand Up @@ -94,9 +95,7 @@ def _variance(self, index: pd.Series, gp: GaussianProcessRegressor) -> np.ndarra

def _plant(self, variance: bool) -> Plant:
# retrieve data and gaussian process regressor
with importlib.resources.path('benchmarks.unit_commitment', 'data.csv') as file:
df = pd.read_csv(file).iloc[(self.day - 1) * 24: self.day * 24]
df['datetime'] = pd.to_datetime(df['datetime'])
df = self.data
with importlib.resources.path('benchmarks.unit_commitment', 'gp.joblib') as file:
gp = joblib.load(file)
# handle plant
Expand Down Expand Up @@ -184,6 +183,13 @@ def prediction_error(self) -> float:
def uncertainty_error(self) -> float:
return self.configuration['uncertainty_error']

@property
@cachedproperty
def plant(self) -> Plant:
return self._plant(variance=False)

@cachedproperty
def data(self) -> pd.DataFrame:
with importlib.resources.path('benchmarks.unit_commitment', 'data.csv') as file:
df = pd.read_csv(file).iloc[(self.day - 1) * 24: self.day * 24]
df['datetime'] = pd.to_datetime(df['datetime'])
return df
33 changes: 0 additions & 33 deletions setup.py

This file was deleted.

0 comments on commit 37beacd

Please sign in to comment.