Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel computing does not work fine for experiment. #172

Open
zixiangliwust opened this issue May 15, 2024 · 0 comments
Open

Parallel computing does not work fine for experiment. #172

zixiangliwust opened this issue May 15, 2024 · 0 comments

Comments

@zixiangliwust
Copy link

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())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant