Skip to content

Parallel computing does not work fine for experiment.  #172

@zixiangliwust

Description

@zixiangliwust

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions