pymoo icon indicating copy to clipboard operation
pymoo copied to clipboard

Time based termination not working

Open acheong08 opened this issue 1 year ago • 1 comments


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.

acheong08 avatar Sep 06 '24 11:09 acheong08

Does providing the full string solve this issue?

termination = get_termination("time", "00:00:03")

blankjul avatar Sep 22 '24 16:09 blankjul