pymoo
pymoo copied to clipboard
Time based termination not working
if __name__ == "__main__":
initial_solution = actions_to_np(get_solution(f"merged/{SEED}.json"))
algorithm = PatternSearch(x0=initial_solution)
np.random.seed(2281)
demand = get_demand()
problem = MyProblem(demand)
termination = get_termination("time", 1)
res: None | Any = minimize(problem, algorithm, termination, verbose=True) # type: ignore[reportUnknownVariableType]
if res is None or res.X is None:
print("No solution found")
exit()
best_solution = problem.decode_actions(res.X)
best_score = Evaluator(
best_solution, demand, SERVER_MAP, DATACENTER_MAP, SELLING_PRICES_MAP
).get_score()
print(f"Best score: {best_score}")
This doesn't terminate. Swapping the value to 0.x terminates instantly.
Does providing the full string solve this issue?
termination = get_termination("time", "00:00:03")