Skip to content

How to make the double parallelization? #12

Description

@xushanthu-2014

Hi,
First of all, thank you for developing such a great optimization package!
I’m wondering whether it’s possible to combine parallelization inside the cost function with the parallel evaluation across the CMA-ES population.
Here’s my situation:
I’m optimizing model parameters using CMA-ES.
Inside my cost function, the model performs 17 independent site-level runs (each using the same parameter vector), and then aggregates their results into a single scalar loss. So, there are two potential levels of parallelism:

  1. Across population members (already supported via parallel_evaluation = true), and
  2. Within each cost function evaluation, across the 17 model runs.

Currently, the CMA-ES package parallelizes across the population. However, it would be much faster if I could exploit both levels of parallelism simultaneously — e.g., multithreading (or distributed) across population members and, within each, further parallelize over my 17 runs.
Here’s a simplified example illustrating the idea:

function rosenbrock(x, input)
    n = length(x)
    return sum(100 * (x[2i-1]^2 - x[2i])^2 + (x[2i-1] - 1)^2 for i in 1:div(n, 2)) + sum(input)
end

function my_model(x, total_input)
    results = Vector{Float64}(undef, length(total_input))
    for (i, input) in enumerate(total_input)
        y = rosenbrock(x, input)
        results[i] = y
    end
    return sum(results)
end

You can see that the for loop in my_model (over total_input) represents the 17 independent runs.
I’m wondering if there’s a clean way to parallelize both this inner loop and the CMA-ES population evaluations at the same time, without the two interfering with each other.
Any guidance or example would be greatly appreciated!
Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions