Pattern for modifying objects on distant processing units

25 views
Skip to first unread message

ldr

unread,
Dec 14, 2021, 7:55:38 AM12/14/21
to deap-users
Hi, I am quite new to DEAP and Python, so I apologize if the following question is too trivial.

As per the DEAP documentation, when using multiple processors: " modifications made to an object on a distant processing unit will not be made available to the other processing units"

I am using a genetic algorithm to solve an optimization problem. In my application, I have the need to modify individuals during the execution of the evaluation function. My code works exactly as intended in single processing mode. However, when I converted it to multiprocessing using the multiprocessing module, I ran into the problem that my "distant" modifications are not kept.

My individuals take the form of a list of lists and the modifications in the inner lists are not kept. Each inner list has two elements, and integer, that is never modified and some important data generated during the evaluation cycle of the algorithm, which needs to be modified during that phase.

The documentation also states: " explicitly communicated through function arguments and return values". However, as someone new to DEAP and Python I really cannot figure out how this can be practically implemented. For example, from the evaluation function I cannot return the updated individual because DEAP requires the evaluation function to return a tuple with the evaluation score.

My question is therefore: What is the appropriate pattern for modifying objects in distant processing units and keep the modifications?

Thanks for the help!
Reply all
Reply to author
Forward
0 new messages