renamed haushaltsgeräte to home appliance (#196)

* * rename Haushaltsgeraete to home appliance
* renamed strafe to penalty (optimization problem)

Signed-off-by: Jürgen Eckel <juergen.eckel@gmail.com>

* removed penalty renaming

Signed-off-by: Jürgen Eckel <juergen.eckel@gmail.com>

* renamed one variable

Signed-off-by: Jürgen Eckel <juergen.eckel@gmail.com>

* * renamed variable names and methods of the home appliance class

* renamed missed method names

* fixed renamed variable

* renamed object

* adjusted to latest repo changes

* renamed file to class_home_applianc.py

* renamed method

---------

Signed-off-by: Jürgen Eckel <juergen.eckel@gmail.com>
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel
2024-11-26 00:53:16 +01:00
committed by GitHub
parent 12679b6ab1
commit 2a163569bc
16 changed files with 174 additions and 107 deletions

View File

@@ -2,53 +2,53 @@ import numpy as np
from pydantic import BaseModel, Field
class HaushaltsgeraetParameters(BaseModel):
verbrauch_wh: int = Field(
class HomeApplianceParameters(BaseModel):
consumption_wh: int = Field(
gt=0,
description="An integer representing the energy consumption of a household device in watt-hours.",
)
dauer_h: int = Field(
duration_h: int = Field(
gt=0,
description="An integer representing the usage duration of a household device in hours.",
)
class Haushaltsgeraet:
def __init__(self, parameters: HaushaltsgeraetParameters, hours=24):
class HomeAppliance:
def __init__(self, parameters: HomeApplianceParameters, hours=None):
self.hours = hours # Total duration for which the planning is done
self.verbrauch_wh = (
parameters.verbrauch_wh # Total energy consumption of the device in kWh
)
self.dauer_h = parameters.dauer_h # Duration of use in hours
self.lastkurve = np.zeros(self.hours) # Initialize the load curve with zeros
self.consumption_wh = (
parameters.consumption_wh
) # Total energy consumption of the device in kWh
self.duration_h = parameters.duration_h # Duration of use in hours
self.load_curve = np.zeros(self.hours) # Initialize the load curve with zeros
def set_startzeitpunkt(self, start_hour, global_start_hour=0):
def set_starting_time(self, start_hour, global_start_hour=0):
"""Sets the start time of the device and generates the corresponding load curve.
:param start_hour: The hour at which the device should start.
"""
self.reset()
# Check if the duration of use is within the available time frame
if start_hour + self.dauer_h > self.hours:
if start_hour + self.duration_h > self.hours:
raise ValueError("The duration of use exceeds the available time frame.")
if start_hour < global_start_hour:
raise ValueError("The start time is earlier than the available time frame.")
# Calculate power per hour based on total consumption and duration
leistung_pro_stunde = self.verbrauch_wh / self.dauer_h # Convert to watt-hours
power_per_hour = self.consumption_wh / self.duration_h # Convert to watt-hours
# Set the power for the duration of use in the load curve array
self.lastkurve[start_hour : start_hour + self.dauer_h] = leistung_pro_stunde
self.load_curve[start_hour : start_hour + self.duration_h] = power_per_hour
def reset(self):
"""Resets the load curve."""
self.lastkurve = np.zeros(self.hours)
self.load_curve = np.zeros(self.hours)
def get_lastkurve(self):
def get_load_curve(self):
"""Returns the current load curve."""
return self.lastkurve
return self.load_curve
def get_last_fuer_stunde(self, hour):
def get_load_for_hour(self, hour):
"""Returns the load for a specific hour.
:param hour: The hour for which the load is queried.
@@ -57,8 +57,8 @@ class Haushaltsgeraet:
if hour < 0 or hour >= self.hours:
raise ValueError("The specified hour is outside the available time frame.")
return self.lastkurve[hour]
return self.load_curve[hour]
def spaetestmoeglicher_startzeitpunkt(self):
def get_latest_starting_point(self):
"""Returns the latest possible start time at which the device can still run completely."""
return self.hours - self.dauer_h
return self.hours - self.duration_h