0

I want to solve a multi-objective problem with nsga2 or moead taking advantage of the parallelism available in pygmo library. I have seen a very nice example on github posted below. However I am not sure I understand it correctly. Setting the number of generations to 10 in the nsga2 algorithm, it then loops 10 iterations (the so-called number of evolutions) calling the function evolve on the archipelago. Why should we do this evolution specifically ? Could we not set the number of generations to 100 instead of 10 ? or use archi.evolve(10).

The goal here is to speed up the pareto frontier approximation, e.g. instead of using 200 gen and 200 pop size on one core , I would expect that parallelize 50 gen and 50 pop size on 8 cores would do the job. But I am not sure how to do it.

""Example that illustrates multi-objective optimization using pygmo."""

import pygmo as pg
import numpy as np
from multiprocessing import Process, freeze_support

def optimize(popsize=100, generations=10, islands=3, evolutions=10,
             prob=pg.problem(FonsecaFleming(5))):
    """Start optimization process."""
    # set up algorithm and optimize
    algo = pg.algorithm(pg.nsga2(gen=generations))
    archi = pg.archipelago(islands, algo=algo, prob=prob, pop_size=popsize)

    # evolution
    fits_log, vectors_log = [], []
    for e in range(0, evolutions):
        # evolve islands
        archi.evolve(e)
        archi.wait()
        # extract data
        vectors = [isl.get_population().get_x() for isl in archi]
        vectors_log.append(vectors)
        fits = [isl.get_population().get_f() for isl in archi]
        fits_log.append(fits)

    return [fits_log, vectors_log]


if __name__ == '__main__':
    freeze_support()
    Process(target=optimize).start()

Because nsga2 does not seem compatible with a topology in pygmo, I have decided to use moead instead (tell me if i am wrong).

Using a priori-knowledge, i have created a population of 200 individuals , each a vector of 30 variables. I have set fully connected topology to allow communications between the islands of the archipelago. See below my code.

   algo.set_verbosity(10)
   archi = pg.archipelago(n=8, algo=algo, pop=pop)
   archi.set_topology(pg.fully_connected(len(archi)))
   archi.evolve()
  archi.wait_check()  

and output:

Output of pygmo archipelago

The code runs but I would have expected different values in the log (ADF, ideal1, ideal2) displayed for each process. Indeed for each generation , all islands have the same output parameters. Is that normal ? Also it is not that much faster (464 seconds instead of 729s)...

Sophie
  • 11
  • 3
  • Hi Sophie, you may want to ask this question also in https://or.stackexchange.com/ it is similar to stackoverflow, but focused on problems similar to yours (I think so), a bit less on coding. – dankal444 Jan 04 '23 at 22:31

0 Answers0