Awattar Price changed to more precise value; if SoC=0 discharge =1 forced. Exp Avg for siple Price Forecast

This commit is contained in:
Andreas 2024-12-25 19:12:38 +01:00
parent cc24904703
commit 56aa0ac2f5
2 changed files with 27 additions and 11 deletions

View File

@ -432,9 +432,25 @@ class optimization_problem:
discharge_hours_bin, eautocharge_hours_index, washingstart_int
)
individual[:] = adjusted_individual # Aktualisiere das ursprüngliche individual
individual[:] = adjusted_individual
# Berechnung weiterer Metriken
# New check: Activate discharge when battery SoC is 0
battery_soc_per_hour = np.array(
o.get("Battery_SoC_pro_Stunde", [])
) # Example key for battery SoC
if battery_soc_per_hour is not None:
# Find hours where battery SoC is 0
zero_soc_mask = battery_soc_per_hour == 0
discharge_hours_bin[zero_soc_mask] = 1 # Activate discharge for these hours
# Merge the updated discharge_hours_bin back into the individual
adjusted_individual = self.merge_individual(
discharge_hours_bin, eautocharge_hours_index, washingstart_int
)
individual[:] = adjusted_individual
# More metrics
individual.extra_data = ( # type: ignore[attr-defined]
o["Gesamtbilanz_Euro"],
o["Gesamt_Verluste"],

View File

@ -98,7 +98,7 @@ class HourlyElectricityPriceForecast:
# Extract the price from 00:00 of the previous day
previous_day_prices = [
entry["marketpriceEurocentPerKWh"] # + self.charges
entry["marketprice"] # + self.charges
for entry in self.prices
if previous_day_str in entry["end"]
]
@ -106,19 +106,16 @@ class HourlyElectricityPriceForecast:
# Extract all prices for the specified date
date_prices = [
entry["marketpriceEurocentPerKWh"] # + self.charges
entry["marketprice"] # + self.charges
for entry in self.prices
if date_str in entry["end"]
]
# print(f"getPrice: {len(date_prices)}")
# Add the last price of the previous day at the start of the list
if len(date_prices) == 23:
date_prices.insert(0, last_price_of_previous_day)
# print(np.array(date_prices) / (1000.0 * 100.0))
# print("PRICE:")
# print(np.array(date_prices) / (1000.0 * 100.0) + self.charges)
return np.array(date_prices) / (1000.0 * 100.0) + self.charges
return np.array(date_prices) / (1000.0 * 1000.0) + self.charges
def get_average_price_last_7_days(self, end_date_str: Optional[str] = None) -> np.ndarray:
"""Calculate the hourly average electricity price for the last 7 days.
@ -170,8 +167,11 @@ class HourlyElectricityPriceForecast:
price_matrix = price_data.reshape(-1, 24)
# Calculate the average price for each hour across the 7 days
average_prices = np.mean(price_matrix, axis=0)
# print("AVG:", average_prices)
average_prices = np.average(
price_matrix,
axis=0,
weights=np.array([1, 2, 4, 8, 16, 32, 64]) / np.sum(np.array([1, 2, 4, 8, 16, 32, 64])),
)
return average_prices
def get_price_for_daterange(