Spaces:
Sleeping
Sleeping
Daniel Varga commited on
Commit ·
a13327d
1
Parent(s): e8def5c
supplier
Browse files- v2/architecture.py +7 -2
- v2/supplier.py +9 -2
v2/architecture.py
CHANGED
|
@@ -106,7 +106,8 @@ class Decider:
|
|
| 106 |
def decide(self, prod_pred, cons_pred, battery_model):
|
| 107 |
# assert len(prod_pred) == len(cons_pred) == self.input_window_size
|
| 108 |
self.random_seed += 1
|
| 109 |
-
self.random_seed %= 3 # dummy rotates between
|
|
|
|
| 110 |
return self.random_seed
|
| 111 |
# dummy decider always says DISCHARGE:
|
| 112 |
# return pd.Series([Decision.DISCHARGE] * self.output_window_size, dtype=int)
|
|
@@ -206,7 +207,6 @@ def simulator(battery_model, supplier, prod_cons, prod_predictor, cons_predictor
|
|
| 206 |
else:
|
| 207 |
consumption_from_network_to_bess = 0
|
| 208 |
|
| 209 |
-
supplier.(consumption_from_network)
|
| 210 |
soc_series.append(battery_model.soc)
|
| 211 |
consumption_from_solar_series.append(consumption_from_solar)
|
| 212 |
consumption_from_network_series.append(consumption_from_network)
|
|
@@ -220,6 +220,11 @@ def simulator(battery_model, supplier, prod_cons, prod_predictor, cons_predictor
|
|
| 220 |
consumption_from_bess_series = np.array(consumption_from_bess_series)
|
| 221 |
discarded_production_series = np.array(discarded_production_series)
|
| 222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 223 |
results = pd.DataFrame({'soc_series': soc_series, 'consumption_from_solar': consumption_from_solar_series,
|
| 224 |
'consumption_from_network': consumption_from_network_series,
|
| 225 |
'consumption_from_bess': consumption_from_bess_series,
|
|
|
|
| 106 |
def decide(self, prod_pred, cons_pred, battery_model):
|
| 107 |
# assert len(prod_pred) == len(cons_pred) == self.input_window_size
|
| 108 |
self.random_seed += 1
|
| 109 |
+
self.random_seed %= 3 # dummy rotates between Decisions
|
| 110 |
+
self.random_seed = Decision.PASSIVE
|
| 111 |
return self.random_seed
|
| 112 |
# dummy decider always says DISCHARGE:
|
| 113 |
# return pd.Series([Decision.DISCHARGE] * self.output_window_size, dtype=int)
|
|
|
|
| 207 |
else:
|
| 208 |
consumption_from_network_to_bess = 0
|
| 209 |
|
|
|
|
| 210 |
soc_series.append(battery_model.soc)
|
| 211 |
consumption_from_solar_series.append(consumption_from_solar)
|
| 212 |
consumption_from_network_series.append(consumption_from_network)
|
|
|
|
| 220 |
consumption_from_bess_series = np.array(consumption_from_bess_series)
|
| 221 |
discarded_production_series = np.array(discarded_production_series)
|
| 222 |
|
| 223 |
+
total_charge, consumption_charge_series, demand_charges = supplier.fee(
|
| 224 |
+
pd.Series(consumption_from_network_series, index=prod_cons.index),
|
| 225 |
+
provide_detail=True)
|
| 226 |
+
print(f"All in all we have paid {total_charge} to network.")
|
| 227 |
+
|
| 228 |
results = pd.DataFrame({'soc_series': soc_series, 'consumption_from_solar': consumption_from_solar_series,
|
| 229 |
'consumption_from_network': consumption_from_network_series,
|
| 230 |
'consumption_from_bess': consumption_from_bess_series,
|
v2/supplier.py
CHANGED
|
@@ -55,7 +55,9 @@ class Supplier:
|
|
| 55 |
|
| 56 |
# demand_series is pandas series indexed by time.
|
| 57 |
# during each time step demand [kW] is assumed to be constant.
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
prices = [self.price(date) for date in demand_series.index]
|
| 60 |
prices_series = pd.Series(data=prices, index=demand_series.index)
|
| 61 |
# prices are HUF/kWh, demand is kW. note the missing h.
|
|
@@ -71,7 +73,12 @@ class Supplier:
|
|
| 71 |
fifteen_minute_peaks = demand_series.resample('15T').max()
|
| 72 |
demand_charges = [self.demand_charge(demand) for demand in fifteen_minute_peaks]
|
| 73 |
total_demand_charge = sum(demand_charges)
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
|
| 77 |
class TestSupplier(unittest.TestCase):
|
|
|
|
| 55 |
|
| 56 |
# demand_series is pandas series indexed by time.
|
| 57 |
# during each time step demand [kW] is assumed to be constant.
|
| 58 |
+
#
|
| 59 |
+
# TODO the provide_detail returned value types are inconsistent and confusing.
|
| 60 |
+
def fee(self, demand_series, provide_detail=False):
|
| 61 |
prices = [self.price(date) for date in demand_series.index]
|
| 62 |
prices_series = pd.Series(data=prices, index=demand_series.index)
|
| 63 |
# prices are HUF/kWh, demand is kW. note the missing h.
|
|
|
|
| 73 |
fifteen_minute_peaks = demand_series.resample('15T').max()
|
| 74 |
demand_charges = [self.demand_charge(demand) for demand in fifteen_minute_peaks]
|
| 75 |
total_demand_charge = sum(demand_charges)
|
| 76 |
+
total_charge = consumption_charge + total_demand_charge
|
| 77 |
+
if provide_detail:
|
| 78 |
+
consumption_charge_series = demand_series * prices_series * step_in_hour
|
| 79 |
+
return total_charge, consumption_charge_series, demand_charges
|
| 80 |
+
else:
|
| 81 |
+
return total_charge
|
| 82 |
|
| 83 |
|
| 84 |
class TestSupplier(unittest.TestCase):
|