mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2025-04-19 08:55:15 +00:00
Activate optimization test with 3 generations
This commit is contained in:
parent
b6d0ef22f3
commit
3c1482c2c0
@ -198,7 +198,7 @@ class optimization_problem:
|
|||||||
return (gesamtbilanz,)
|
return (gesamtbilanz,)
|
||||||
|
|
||||||
def optimize(
|
def optimize(
|
||||||
self, start_solution: Optional[List[float]] = None
|
self, start_solution: Optional[List[float]] = None, ngen: int = 400
|
||||||
) -> Tuple[Any, Dict[str, List[Any]]]:
|
) -> Tuple[Any, Dict[str, List[Any]]]:
|
||||||
"""Run the optimization process using a genetic algorithm."""
|
"""Run the optimization process using a genetic algorithm."""
|
||||||
population = self.toolbox.population(n=300)
|
population = self.toolbox.population(n=300)
|
||||||
@ -222,7 +222,7 @@ class optimization_problem:
|
|||||||
lambda_=200,
|
lambda_=200,
|
||||||
cxpb=0.5,
|
cxpb=0.5,
|
||||||
mutpb=0.3,
|
mutpb=0.3,
|
||||||
ngen=400,
|
ngen=ngen,
|
||||||
stats=stats,
|
stats=stats,
|
||||||
halloffame=hof,
|
halloffame=hof,
|
||||||
verbose=self.verbose,
|
verbose=self.verbose,
|
||||||
@ -244,6 +244,8 @@ class optimization_problem:
|
|||||||
start_hour: Optional[int] = None,
|
start_hour: Optional[int] = None,
|
||||||
worst_case: bool = False,
|
worst_case: bool = False,
|
||||||
startdate: Optional[Any] = None, # startdate is not used!
|
startdate: Optional[Any] = None, # startdate is not used!
|
||||||
|
*,
|
||||||
|
ngen: int = 400,
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Perform EMS (Energy Management System) optimization and visualize results.
|
Perform EMS (Energy Management System) optimization and visualize results.
|
||||||
@ -303,7 +305,9 @@ class optimization_problem:
|
|||||||
"evaluate",
|
"evaluate",
|
||||||
lambda ind: self.evaluate(ind, ems, parameter, start_hour, worst_case),
|
lambda ind: self.evaluate(ind, ems, parameter, start_hour, worst_case),
|
||||||
)
|
)
|
||||||
start_solution, extra_data = self.optimize(parameter["start_solution"])
|
start_solution, extra_data = self.optimize(
|
||||||
|
parameter["start_solution"], ngen=ngen
|
||||||
|
)
|
||||||
|
|
||||||
# Perform final evaluation on the best solution
|
# Perform final evaluation on the best solution
|
||||||
o = self.evaluate_inner(start_solution, ems, start_hour)
|
o = self.evaluate_inner(start_solution, ems, start_hour)
|
||||||
|
@ -11,7 +11,6 @@ DIR_TESTDATA = Path(__file__).parent / "testdata"
|
|||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"fn_in, fn_out", [("optimize_input_1.json", "optimize_result_1.json")]
|
"fn_in, fn_out", [("optimize_input_1.json", "optimize_result_1.json")]
|
||||||
)
|
)
|
||||||
@pytest.mark.skip(reason="Expensive - Skipped per default")
|
|
||||||
def test_optimize(fn_in, fn_out):
|
def test_optimize(fn_in, fn_out):
|
||||||
# Load input and output data
|
# Load input and output data
|
||||||
with open(DIR_TESTDATA / fn_in, "r") as f_in:
|
with open(DIR_TESTDATA / fn_in, "r") as f_in:
|
||||||
@ -26,7 +25,9 @@ def test_optimize(fn_in, fn_out):
|
|||||||
start_hour = 10
|
start_hour = 10
|
||||||
|
|
||||||
# Call the optimization function
|
# Call the optimization function
|
||||||
ergebnis = opt_class.optimierung_ems(parameter=input_data, start_hour=start_hour)
|
ergebnis = opt_class.optimierung_ems(
|
||||||
|
parameter=input_data, start_hour=start_hour, ngen=3
|
||||||
|
)
|
||||||
|
|
||||||
# Assert that the output contains all expected entries.
|
# Assert that the output contains all expected entries.
|
||||||
# This does not assert that the optimization always gives the same result!
|
# This does not assert that the optimization always gives the same result!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user