mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-11-01 15:26:19 +00:00
fix: ensure genetic common settings available
Some checks failed
docker-build / platform-excludes (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
Some checks failed
docker-build / platform-excludes (push) Has been cancelled
docker-build / build (push) Has been cancelled
docker-build / merge (push) Has been cancelled
pre-commit / pre-commit (push) Has been cancelled
Run Pytest on Pull Request / test (push) Has been cancelled
Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
from typing import Optional, Union
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic import Field, model_validator
|
||||
|
||||
from akkudoktoreos.config.configabc import SettingsBaseModel
|
||||
from akkudoktoreos.core.pydantic import PydanticBaseModel, PydanticDateTimeDataFrame
|
||||
from akkudoktoreos.core.pydantic import (
|
||||
PydanticBaseModel,
|
||||
PydanticDateTimeDataFrame,
|
||||
)
|
||||
from akkudoktoreos.utils.datetimeutil import DateTime
|
||||
|
||||
|
||||
@@ -58,12 +61,26 @@ class OptimizationCommonSettings(SettingsBaseModel):
|
||||
examples=[60 * 60, 15 * 60],
|
||||
)
|
||||
|
||||
algorithm: Optional[str] = Field(
|
||||
default="GENETIC",
|
||||
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}}],
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def _enforce_algorithm_configuration(self) -> "OptimizationCommonSettings":
|
||||
"""Ensure algorithm default configuration is set."""
|
||||
if self.algorithm is not None:
|
||||
if self.algorithm.lower() == "genetic" and self.genetic is None:
|
||||
self.genetic = GeneticCommonSettings()
|
||||
return self
|
||||
|
||||
|
||||
class OptimizationSolution(PydanticBaseModel):
|
||||
"""General Optimization Solution."""
|
||||
|
||||
Reference in New Issue
Block a user