mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-12-14 07:46:18 +00:00
Verluste stündlich / gesamt werden ausgegeben und mit minimiert
Start ab Stunde X jetzt möglich
This commit is contained in:
99
test.py
99
test.py
@@ -19,7 +19,7 @@ import random
|
||||
import os
|
||||
|
||||
|
||||
|
||||
start_hour = 11
|
||||
prediction_hours = 24
|
||||
date = (datetime.now().date() + timedelta(hours = prediction_hours)).strftime("%Y-%m-%d")
|
||||
date_now = datetime.now().strftime("%Y-%m-%d")
|
||||
@@ -36,8 +36,9 @@ discharge_array = np.full(prediction_hours,1) #np.array([1, 0, 1, 0, 1, 1, 1, 1,
|
||||
|
||||
laden_moeglich = np.full(prediction_hours,1) # np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0])
|
||||
#np.full(prediction_hours,1)
|
||||
eauto = EAuto(soc=10, capacity = 60000, power_charge = 7000, load_allowed = laden_moeglich)
|
||||
min_soc_eauto = 10
|
||||
eauto = PVAkku(kapazitaet_wh=60000, hours=prediction_hours, lade_effizienz=0.95, entlade_effizienz=1.0, max_ladeleistung_w=10000 ,start_soc_prozent=10)
|
||||
eauto.set_charge_per_hour(laden_moeglich)
|
||||
min_soc_eauto = 80
|
||||
hohe_strafe = 10.0
|
||||
|
||||
|
||||
@@ -82,24 +83,25 @@ gesamtlast.hinzufuegen("Heatpump", leistung_wp)
|
||||
|
||||
# EAuto
|
||||
######################
|
||||
leistung_eauto = eauto.get_stuendliche_last()
|
||||
soc_eauto = eauto.get_stuendlicher_soc()
|
||||
gesamtlast.hinzufuegen("eauto", leistung_eauto)
|
||||
# leistung_eauto = eauto.get_stuendliche_last()
|
||||
# soc_eauto = eauto.get_stuendlicher_soc()
|
||||
# gesamtlast.hinzufuegen("eauto", leistung_eauto)
|
||||
|
||||
# print(gesamtlast.gesamtlast_berechnen())
|
||||
|
||||
# EMS / Stromzähler Bilanz
|
||||
ems = EnergieManagementSystem(akku, gesamtlast.gesamtlast_berechnen(), pv_forecast, specific_date_prices, einspeiseverguetung_cent_pro_wh)
|
||||
#akku=None, pv_prognose_wh=None, strompreis_cent_pro_wh=None, einspeiseverguetung_cent_pro_wh=None, eauto=None, gesamtlast=None
|
||||
|
||||
ems = EnergieManagementSystem(akku=akku, gesamtlast = gesamtlast, pv_prognose_wh=pv_forecast, strompreis_cent_pro_wh=specific_date_prices, einspeiseverguetung_cent_pro_wh=einspeiseverguetung_cent_pro_wh, eauto=eauto)
|
||||
|
||||
|
||||
o = ems.simuliere(0)#ems.simuliere_ab_jetzt()
|
||||
o = ems.simuliere(start_hour)#ems.simuliere_ab_jetzt()
|
||||
#pprint(o)
|
||||
#pprint(o["Gesamtbilanz_Euro"])
|
||||
|
||||
#visualisiere_ergebnisse(gesamtlast,leistung_haushalt,leistung_wp, pv_forecast, specific_date_prices, o, soc_eauto)
|
||||
#visualisiere_ergebnisse(gesamtlast, pv_forecast, specific_date_prices, o,discharge_array,laden_moeglich, temperature_forecast, start_hour, prediction_hours)
|
||||
|
||||
|
||||
#sys.exit()
|
||||
|
||||
# Optimierung
|
||||
|
||||
@@ -111,17 +113,18 @@ def evaluate_inner(individual):
|
||||
#print(discharge_hours_bin)
|
||||
#print(len(eautocharge_hours_float))
|
||||
ems.reset()
|
||||
eauto.reset()
|
||||
#eauto.reset()
|
||||
ems.set_akku_discharge_hours(discharge_hours_bin)
|
||||
|
||||
eauto.set_laden_moeglich(eautocharge_hours_float)
|
||||
eauto.berechne_ladevorgang()
|
||||
leistung_eauto = eauto.get_stuendliche_last()
|
||||
gesamtlast.hinzufuegen("eauto", leistung_eauto)
|
||||
ems.set_eauto_charge_hours(eautocharge_hours_float)
|
||||
|
||||
ems.set_gesamtlast(gesamtlast.gesamtlast_berechnen())
|
||||
#eauto.set_laden_moeglich(eautocharge_hours_float)
|
||||
#eauto.berechne_ladevorgang()
|
||||
#leistung_eauto = eauto.get_stuendliche_last()
|
||||
#gesamtlast.hinzufuegen("eauto", leistung_eauto)
|
||||
|
||||
o = ems.simuliere(0)
|
||||
#ems.set_gesamtlast(gesamtlast.gesamtlast_berechnen())
|
||||
|
||||
o = ems.simuliere(start_hour)
|
||||
return o, eauto
|
||||
|
||||
# Fitness-Funktion (muss Ihre EnergieManagementSystem-Logik integrieren)
|
||||
@@ -130,12 +133,13 @@ def evaluate(individual):
|
||||
gesamtbilanz = o["Gesamtbilanz_Euro"]
|
||||
|
||||
# Überprüfung, ob der Mindest-SoC erreicht wird
|
||||
final_soc = eauto.get_stuendlicher_soc()[-1] # Nimmt den SoC am Ende des Optimierungszeitraums
|
||||
final_soc = eauto.ladezustand_in_prozent() # Nimmt den SoC am Ende des Optimierungszeitraums
|
||||
strafe = 0.0
|
||||
#if final_soc < min_soc_eauto:
|
||||
# Fügt eine Strafe hinzu, wenn der Mindest-SoC nicht erreicht wird
|
||||
strafe = max(0,(min_soc_eauto - final_soc) * hohe_strafe ) # `hohe_strafe` ist ein vorher festgelegter Strafwert
|
||||
gesamtbilanz += strafe
|
||||
gesamtbilanz += o["Gesamt_Verluste"]/1000.0
|
||||
return (gesamtbilanz,)
|
||||
|
||||
|
||||
@@ -229,65 +233,14 @@ print("Beste Lösung:", best_solution)
|
||||
#ems.set_akku_discharge_hours(best_solution)
|
||||
o,eauto = evaluate_inner(best_solution)
|
||||
|
||||
soc_eauto = eauto.get_stuendlicher_soc()
|
||||
print(soc_eauto)
|
||||
pprint(o)
|
||||
pprint(eauto.get_stuendlicher_soc())
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# # Werkzeug-Setup
|
||||
# creator.create("FitnessMin", base.Fitness, weights=(-1.0,))
|
||||
# creator.create("Individual", list, fitness=creator.FitnessMin)
|
||||
|
||||
# toolbox = base.Toolbox()
|
||||
|
||||
|
||||
|
||||
|
||||
# toolbox.register("attr_bool", random.randint, 0, 1)
|
||||
# toolbox.register("attr_float", random.uniform, 0.0, 1.0)
|
||||
# toolbox.register("individual", tools.initCycle, creator.Individual, (toolbox.attr_bool,toolbox.attr_float), n=prediction_hours)
|
||||
|
||||
# start_individual = toolbox.individual()
|
||||
# start_individual[:] = start_solution
|
||||
|
||||
# toolbox.register("population", tools.initRepeat, list, toolbox.individual)
|
||||
|
||||
# toolbox.register("evaluate", evaluate)
|
||||
# toolbox.register("mate", tools.cxTwoPoint)
|
||||
# toolbox.register("mutate", tools.mutFlipBit, indpb=0.05)
|
||||
# toolbox.register("select", tools.selTournament, tournsize=3)
|
||||
|
||||
# # Genetischer Algorithmus
|
||||
# def optimize():
|
||||
# population = toolbox.population(n=1000)
|
||||
# population[0] = start_individual
|
||||
# hof = tools.HallOfFame(1)
|
||||
|
||||
# stats = tools.Statistics(lambda ind: ind.fitness.values)
|
||||
# stats.register("avg", np.mean)
|
||||
# stats.register("min", np.min)
|
||||
# stats.register("max", np.max)
|
||||
|
||||
# algorithms.eaMuPlusLambda(population, toolbox, 100, 200, cxpb=0.5, mutpb=0.2, ngen=1000, stats=stats, halloffame=hof, verbose=True)
|
||||
# #algorithms.eaSimple(population, toolbox, cxpb=0.2, mutpb=0.2, ngen=1000, stats=stats, halloffame=hof, verbose=True)
|
||||
# return hof[0]
|
||||
|
||||
# best_solution = optimize()
|
||||
# print("Beste Lösung:", best_solution)
|
||||
|
||||
# #ems.set_akku_discharge_hours(best_solution)
|
||||
# o,eauto = evaluate_inner(best_solution)
|
||||
|
||||
# soc_eauto = eauto.get_stuendlicher_soc()
|
||||
# print(soc_eauto)
|
||||
# pprint(o)
|
||||
# pprint(eauto.get_stuendlicher_soc())
|
||||
|
||||
visualisiere_ergebnisse(gesamtlast,leistung_haushalt,leistung_wp, pv_forecast, specific_date_prices, o,soc_eauto,best_solution[0::2],best_solution[1::2] , temperature_forecast)
|
||||
|
||||
#visualisiere_ergebnisse(gesamtlast,leistung_haushalt,leistung_wp, pv_forecast, specific_date_prices, o,soc_eauto,best_solution[0::2],best_solution[1::2] , temperature_forecast)
|
||||
visualisiere_ergebnisse(gesamtlast, pv_forecast, specific_date_prices, o,best_solution[0::2],best_solution[1::2] , temperature_forecast, start_hour, prediction_hours)
|
||||
|
||||
|
||||
# for data in forecast.get_forecast_data():
|
||||
|
||||
Reference in New Issue
Block a user