These are chat archives for DEAP/deap

29th
Jun 2016
Fran├žois-Michel De Rainville
@fmder
Jun 29 2016 10:03
@shivamkalra Checkout the OneMax example
This message was deleted
@manuparra a) yes b) no, not entirely. The evolution loop is a markov process and thus the next generation depends on the the previous ones. But, there is something called the Island model where the population is divided in a few subgroups that are independent for a few generation and then share individuals through migration. There is an example of this model (parallelized) in the examples/ga folder.
Manuel Parra
@manuparra
Jun 29 2016 15:02

Thanks @fmder. I'm trying to parallelize Mutation as follow:

def mutparallel(indpb,segment):
    for i in xrange(len(segment)):    
        if random.random() < indpb:
            #change[i] some value
    return segment

And then, my mutation function is:

def basicmutation(individual,indpb)

    size = len(individual)    

    cores=mp.cpu_count()

    pool = mp.Pool(cores)

    # Numeber of elements to parallelize for each core
    slice_len=int(math.ceil(float(size)/float(cores)))

    # Split individual in a list with X lists of slice_len size
    segments=[individual[i:i+slice_len] for i in range(0, size, slice_len)]

    # Parameters 
    func = partial(mutparallel, indpb)

    # Map 
    results=pool.map(func,segments)

    pool.close()
    pool.join()

    individual=list(itertools.chain(*results))

    return individual,

And now: Must I use deepcopy to return mutated individual ?