mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-11-21 12:56:27 +00:00
fix: pydantic extra keywords deprecated (#753)
Pydantic deprecates using extra keyword arguments on Field. Used json_schema_extra instead. Deprecated in Pydantic V2.0 to be removed in V3.0. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -34,50 +34,74 @@ class GeneticSimulation(PydanticBaseModel):
|
||||
)
|
||||
|
||||
start_hour: int = Field(
|
||||
default=0, ge=0, le=23, description="Starting hour on day for optimizations."
|
||||
default=0,
|
||||
ge=0,
|
||||
le=23,
|
||||
json_schema_extra={"description": "Starting hour on day for optimizations."},
|
||||
)
|
||||
|
||||
optimization_hours: Optional[int] = Field(
|
||||
default=24, ge=0, description="Number of hours into the future for optimizations."
|
||||
default=24,
|
||||
ge=0,
|
||||
json_schema_extra={"description": "Number of hours into the future for optimizations."},
|
||||
)
|
||||
|
||||
prediction_hours: Optional[int] = Field(
|
||||
default=48, ge=0, description="Number of hours into the future for predictions"
|
||||
default=48,
|
||||
ge=0,
|
||||
json_schema_extra={"description": "Number of hours into the future for predictions"},
|
||||
)
|
||||
|
||||
load_energy_array: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None,
|
||||
description="An array of floats representing the total load (consumption) in watts for different time intervals.",
|
||||
json_schema_extra={
|
||||
"description": "An array of floats representing the total load (consumption) in watts for different time intervals."
|
||||
},
|
||||
)
|
||||
pv_prediction_wh: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None,
|
||||
description="An array of floats representing the forecasted photovoltaic output in watts for different time intervals.",
|
||||
json_schema_extra={
|
||||
"description": "An array of floats representing the forecasted photovoltaic output in watts for different time intervals."
|
||||
},
|
||||
)
|
||||
elect_price_hourly: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None,
|
||||
description="An array of floats representing the electricity price in euros per watt-hour for different time intervals.",
|
||||
json_schema_extra={
|
||||
"description": "An array of floats representing the electricity price in euros per watt-hour for different time intervals."
|
||||
},
|
||||
)
|
||||
elect_revenue_per_hour_arr: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None,
|
||||
description="An array of floats representing the feed-in compensation in euros per watt-hour.",
|
||||
json_schema_extra={
|
||||
"description": "An array of floats representing the feed-in compensation in euros per watt-hour."
|
||||
},
|
||||
)
|
||||
|
||||
battery: Optional[Battery] = Field(default=None, description="TBD.")
|
||||
ev: Optional[Battery] = Field(default=None, description="TBD.")
|
||||
home_appliance: Optional[HomeAppliance] = Field(default=None, description="TBD.")
|
||||
inverter: Optional[Inverter] = Field(default=None, description="TBD.")
|
||||
battery: Optional[Battery] = Field(default=None, json_schema_extra={"description": "TBD."})
|
||||
ev: Optional[Battery] = Field(default=None, json_schema_extra={"description": "TBD."})
|
||||
home_appliance: Optional[HomeAppliance] = Field(
|
||||
default=None, json_schema_extra={"description": "TBD."}
|
||||
)
|
||||
inverter: Optional[Inverter] = Field(default=None, json_schema_extra={"description": "TBD."})
|
||||
|
||||
ac_charge_hours: Optional[NDArray[Shape["*"], float]] = Field(default=None, description="TBD")
|
||||
dc_charge_hours: Optional[NDArray[Shape["*"], float]] = Field(default=None, description="TBD")
|
||||
ac_charge_hours: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None, json_schema_extra={"description": "TBD"}
|
||||
)
|
||||
dc_charge_hours: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None, json_schema_extra={"description": "TBD"}
|
||||
)
|
||||
bat_discharge_hours: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None, description="TBD"
|
||||
default=None, json_schema_extra={"description": "TBD"}
|
||||
)
|
||||
ev_charge_hours: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None, json_schema_extra={"description": "TBD"}
|
||||
)
|
||||
ev_charge_hours: Optional[NDArray[Shape["*"], float]] = Field(default=None, description="TBD")
|
||||
ev_discharge_hours: Optional[NDArray[Shape["*"], float]] = Field(
|
||||
default=None, description="TBD"
|
||||
default=None, json_schema_extra={"description": "TBD"}
|
||||
)
|
||||
home_appliance_start_hour: Optional[int] = Field(
|
||||
default=None, description="Home appliance start hour - None denotes no start."
|
||||
default=None,
|
||||
json_schema_extra={"description": "Home appliance start hour - None denotes no start."},
|
||||
)
|
||||
|
||||
def prepare(
|
||||
|
||||
@@ -9,27 +9,27 @@ from akkudoktoreos.utils.datetimeutil import TimeWindowSequence
|
||||
|
||||
|
||||
class DeviceParameters(GeneticParametersBaseModel):
|
||||
device_id: str = Field(description="ID of device", examples="device1")
|
||||
device_id: str = Field(json_schema_extra={"description": "ID of device", "examples": "device1"})
|
||||
hours: Optional[int] = Field(
|
||||
default=None,
|
||||
gt=0,
|
||||
description="Number of prediction hours. Defaults to global config prediction hours.",
|
||||
examples=[None],
|
||||
json_schema_extra={
|
||||
"description": "Number of prediction hours. Defaults to global config prediction hours.",
|
||||
"examples": [None],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def max_charging_power_field(description: Optional[str] = None) -> float:
|
||||
if description is None:
|
||||
description = "Maximum charging power in watts."
|
||||
return Field(
|
||||
default=5000,
|
||||
gt=0,
|
||||
description=description,
|
||||
)
|
||||
return Field(default=5000, gt=0, json_schema_extra={"description": description})
|
||||
|
||||
|
||||
def initial_soc_percentage_field(description: str) -> int:
|
||||
return Field(default=0, ge=0, le=100, description=description, examples=[42])
|
||||
return Field(
|
||||
default=0, ge=0, le=100, json_schema_extra={"description": description, "examples": [42]}
|
||||
)
|
||||
|
||||
|
||||
def discharging_efficiency_field(default_value: float) -> float:
|
||||
@@ -37,24 +37,32 @@ def discharging_efficiency_field(default_value: float) -> float:
|
||||
default=default_value,
|
||||
gt=0,
|
||||
le=1,
|
||||
description="A float representing the discharge efficiency of the battery.",
|
||||
json_schema_extra={
|
||||
"description": "A float representing the discharge efficiency of the battery."
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class BaseBatteryParameters(DeviceParameters):
|
||||
"""Battery Device Simulation Configuration."""
|
||||
|
||||
device_id: str = Field(description="ID of battery", examples=["battery1"])
|
||||
device_id: str = Field(
|
||||
json_schema_extra={"description": "ID of battery", "examples": ["battery1"]}
|
||||
)
|
||||
capacity_wh: int = Field(
|
||||
gt=0,
|
||||
description="An integer representing the capacity of the battery in watt-hours.",
|
||||
examples=[8000],
|
||||
json_schema_extra={
|
||||
"description": "An integer representing the capacity of the battery in watt-hours.",
|
||||
"examples": [8000],
|
||||
},
|
||||
)
|
||||
charging_efficiency: float = Field(
|
||||
default=0.88,
|
||||
gt=0,
|
||||
le=1,
|
||||
description="A float representing the charging efficiency of the battery.",
|
||||
json_schema_extra={
|
||||
"description": "A float representing the charging efficiency of the battery."
|
||||
},
|
||||
)
|
||||
discharging_efficiency: float = discharging_efficiency_field(0.88)
|
||||
max_charge_power_w: Optional[float] = max_charging_power_field()
|
||||
@@ -65,19 +73,25 @@ class BaseBatteryParameters(DeviceParameters):
|
||||
default=0,
|
||||
ge=0,
|
||||
le=100,
|
||||
description="An integer representing the minimum state of charge (SOC) of the battery in percentage.",
|
||||
examples=[10],
|
||||
json_schema_extra={
|
||||
"description": "An integer representing the minimum state of charge (SOC) of the battery in percentage.",
|
||||
"examples": [10],
|
||||
},
|
||||
)
|
||||
max_soc_percentage: int = Field(
|
||||
default=100,
|
||||
ge=0,
|
||||
le=100,
|
||||
description="An integer representing the maximum state of charge (SOC) of the battery in percentage.",
|
||||
json_schema_extra={
|
||||
"description": "An integer representing the maximum state of charge (SOC) of the battery in percentage."
|
||||
},
|
||||
)
|
||||
charge_rates: Optional[list[float]] = Field(
|
||||
default=None,
|
||||
description="Charge rates as factor of maximum charging power [0.00 ... 1.00]. None denotes all charge rates are available.",
|
||||
examples=[[0.0, 0.25, 0.5, 0.75, 1.0], None],
|
||||
json_schema_extra={
|
||||
"description": "Charge rates as factor of maximum charging power [0.00 ... 1.00]. None denotes all charge rates are available.",
|
||||
"examples": [[0.0, 0.25, 0.5, 0.75, 1.0], None],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -90,7 +104,9 @@ class SolarPanelBatteryParameters(BaseBatteryParameters):
|
||||
class ElectricVehicleParameters(BaseBatteryParameters):
|
||||
"""Battery Electric Vehicle Device Simulation Configuration."""
|
||||
|
||||
device_id: str = Field(description="ID of electric vehicle", examples=["ev1"])
|
||||
device_id: str = Field(
|
||||
json_schema_extra={"description": "ID of electric vehicle", "examples": ["ev1"]}
|
||||
)
|
||||
discharging_efficiency: float = discharging_efficiency_field(1.0)
|
||||
initial_soc_percentage: int = initial_soc_percentage_field(
|
||||
"An integer representing the current state of charge (SOC) of the battery in percentage."
|
||||
@@ -100,33 +116,44 @@ class ElectricVehicleParameters(BaseBatteryParameters):
|
||||
class HomeApplianceParameters(DeviceParameters):
|
||||
"""Home Appliance Device Simulation Configuration."""
|
||||
|
||||
device_id: str = Field(description="ID of home appliance", examples=["dishwasher"])
|
||||
device_id: str = Field(
|
||||
json_schema_extra={"description": "ID of home appliance", "examples": ["dishwasher"]}
|
||||
)
|
||||
consumption_wh: int = Field(
|
||||
gt=0,
|
||||
description="An integer representing the energy consumption of a household device in watt-hours.",
|
||||
examples=[2000],
|
||||
json_schema_extra={
|
||||
"description": "An integer representing the energy consumption of a household device in watt-hours.",
|
||||
"examples": [2000],
|
||||
},
|
||||
)
|
||||
duration_h: int = Field(
|
||||
gt=0,
|
||||
description="An integer representing the usage duration of a household device in hours.",
|
||||
examples=[3],
|
||||
json_schema_extra={
|
||||
"description": "An integer representing the usage duration of a household device in hours.",
|
||||
"examples": [3],
|
||||
},
|
||||
)
|
||||
time_windows: Optional[TimeWindowSequence] = Field(
|
||||
default=None,
|
||||
description="List of allowed time windows. Defaults to optimization general time window.",
|
||||
examples=[
|
||||
[
|
||||
{"start_time": "10:00", "duration": "2 hours"},
|
||||
json_schema_extra={
|
||||
"description": "List of allowed time windows. Defaults to optimization general time window.",
|
||||
"examples": [
|
||||
[
|
||||
{"start_time": "10:00", "duration": "2 hours"},
|
||||
],
|
||||
],
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class InverterParameters(DeviceParameters):
|
||||
"""Inverter Device Simulation Configuration."""
|
||||
|
||||
device_id: str = Field(description="ID of inverter", examples=["inverter1"])
|
||||
max_power_wh: float = Field(gt=0, examples=[10000])
|
||||
battery_id: Optional[str] = Field(
|
||||
default=None, description="ID of battery", examples=[None, "battery1"]
|
||||
device_id: str = Field(
|
||||
json_schema_extra={"description": "ID of inverter", "examples": ["inverter1"]}
|
||||
)
|
||||
max_power_wh: float = Field(gt=0, json_schema_extra={"examples": [10000]})
|
||||
battery_id: Optional[str] = Field(
|
||||
default=None,
|
||||
json_schema_extra={"description": "ID of battery", "examples": [None, "battery1"]},
|
||||
)
|
||||
|
||||
@@ -37,19 +37,29 @@ class GeneticEnergyManagementParameters(GeneticParametersBaseModel):
|
||||
"""Encapsulates energy-related forecasts and costs used in GENETIC optimization."""
|
||||
|
||||
pv_prognose_wh: list[float] = Field(
|
||||
description="An array of floats representing the forecasted photovoltaic output in watts for different time intervals."
|
||||
json_schema_extra={
|
||||
"description": "An array of floats representing the forecasted photovoltaic output in watts for different time intervals."
|
||||
}
|
||||
)
|
||||
strompreis_euro_pro_wh: list[float] = Field(
|
||||
description="An array of floats representing the electricity price in euros per watt-hour for different time intervals."
|
||||
json_schema_extra={
|
||||
"description": "An array of floats representing the electricity price in euros per watt-hour for different time intervals."
|
||||
}
|
||||
)
|
||||
einspeiseverguetung_euro_pro_wh: Union[list[float], float] = Field(
|
||||
description="A float or array of floats representing the feed-in compensation in euros per watt-hour."
|
||||
json_schema_extra={
|
||||
"description": "A float or array of floats representing the feed-in compensation in euros per watt-hour."
|
||||
}
|
||||
)
|
||||
preis_euro_pro_wh_akku: float = Field(
|
||||
description="A float representing the cost of battery energy per watt-hour."
|
||||
json_schema_extra={
|
||||
"description": "A float representing the cost of battery energy per watt-hour."
|
||||
}
|
||||
)
|
||||
gesamtlast: list[float] = Field(
|
||||
description="An array of floats representing the total load (consumption) in watts for different time intervals."
|
||||
json_schema_extra={
|
||||
"description": "An array of floats representing the total load (consumption) in watts for different time intervals."
|
||||
}
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
@@ -93,10 +103,15 @@ class GeneticOptimizationParameters(
|
||||
dishwasher: Optional[HomeApplianceParameters] = None
|
||||
temperature_forecast: Optional[list[Optional[float]]] = Field(
|
||||
default=None,
|
||||
description="An array of floats representing the temperature forecast in degrees Celsius for different time intervals.",
|
||||
json_schema_extra={
|
||||
"description": "An array of floats representing the temperature forecast in degrees Celsius for different time intervals."
|
||||
},
|
||||
)
|
||||
start_solution: Optional[list[float]] = Field(
|
||||
default=None, description="Can be `null` or contain a previous solution (if available)."
|
||||
default=None,
|
||||
json_schema_extra={
|
||||
"description": "Can be `null` or contain a previous solution (if available)."
|
||||
},
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
|
||||
@@ -28,29 +28,52 @@ from akkudoktoreos.utils.utils import NumpyEncoder
|
||||
|
||||
|
||||
class DeviceOptimizeResult(GeneticParametersBaseModel):
|
||||
device_id: str = Field(description="ID of device", examples=["device1"])
|
||||
hours: int = Field(gt=0, description="Number of hours in the simulation.", examples=[24])
|
||||
device_id: str = Field(
|
||||
json_schema_extra={"description": "ID of device", "examples": ["device1"]}
|
||||
)
|
||||
hours: int = Field(
|
||||
gt=0,
|
||||
json_schema_extra={"description": "Number of hours in the simulation.", "examples": [24]},
|
||||
)
|
||||
|
||||
|
||||
class ElectricVehicleResult(DeviceOptimizeResult):
|
||||
"""Result class containing information related to the electric vehicle's charging and discharging behavior."""
|
||||
|
||||
device_id: str = Field(description="ID of electric vehicle", examples=["ev1"])
|
||||
device_id: str = Field(
|
||||
json_schema_extra={"description": "ID of electric vehicle", "examples": ["ev1"]}
|
||||
)
|
||||
charge_array: list[float] = Field(
|
||||
description="Hourly charging status (0 for no charging, 1 for charging)."
|
||||
json_schema_extra={
|
||||
"description": "Hourly charging status (0 for no charging, 1 for charging)."
|
||||
}
|
||||
)
|
||||
discharge_array: list[int] = Field(
|
||||
description="Hourly discharging status (0 for no discharging, 1 for discharging)."
|
||||
json_schema_extra={
|
||||
"description": "Hourly discharging status (0 for no discharging, 1 for discharging)."
|
||||
}
|
||||
)
|
||||
discharging_efficiency: float = Field(
|
||||
json_schema_extra={"description": "The discharge efficiency as a float.."}
|
||||
)
|
||||
capacity_wh: int = Field(
|
||||
json_schema_extra={"description": "Capacity of the EV’s battery in watt-hours."}
|
||||
)
|
||||
charging_efficiency: float = Field(
|
||||
json_schema_extra={"description": "Charging efficiency as a float.."}
|
||||
)
|
||||
max_charge_power_w: int = Field(
|
||||
json_schema_extra={"description": "Maximum charging power in watts."}
|
||||
)
|
||||
discharging_efficiency: float = Field(description="The discharge efficiency as a float..")
|
||||
capacity_wh: int = Field(description="Capacity of the EV’s battery in watt-hours.")
|
||||
charging_efficiency: float = Field(description="Charging efficiency as a float..")
|
||||
max_charge_power_w: int = Field(description="Maximum charging power in watts.")
|
||||
soc_wh: float = Field(
|
||||
description="State of charge of the battery in watt-hours at the start of the simulation."
|
||||
json_schema_extra={
|
||||
"description": "State of charge of the battery in watt-hours at the start of the simulation."
|
||||
}
|
||||
)
|
||||
initial_soc_percentage: int = Field(
|
||||
description="State of charge at the start of the simulation in percentage."
|
||||
json_schema_extra={
|
||||
"description": "State of charge at the start of the simulation in percentage."
|
||||
}
|
||||
)
|
||||
|
||||
@field_validator("discharge_array", "charge_array", mode="before")
|
||||
@@ -61,37 +84,49 @@ class ElectricVehicleResult(DeviceOptimizeResult):
|
||||
class GeneticSimulationResult(GeneticParametersBaseModel):
|
||||
"""This object contains the results of the simulation and provides insights into various parameters over the entire forecast period."""
|
||||
|
||||
Last_Wh_pro_Stunde: list[float] = Field(description="TBD")
|
||||
Last_Wh_pro_Stunde: list[float] = Field(json_schema_extra={"description": "TBD"})
|
||||
EAuto_SoC_pro_Stunde: list[float] = Field(
|
||||
description="The state of charge of the EV for each hour."
|
||||
json_schema_extra={"description": "The state of charge of the EV for each hour."}
|
||||
)
|
||||
Einnahmen_Euro_pro_Stunde: list[float] = Field(
|
||||
description="The revenue from grid feed-in or other sources in euros per hour."
|
||||
json_schema_extra={
|
||||
"description": "The revenue from grid feed-in or other sources in euros per hour."
|
||||
}
|
||||
)
|
||||
Gesamt_Verluste: float = Field(
|
||||
description="The total losses in watt-hours over the entire period."
|
||||
json_schema_extra={"description": "The total losses in watt-hours over the entire period."}
|
||||
)
|
||||
Gesamtbilanz_Euro: float = Field(
|
||||
description="The total balance of revenues minus costs in euros."
|
||||
json_schema_extra={"description": "The total balance of revenues minus costs in euros."}
|
||||
)
|
||||
Gesamteinnahmen_Euro: float = Field(description="The total revenues in euros.")
|
||||
Gesamtkosten_Euro: float = Field(description="The total costs in euros.")
|
||||
Gesamteinnahmen_Euro: float = Field(
|
||||
json_schema_extra={"description": "The total revenues in euros."}
|
||||
)
|
||||
Gesamtkosten_Euro: float = Field(json_schema_extra={"description": "The total costs in euros."})
|
||||
Home_appliance_wh_per_hour: list[Optional[float]] = Field(
|
||||
description="The energy consumption of a household appliance in watt-hours per hour."
|
||||
json_schema_extra={
|
||||
"description": "The energy consumption of a household appliance in watt-hours per hour."
|
||||
}
|
||||
)
|
||||
Kosten_Euro_pro_Stunde: list[float] = Field(
|
||||
json_schema_extra={"description": "The costs in euros per hour."}
|
||||
)
|
||||
Kosten_Euro_pro_Stunde: list[float] = Field(description="The costs in euros per hour.")
|
||||
Netzbezug_Wh_pro_Stunde: list[float] = Field(
|
||||
description="The grid energy drawn in watt-hours per hour."
|
||||
json_schema_extra={"description": "The grid energy drawn in watt-hours per hour."}
|
||||
)
|
||||
Netzeinspeisung_Wh_pro_Stunde: list[float] = Field(
|
||||
description="The energy fed into the grid in watt-hours per hour."
|
||||
json_schema_extra={"description": "The energy fed into the grid in watt-hours per hour."}
|
||||
)
|
||||
Verluste_Pro_Stunde: list[float] = Field(
|
||||
json_schema_extra={"description": "The losses in watt-hours per hour."}
|
||||
)
|
||||
Verluste_Pro_Stunde: list[float] = Field(description="The losses in watt-hours per hour.")
|
||||
akku_soc_pro_stunde: list[float] = Field(
|
||||
description="The state of charge of the battery (not the EV) in percentage per hour."
|
||||
json_schema_extra={
|
||||
"description": "The state of charge of the battery (not the EV) in percentage per hour."
|
||||
}
|
||||
)
|
||||
Electricity_price: list[float] = Field(
|
||||
description="Used Electricity Price, including predictions"
|
||||
json_schema_extra={"description": "Used Electricity Price, including predictions"}
|
||||
)
|
||||
|
||||
@field_validator(
|
||||
@@ -115,24 +150,34 @@ class GeneticSolution(ConfigMixin, GeneticParametersBaseModel):
|
||||
"""**Note**: The first value of "Last_Wh_per_hour", "Netzeinspeisung_Wh_per_hour", and "Netzbezug_Wh_per_hour", will be set to null in the JSON output and represented as NaN or None in the corresponding classes' data returns. This approach is adopted to ensure that the current hour's processing remains unchanged."""
|
||||
|
||||
ac_charge: list[float] = Field(
|
||||
description="Array with AC charging values as relative power (0.0-1.0), other values set to 0."
|
||||
json_schema_extra={
|
||||
"description": "Array with AC charging values as relative power (0.0-1.0), other values set to 0."
|
||||
}
|
||||
)
|
||||
dc_charge: list[float] = Field(
|
||||
description="Array with DC charging values as relative power (0-1), other values set to 0."
|
||||
json_schema_extra={
|
||||
"description": "Array with DC charging values as relative power (0-1), other values set to 0."
|
||||
}
|
||||
)
|
||||
discharge_allowed: list[int] = Field(
|
||||
description="Array with discharge values (1 for discharge, 0 otherwise)."
|
||||
json_schema_extra={
|
||||
"description": "Array with discharge values (1 for discharge, 0 otherwise)."
|
||||
}
|
||||
)
|
||||
eautocharge_hours_float: Optional[list[float]] = Field(description="TBD")
|
||||
eautocharge_hours_float: Optional[list[float]] = Field(json_schema_extra={"description": "TBD"})
|
||||
result: GeneticSimulationResult
|
||||
eauto_obj: Optional[ElectricVehicleResult]
|
||||
start_solution: Optional[list[float]] = Field(
|
||||
default=None,
|
||||
description="An array of binary values (0 or 1) representing a possible starting solution for the simulation.",
|
||||
json_schema_extra={
|
||||
"description": "An array of binary values (0 or 1) representing a possible starting solution for the simulation."
|
||||
},
|
||||
)
|
||||
washingstart: Optional[int] = Field(
|
||||
default=None,
|
||||
description="Can be `null` or contain an object representing the start of washing (if applicable).",
|
||||
json_schema_extra={
|
||||
"description": "Can be `null` or contain an object representing the start of washing (if applicable)."
|
||||
},
|
||||
)
|
||||
|
||||
@field_validator(
|
||||
|
||||
@@ -16,30 +16,38 @@ class GeneticCommonSettings(SettingsBaseModel):
|
||||
individuals: Optional[int] = Field(
|
||||
default=300,
|
||||
ge=10,
|
||||
description="Number of individuals (solutions) to generate for the (initial) generation [>= 10]. Defaults to 300.",
|
||||
examples=[300],
|
||||
json_schema_extra={
|
||||
"description": "Number of individuals (solutions) to generate for the (initial) generation [>= 10]. Defaults to 300.",
|
||||
"examples": [300],
|
||||
},
|
||||
)
|
||||
|
||||
generations: Optional[int] = Field(
|
||||
default=400,
|
||||
ge=10,
|
||||
description="Number of generations to evaluate the optimal solution [>= 10]. Defaults to 400.",
|
||||
examples=[400],
|
||||
json_schema_extra={
|
||||
"description": "Number of generations to evaluate the optimal solution [>= 10]. Defaults to 400.",
|
||||
"examples": [400],
|
||||
},
|
||||
)
|
||||
|
||||
seed: Optional[int] = Field(
|
||||
default=None,
|
||||
ge=0,
|
||||
description="Fixed seed for genetic algorithm. Defaults to 'None' which means random seed.",
|
||||
examples=[None],
|
||||
json_schema_extra={
|
||||
"description": "Fixed seed for genetic algorithm. Defaults to 'None' which means random seed.",
|
||||
"examples": [None],
|
||||
},
|
||||
)
|
||||
|
||||
penalties: Optional[dict[str, Union[float, int, str]]] = Field(
|
||||
default=None,
|
||||
description="A dictionary of penalty function parameters consisting of a penalty function parameter name and the associated value.",
|
||||
examples=[
|
||||
{"ev_soc_miss": 10},
|
||||
],
|
||||
json_schema_extra={
|
||||
"description": "A dictionary of penalty function parameters consisting of a penalty function parameter name and the associated value.",
|
||||
"examples": [
|
||||
{"ev_soc_miss": 10},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@@ -49,28 +57,33 @@ class OptimizationCommonSettings(SettingsBaseModel):
|
||||
horizon_hours: Optional[int] = Field(
|
||||
default=24,
|
||||
ge=0,
|
||||
description="The general time window within which the energy optimization goal shall be achieved [h]. Defaults to 24 hours.",
|
||||
examples=[24],
|
||||
json_schema_extra={
|
||||
"description": "The general time window within which the energy optimization goal shall be achieved [h]. Defaults to 24 hours.",
|
||||
"examples": [24],
|
||||
},
|
||||
)
|
||||
|
||||
interval: Optional[int] = Field(
|
||||
default=3600,
|
||||
ge=15 * 60,
|
||||
le=60 * 60,
|
||||
description="The optimization interval [sec].",
|
||||
examples=[60 * 60, 15 * 60],
|
||||
json_schema_extra={
|
||||
"description": "The optimization interval [sec].",
|
||||
"examples": [60 * 60, 15 * 60],
|
||||
},
|
||||
)
|
||||
|
||||
algorithm: Optional[str] = Field(
|
||||
default="GENETIC",
|
||||
description="The optimization algorithm.",
|
||||
examples=["GENETIC"],
|
||||
json_schema_extra={"description": "The optimization algorithm.", "examples": ["GENETIC"]},
|
||||
)
|
||||
|
||||
genetic: Optional[GeneticCommonSettings] = Field(
|
||||
default=None,
|
||||
description="Genetic optimization algorithm configuration.",
|
||||
examples=[{"individuals": 400, "seed": None, "penalties": {"ev_soc_miss": 10}}],
|
||||
json_schema_extra={
|
||||
"description": "Genetic optimization algorithm configuration.",
|
||||
"examples": [{"individuals": 400, "seed": None, "penalties": {"ev_soc_miss": 10}}],
|
||||
},
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
@@ -85,57 +98,71 @@ class OptimizationCommonSettings(SettingsBaseModel):
|
||||
class OptimizationSolution(PydanticBaseModel):
|
||||
"""General Optimization Solution."""
|
||||
|
||||
id: str = Field(..., description="Unique ID for the optimization solution.")
|
||||
id: str = Field(
|
||||
..., json_schema_extra={"description": "Unique ID for the optimization solution."}
|
||||
)
|
||||
|
||||
generated_at: DateTime = Field(..., description="Timestamp when the solution was generated.")
|
||||
generated_at: DateTime = Field(
|
||||
..., json_schema_extra={"description": "Timestamp when the solution was generated."}
|
||||
)
|
||||
|
||||
comment: Optional[str] = Field(
|
||||
default=None, description="Optional comment or annotation for the solution."
|
||||
default=None,
|
||||
json_schema_extra={"description": "Optional comment or annotation for the solution."},
|
||||
)
|
||||
|
||||
valid_from: Optional[DateTime] = Field(
|
||||
default=None, description="Start time of the optimization solution."
|
||||
default=None, json_schema_extra={"description": "Start time of the optimization solution."}
|
||||
)
|
||||
|
||||
valid_until: Optional[DateTime] = Field(
|
||||
default=None,
|
||||
description="End time of the optimization solution.",
|
||||
default=None, json_schema_extra={"description": "End time of the optimization solution."}
|
||||
)
|
||||
|
||||
total_losses_energy_wh: float = Field(
|
||||
description="The total losses in watt-hours over the entire period."
|
||||
json_schema_extra={"description": "The total losses in watt-hours over the entire period."}
|
||||
)
|
||||
|
||||
total_revenues_amt: float = Field(description="The total revenues [money amount].")
|
||||
total_revenues_amt: float = Field(
|
||||
json_schema_extra={"description": "The total revenues [money amount]."}
|
||||
)
|
||||
|
||||
total_costs_amt: float = Field(description="The total costs [money amount].")
|
||||
total_costs_amt: float = Field(
|
||||
json_schema_extra={"description": "The total costs [money amount]."}
|
||||
)
|
||||
|
||||
fitness_score: set[float] = Field(description="The fitness score as a set of fitness values.")
|
||||
fitness_score: set[float] = Field(
|
||||
json_schema_extra={"description": "The fitness score as a set of fitness values."}
|
||||
)
|
||||
|
||||
prediction: PydanticDateTimeDataFrame = Field(
|
||||
description=(
|
||||
"Datetime data frame with time series prediction data per optimization interval:"
|
||||
"- pv_energy_wh: PV energy prediction (positive) in wh"
|
||||
"- elec_price_amt_kwh: Electricity price prediction in money per kwh"
|
||||
"- feed_in_tariff_amt_kwh: Feed in tariff prediction in money per kwh"
|
||||
"- weather_temp_air_celcius: Temperature in °C"
|
||||
"- loadforecast_energy_wh: Load mean energy prediction in wh"
|
||||
"- loadakkudoktor_std_energy_wh: Load energy standard deviation prediction in wh"
|
||||
"- loadakkudoktor_mean_energy_wh: Load mean energy prediction in wh"
|
||||
)
|
||||
json_schema_extra={
|
||||
"description": (
|
||||
"Datetime data frame with time series prediction data per optimization interval:"
|
||||
"- pv_energy_wh: PV energy prediction (positive) in wh"
|
||||
"- elec_price_amt_kwh: Electricity price prediction in money per kwh"
|
||||
"- feed_in_tariff_amt_kwh: Feed in tariff prediction in money per kwh"
|
||||
"- weather_temp_air_celcius: Temperature in °C"
|
||||
"- loadforecast_energy_wh: Load mean energy prediction in wh"
|
||||
"- loadakkudoktor_std_energy_wh: Load energy standard deviation prediction in wh"
|
||||
"- loadakkudoktor_mean_energy_wh: Load mean energy prediction in wh"
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
solution: PydanticDateTimeDataFrame = Field(
|
||||
description=(
|
||||
"Datetime data frame with time series solution data per optimization interval:"
|
||||
"- load_energy_wh: Load of all energy consumers in wh"
|
||||
"- grid_energy_wh: Grid energy feed in (negative) or consumption (positive) in wh"
|
||||
"- costs_amt: Costs in money amount"
|
||||
"- revenue_amt: Revenue in money amount"
|
||||
"- losses_energy_wh: Energy losses in wh"
|
||||
"- <device-id>_operation_mode_id: Operation mode id of the device."
|
||||
"- <device-id>_operation_mode_factor: Operation mode factor of the device."
|
||||
"- <device-id>_soc_factor: State of charge of a battery/ electric vehicle device as factor of total capacity."
|
||||
"- <device-id>_energy_wh: Energy consumption (positive) of a device in wh."
|
||||
)
|
||||
json_schema_extra={
|
||||
"description": (
|
||||
"Datetime data frame with time series solution data per optimization interval:"
|
||||
"- load_energy_wh: Load of all energy consumers in wh"
|
||||
"- grid_energy_wh: Grid energy feed in (negative) or consumption (positive) in wh"
|
||||
"- costs_amt: Costs in money amount"
|
||||
"- revenue_amt: Revenue in money amount"
|
||||
"- losses_energy_wh: Energy losses in wh"
|
||||
"- <device-id>_operation_mode_id: Operation mode id of the device."
|
||||
"- <device-id>_operation_mode_factor: Operation mode factor of the device."
|
||||
"- <device-id>_soc_factor: State of charge of a battery/ electric vehicle device as factor of total capacity."
|
||||
"- <device-id>_energy_wh: Energy consumption (positive) of a device in wh."
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user