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

'archipelago' doesn't parallelize to different cores #126

Closed
osm3000 opened this issue Jul 21, 2017 · 0 comments
Closed

'archipelago' doesn't parallelize to different cores #126

osm3000 opened this issue Jul 21, 2017 · 0 comments

Comments

@osm3000
Copy link

osm3000 commented Jul 21, 2017

Hi,

I've tried to make use of archipelago in order to parallelize the problem solution. I first tried the toy example mentioned in:
https://esa.github.io/pagmo2/docs/python/tutorials/using_archipelago.html
Indeed I can see that all the cores are utilized.
However, when I made my own problem (it reads data from a file, and learn discretization for it), I no longer see any improvement in the code:

import pygmo as pg
import numpy as np
import matplotlib.pyplot as plt
from numba import jit, float64
import pickle
class auto_quantizer:
    def __init__(self,dim, min_value, max_value, actual_data):
        self.dim = dim
        self.min_value = min_value
        self.max_value = max_value
        self.actual_data = actual_data
    def fitness(self, x):
        return [self.determine_nearest_value(x)]

    def get_bounds(self):
        return (np.full((self.dim,),self.min_value),np.full((self.dim,),self.max_value))

    def determine_nearest_value(self, x):
        total_loss = 0
        for data_point in self.actual_data:
            total_loss += np.min(np.abs(x - data_point))
        return total_loss
if __name__ == '__main__':
    actual_data = pickle.load(open('speed.pkl', 'rb'))[0]
    actual_data = np.array(actual_data)
    print ("actual_data: ", actual_data.shape)
    min_value = np.min(actual_data)
    max_value = np.max(actual_data)
    nb_levels = 8
    uni_levels = np.linspace(min_value, max_value, nb_levels)
    prob = pg.problem(auto_quantizer(nb_levels, min_value, max_value, actual_data))
    algo = pg.algorithm(pg.sea(gen = 2000))
    archi = pg.archipelago(32,algo=algo, prob=prob, pop_size=200)
    print(archi)
    archi.evolve()
    archi.wait()
    print (archi.get_champions_f())

I can see only one core is being utilized.
Any thoughts on why?

@osm3000 osm3000 closed this as completed Jul 21, 2017
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