jMetalPy icon indicating copy to clipboard operation
jMetalPy copied to clipboard

Parallel computing does not work fine for experiment.

Open zixiangliwust opened this issue 1 month ago • 1 comments

Parallel computing does not work fine for experiment. Different values of max_workers (e.g., max_workers=1 and max_workers=10) consume the same computation time.

class Experiment: def init(self, output_dir: str, jobs: List[Job], m_workers: int = 6): """Run an experiment to execute a list of jobs.

    :param output_dir: Base directory where each job will save its results.
    :param jobs: List of Jobs (from :py:mod:`jmetal.util.laboratory)`) to be executed.
    :param m_workers: Maximum number of workers to execute the Jobs in parallel.
    """
    self.jobs = jobs
    self.m_workers = m_workers
    self.output_dir = output_dir
    self.job_data = []

def run(self) -> None:
    with ProcessPoolExecutor(max_workers=10) as executor:
        for job in self.jobs:
            output_path = os.path.join(self.output_dir, job.algorithm_tag, job.problem_tag)
            executor.submit(job.execute(output_path))
            self.job_data.append(job.get_algorithm_data())

zixiangliwust avatar May 15 '24 09:05 zixiangliwust