Project-Platypus / Platypus

A Free and Open Source Python Library for Multiobjective Optimization
GNU General Public License v3.0
563 stars 153 forks source link

Parallelization not finishing #146

Closed sabrinadraude closed 1 year ago

sabrinadraude commented 4 years ago

Hi,

I have been using the parallelization aspect of Platypus. However the code never finishes, after hours of leaving it to run. I'm not sure if there is something else I need to download?

problem = Problem(multiple_days_assigned_size, 2, 2)
problem.directions[1] = Problem.MINIMIZE
problem.directions[0] = Problem.MINIMIZE
problem.constraints[:] = ">=0"
problem.types[:] = Integer(0, my_counter_again - 1)
problem.function = lambda x: evaluation_function2(x, jobs, c_time_added_up, total_allowed_time_all_jobs,
                                                  extra_time)

# calculate the difference in models nsga2 and nsga3
if __name__ == "__main__":
    algorithms = [NSGAII, (NSGAIII, {"divisions_outer":12})]
    with ProcessPoolEvaluator(4) as evaluator:
        results = experiment(algorithms, [problem], nfe=2, evaluator=evaluator)

        # Calculate the hypervolume using assigned objective max and mins for comparing algorithms
        min_pri = 0
        min_cost = multiple_days_assigned_size * 30
        max_pri = multiple_days_assigned_size * 6.53
        max_cost = multiple_days_assigned_size * 130

        # calculate the hypervolume indicator between the algorithms
        hyp = Hypervolume(minimum=[min_pri, min_cost], maximum=[max_pri, max_cost])
        hyp_result = calculate(results, hyp, evaluator=evaluator)
        display(hyp_result, ndigits=3)
jetuk commented 4 years ago

How long does evaluation_function2 take to run? Can you see if it is running and completing in a reasonable time? Does it work OK with NSGAII but not NSGAIII, or the other way around?

sabrinadraude commented 4 years ago

Hiya,

the evaluation function takes a few mins to run for each of the algorithms separately. I'm not sure why it won't finish when I try use the parallelization . Should I try run it for less?

Cheers,

Sabrina

jetuk commented 4 years ago

Can you try without the hypervolume lines at the bottom? It might be that each process is stalling trying to display the HV figure?

sabrinadraude commented 4 years ago

I've tried that as well, and still after an hour no result has been created.

jetuk commented 4 years ago

Sorry, I lost track of this issue. Did you manage to solve the problem? If not, do the algorithms solve individually without using the experiment function?

sabrinadraude commented 4 years ago

Hiya, yep they all solve individually. Just the experimenter doesn't conclude when I use my problem. I used the example code provided and that works, just my example doesn't.

jetuk commented 4 years ago

Both examples are using the ProcessPoolEvaluator? Does your function do anything with threads or processes (e.g. uses the multiprocessing library)?

sabrinadraude commented 4 years ago

Yep both use ProcessPoolEvaluator and my function does not include threads or processes.

jetuk commented 4 years ago

I'm afraid its quite difficult to debug without your function unless you can isolate what block/function call is causing it to misbehave.

github-actions[bot] commented 1 year ago

This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR.