Activate optimization test with 3 generations

This commit is contained in:
Michael Osthege
2024-10-07 19:52:48 +02:00
committed by Andreas
parent f4661b0043
commit 2f1f37577b
2 changed files with 10 additions and 5 deletions

View File

@@ -198,7 +198,7 @@ class optimization_problem:
return (gesamtbilanz,)
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]]]:
"""Run the optimization process using a genetic algorithm."""
population = self.toolbox.population(n=300)
@@ -222,7 +222,7 @@ class optimization_problem:
lambda_=200,
cxpb=0.5,
mutpb=0.3,
ngen=400,
ngen=ngen,
stats=stats,
halloffame=hof,
verbose=self.verbose,
@@ -244,6 +244,8 @@ class optimization_problem:
start_hour: Optional[int] = None,
worst_case: bool = False,
startdate: Optional[Any] = None, # startdate is not used!
*,
ngen: int = 400,
) -> Dict[str, Any]:
"""
Perform EMS (Energy Management System) optimization and visualize results.
@@ -303,7 +305,9 @@ class optimization_problem:
"evaluate",
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
o = self.evaluate_inner(start_solution, ems, start_hour)