I am new to python and started using the genetic algorithm (GA) to do some kind of curve binding. For this GA, I use the (amazing) pyevolve library ( http://pyevolve.sourceforge.net/ ), which can significantly reduce the computation time using multiprocessing.
This is where my problem arises: the curve I want to approximate is an array that is read from an excel file and saved as a global variable at the beginning of my program. When using the python multiprocessing module, each process creates its own python instance with its own global variable. This makes every person in every generation of the algorithm (every process) open and read the excel file again and again. Opening large excel files can lead to a huge amount of time, so it would be nice to open this file only once and make the file readable for each process / individual file.
Multiprocessing is initiated in the pyevolve library, and I do not want to change it in order to simplify its updating. Unfortunately, this means just passing the variable to the process pool through for example
p = Process(target=my_func,args=(my_array))
not an option for me. This is the only solution I have found so far.
Does anyone know a different way to make my_array accessible from each process?
Thanks in advance!
python multiprocessing global pyevolve
Marku
source share